]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: handle unassigned PCI hostdevs in command line
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Tue, 17 Dec 2019 20:35:03 +0000 (17:35 -0300)
committerCole Robinson <crobinso@redhat.com>
Wed, 18 Dec 2019 18:08:28 +0000 (13:08 -0500)
Previous patch made it possible for the QEMU driver to check if
a given PCI hostdev is unassigned, by checking if dev->info->type is
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED, meaning that this device
shouldn't be part of the actual guest launch.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/hostdev-pci-address-unassigned.args [new file with mode: 0644]
tests/qemuxml2argvtest.c

index a459cfef66bbe219633f88da7601085ca4168e39..a8137b3a326c4d0f58aeb159f7728cb816550281 100644 (file)
@@ -5342,6 +5342,10 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
                 *bootHostdevNet = 0;
             }
 
+           /* Ignore unassigned devices  */
+           if (hostdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNASSIGNED)
+               continue;
+
             if (qemuCommandAddExtDevice(cmd, hostdev->info) < 0)
                 return -1;
 
diff --git a/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.args b/tests/qemuxml2argvdata/hostdev-pci-address-unassigned.args
new file mode 100644 (file)
index 0000000..42fae17
--- /dev/null
@@ -0,0 +1,31 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-delete \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-delete/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-delete/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-delete/.config \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name delete \
+-S \
+-machine pc,accel=kvm,usb=off,dump-guest-core=off \
+-m 256 \
+-realtime mlock=off \
+-smp 4,sockets=4,cores=1,threads=1 \
+-uuid 583a8e8e-f0ce-4f53-89ab-092862148b25 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-delete/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-usb \
+-device vfio-pci,host=0005:90:01.0,id=hostdev0,bus=pci.0,addr=0x3 \
+-device vfio-pci,host=0005:90:01.2,id=hostdev2,bus=pci.0,addr=0x4 \
+-device vfio-pci,host=0005:90:01.3,id=hostdev3,bus=pci.0,addr=0x5 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
index 118a460633d8536e4460ae9eb48bc43e4aa3de06..bfbed5c31dec4abf02a4c6edeb879f1895dc46bc 100644 (file)
@@ -1332,6 +1332,10 @@ mymain(void)
             QEMU_CAPS_KVM,
             QEMU_CAPS_DEVICE_VFIO_PCI);
 
+    DO_TEST("hostdev-pci-address-unassigned",
+            QEMU_CAPS_KVM,
+            QEMU_CAPS_DEVICE_VFIO_PCI);
+
     DO_TEST("serial-file-log",
             QEMU_CAPS_CHARDEV_FILE_APPEND,
             QEMU_CAPS_DEVICE_ISA_SERIAL,