[libvirt] [Addendum to PATCH 6/6] A short bit to squash into 'auto-assign virtio devices to PCIe'

Laine Stump laine at laine.org
Mon Aug 8 11:39:06 UTC 2016


I had forgotten to take care of assigning virtio-scsi-pci to a PCIe
address when appropriate. I'm squashing this small patch into PATCH
6/6.

---
 src/qemu/qemu_domain_address.c                              | 12 ++++++++++--
 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.args    |  8 ++++++--
 tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.xml     |  5 +++++
 tests/qemuxml2argvtest.c                                    |  1 +
 tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pcie.xml | 12 ++++++++++--
 tests/qemuxml2xmltest.c                                     |  1 +
 6 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 4dfd6be..d218ac8 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1179,9 +1179,17 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
                 def->controllers[i]->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI)
                 flags |= VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
 
-            /* SCSI controllers can be hot plugged. All others can't */
-            if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
+            if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) {
+                /* if it is a virtio-scsi controller and qemu supports PCIe for
+                 * virtio devices, then auto-assign a PCIe address
+                 */
+                if (def->controllers[i]->model
+                    == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI && virtioPCIe)
+                    flags = VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
+
+                /* All SCSI controllers can be hot plugged. All other controllers can't */
                 flags |= VIR_PCI_CONNECT_HOTPLUGGABLE;
+            }
 
             if (virDomainPCIAddressReserveNextSlot(addrs,
                                                    &def->controllers[i]->info,
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.args b/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.args
index 9cb150c..8b9d74a 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.args
@@ -27,10 +27,14 @@ QEMU_AUDIO_DRV=none \
 addr=0x1d \
 -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pcie.0,addr=0x1d.0x1 \
 -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pcie.0,addr=0x1d.0x2 \
+-device virtio-scsi-pci,id=scsi0,bus=pci.4,addr=0x0 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \
 -device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \
+-drive file=/aarch64.raw,format=raw,if=none,id=drive-scsi0-0-0-1 \
+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=1,\
+drive=drive-scsi0-0-0-1,id=scsi0-0-0-1 \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-virtio-disk1 \
--device virtio-blk-pci,bus=pci.4,addr=0x0,drive=drive-virtio-disk1,\
+-device virtio-blk-pci,bus=pci.5,addr=0x0,drive=drive-virtio-disk1,\
 id=virtio-disk1 \
 -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-virtio-disk2 \
 -device virtio-blk-pci,bus=pcie.0,addr=0x8,drive=drive-virtio-disk2,\
@@ -51,4 +55,4 @@ addr=0x7 \
 -object rng-random,id=objrng0,filename=/dev/random \
 -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0xa \
 -object rng-random,id=objrng1,filename=/dev/random \
--device virtio-rng-pci,rng=objrng1,id=rng1,bus=pci.5,addr=0x0
+-device virtio-rng-pci,rng=objrng1,id=rng1,bus=pci.6,addr=0x0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.xml
index d3c7c05..37816fa 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-virtio-pcie.xml
@@ -21,11 +21,16 @@
     <controller type='pci' model='pcie-root-port'/>
     <controller type='pci' model='pcie-root-port'/>
     <controller type='pci' model='pcie-root-port'/>
+    <controller type='scsi' model='virtio-scsi'/>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest1'/>
       <target dev='sda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
+    <disk type='file' device='disk'>
+      <source file='/aarch64.raw'/>
+      <target dev='sdb' bus='scsi'/>
+    </disk>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
       <target dev='vdb' bus='virtio'/>
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index ce0158d..9685101 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1690,6 +1690,7 @@ mymain(void)
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
+            QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL,
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pcie.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pcie.xml
index 70d0cd2..304e031 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pcie.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virtio-pcie.xml
@@ -19,10 +19,15 @@
       <target dev='sda' bus='sata'/>
       <address type='drive' controller='0' bus='0' target='0' unit='0'/>
     </disk>
+    <disk type='file' device='disk'>
+      <source file='/aarch64.raw'/>
+      <target dev='sdb' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
+    </disk>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
       <target dev='vdb' bus='virtio'/>
-      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
     </disk>
     <disk type='block' device='disk'>
       <source dev='/dev/HostVG/QEMUGuest2'/>
@@ -60,6 +65,9 @@
       <target chassis='6' port='0x28'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </controller>
+    <controller type='scsi' index='0' model='virtio-scsi'>
+      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
+    </controller>
     <controller type='usb' index='0' model='ich9-ehci1'>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
     </controller>
@@ -117,7 +125,7 @@
     <rng model='virtio'>
       <backend model='random'>/dev/random</backend>
       <hotplug require='yes'/>
-      <address type='pci' domain='0x0000' bus='0x05' slot='0x00' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x06' slot='0x00' function='0x0'/>
     </rng>
   </devices>
 </domain>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 40c284d..3dcc8f1 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -701,6 +701,7 @@ mymain(void)
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
+            QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL,
-- 
2.7.4




More information about the libvir-list mailing list