From 81b2604ee418dc5fd5158406d32868c8d15f3256 Mon Sep 17 00:00:00 2001 Message-Id: <81b2604ee418dc5fd5158406d32868c8d15f3256@dist-git> From: Laine Stump Date: Wed, 12 Sep 2018 11:23:47 -0400 Subject: [PATCH] conf: correct false boot order error during domain parse MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit virDomainDefCollectBootOrder() is called for every item on the list for each type of device. One of the checks it makes is to gather the order attributes from the element of all devices, and assure that no two devices have been given the same order. Since (internally to libvirt, *not* in the domain XML) an is on both the list of hostdev devices and the list of network devices, it will be counted twice, and the code that checks for multiple devices with the same boot order will give a false positive. To remedy this, we make sure to return early for hostdev devices that have a parent.type != NONE. This was introduced in commit 5b75a4, which was first in libvirt-4.4.0. Resolves: https://bugzilla.redhat.com/1601318 Signed-off-by: Laine Stump Reviewed-by: Ján Tomko (cherry picked from commit 7ea7342996d74591e00bcbf14b1eb3995f77a199) Signed-off-by: Laine Stump Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 8 ++++ .../net-hostdev-bootorder.args | 27 ++++++++++++ .../net-hostdev-bootorder.xml | 36 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../net-hostdev-bootorder.xml | 42 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 6 files changed, 117 insertions(+) create mode 100644 tests/qemuxml2argvdata/net-hostdev-bootorder.args create mode 100644 tests/qemuxml2argvdata/net-hostdev-bootorder.xml create mode 100644 tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ed9687fde9..eb4e9ac523 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5072,6 +5072,14 @@ virDomainDefCollectBootOrder(virDomainDefPtr def ATTRIBUTE_UNUSED, if (info->bootIndex == 0) return 0; + if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV && + dev->data.hostdev->parent.type != VIR_DOMAIN_DEVICE_NONE) { + /* This hostdev is a child of a higher level device + * (e.g. interface), and thus already being counted on the + * list for the other device type. + */ + return 0; + } if (virAsprintf(&order, "%u", info->bootIndex) < 0) goto cleanup; diff --git a/tests/qemuxml2argvdata/net-hostdev-bootorder.args b/tests/qemuxml2argvdata/net-hostdev-bootorder.args new file mode 100644 index 0000000000..e632d9b195 --- /dev/null +++ b/tests/qemuxml2argvdata/net-hostdev-bootorder.args @@ -0,0 +1,27 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-i686 \ +-name QEMUGuest1 \ +-S \ +-machine pc,accel=tcg,usb=off,dump-guest-core=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ +server,nowait \ +-mon chardev=charmonitor,id=monitor,mode=control \ +-rtc base=utc \ +-no-shutdown \ +-no-acpi \ +-usb \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ +-device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0,\ +bootindex=2 \ +-device pci-assign,host=03:07.1,id=hostdev0,bootindex=1,bus=pci.0,addr=0x3 diff --git a/tests/qemuxml2argvdata/net-hostdev-bootorder.xml b/tests/qemuxml2argvdata/net-hostdev-bootorder.xml new file mode 100644 index 0000000000..cd9f32b2f3 --- /dev/null +++ b/tests/qemuxml2argvdata/net-hostdev-bootorder.xml @@ -0,0 +1,36 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + +
+ + + + + + + + +
+ + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 02bb9889ee..d97dc0ea8d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1321,6 +1321,8 @@ mymain(void) DO_TEST("net-mcast", NONE); DO_TEST("net-udp", NONE); DO_TEST("net-hostdev", NONE); + DO_TEST("net-hostdev-bootorder", + QEMU_CAPS_BOOTINDEX, QEMU_CAPS_PCI_BOOTINDEX); DO_TEST("net-hostdev-multidomain", NONE); DO_TEST("net-hostdev-vfio", QEMU_CAPS_DEVICE_VFIO_PCI); diff --git a/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml b/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml new file mode 100644 index 0000000000..d9ecf40cf0 --- /dev/null +++ b/tests/qemuxml2xmloutdata/net-hostdev-bootorder.xml @@ -0,0 +1,42 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 219136 + 219136 + 1 + + hvm + + + destroy + restart + destroy + + /usr/bin/qemu-system-i686 + + + + + +
+ + +
+ + +
+ + + + + +
+ + +
+ + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index b76410b2c1..5bd522e765 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -454,6 +454,8 @@ mymain(void) DO_TEST("net-virtio-network-portgroup", NONE); DO_TEST("net-virtio-rxtxqueuesize", NONE); DO_TEST("net-hostdev", NONE); + DO_TEST("net-hostdev-bootorder", + QEMU_CAPS_BOOTINDEX, QEMU_CAPS_PCI_BOOTINDEX); DO_TEST("net-hostdev-vfio", NONE); DO_TEST("net-midonet", NONE); DO_TEST("net-openvswitch", NONE); -- 2.19.0