From d163f1619f77c9f4a42846a45a121a154520b66c Mon Sep 17 00:00:00 2001 From: Vasyl Saienko Date: Sun, 2 Feb 2025 14:54:41 +0200 Subject: [PATCH] [devstack ]Use tap interfaces for VMs In order to implement port group testing on CI we need to make sure that we can change mac addresses of interfaces which is possible with tap interfaces, but not supported for direct mode. This patch updates VM setup to use taps for interfaces. Related-Bug: #1718481 Change-Id: I0ef1ad1b2e50cb26839c618a1367704d51ed8a4d --- devstack/tools/ironic/scripts/configure-vm.py | 3 +++ devstack/tools/ironic/scripts/create-node.sh | 14 +++----------- devstack/tools/ironic/templates/vm.xml | 6 +++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/devstack/tools/ironic/scripts/configure-vm.py b/devstack/tools/ironic/scripts/configure-vm.py index 18590279ae..aeb25ff15c 100755 --- a/devstack/tools/ironic/scripts/configure-vm.py +++ b/devstack/tools/ironic/scripts/configure-vm.py @@ -79,6 +79,8 @@ def main(): help='The number of interfaces to add to VM.'), parser.add_argument('--mac', default=None, help='The mac for the first interface on the vm') + parser.add_argument('--mtu', default=None, + help='The mtu for the interfaces on the vm') parser.add_argument('--console-log', help='File to log console') parser.add_argument('--emulator', default=None, @@ -114,6 +116,7 @@ def main(): 'bootdev': args.bootdev, 'interface_count': args.interface_count, 'mac': args.mac, + 'mtu': args.mtu, 'nicdriver': args.libvirt_nic_driver, 'emulator': args.emulator, 'disk_format': args.disk_format, diff --git a/devstack/tools/ironic/scripts/create-node.sh b/devstack/tools/ironic/scripts/create-node.sh index 5cca0ffc25..4920f6d857 100755 --- a/devstack/tools/ironic/scripts/create-node.sh +++ b/devstack/tools/ironic/scripts/create-node.sh @@ -88,16 +88,8 @@ BLOCK_SIZE=${BLOCK_SIZE:-512} INTERFACE_COUNT=${INTERFACE_COUNT:-1} for int in $(seq 1 $INTERFACE_COUNT); do - tapif=tap-${NAME}i${int} ovsif=ovs-${NAME}i${int} - # NOTE(vsaienko) use veth pair here to ensure that interface - # exists in OVS even when VM is powered off. - sudo ip link add dev $tapif type veth peer name $ovsif - for l in $tapif $ovsif; do - sudo ip link set dev $l up - sudo ip link set $l mtu $INTERFACE_MTU - done - sudo ovs-vsctl add-port $BRIDGE $ovsif + sudo ovs-vsctl --no-wait add-port $BRIDGE $ovsif done if [ -n "$MAC_ADDRESS" ] ; then @@ -133,9 +125,9 @@ if ! virsh list --all | grep -q $NAME; then --arch $ARCH --cpus $CPU --memory $MEM --libvirt-nic-driver $LIBVIRT_NIC_DRIVER \ --disk-format $DISK_FORMAT $VM_LOGGING --engine $ENGINE $UEFI_OPTS $vm_opts \ --interface-count $INTERFACE_COUNT $MAC_ADDRESS --machine_type $MACHINE_TYPE \ - --block-size $BLOCK_SIZE >&2 + --block-size $BLOCK_SIZE --mtu ${INTERFACE_MTU} >&2 fi # echo mac in format mac1,ovs-node-0i1;mac2,ovs-node-0i2;...;macN,ovs-node0iN -VM_MAC=$(echo -n $(virsh domiflist $NAME |awk '/tap-/{print $5","$3}')|tr ' ' ';' |sed s/tap-/ovs-/g) +VM_MAC=$(echo -n $(virsh domiflist $NAME |awk '/ovs-/{print $5","$1}')|tr ' ' ';') echo -n "$VM_MAC $VBMC_PORT $PDU_OUTLET" diff --git a/devstack/tools/ironic/templates/vm.xml b/devstack/tools/ironic/templates/vm.xml index f91b166b78..eefd1b68bd 100644 --- a/devstack/tools/ironic/templates/vm.xml +++ b/devstack/tools/ironic/templates/vm.xml @@ -50,12 +50,12 @@ {% endfor %} {% for n in range(1, interface_count+1) %} - + {% if n == 1 and mac %} {% endif %} - - + + {% if uefi_loader and bootdev == 'network' %} {% endif %}