]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Use PHBs to fill holes in PCI bus numbering
authorAndrea Bolognani <abologna@redhat.com>
Fri, 26 May 2017 17:34:21 +0000 (19:34 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Sat, 15 Jul 2017 12:50:42 +0000 (14:50 +0200)
PCI bus has to be numbered sequentially, and no index can be
missing, so libvirt will fill in the blanks automatically for
the user.

Up until now, it has done so using either pci-bridge, for machine
types based on legacy PCI, or pcie-root-port, for machine types
based on PCI Express. Neither choice is good for pSeries guests,
where PHBs (pci-root) should be used instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
src/qemu/qemu_domain_address.c
tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-2.args
tests/qemuxml2argvtest.c
tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-2.xml
tests/qemuxml2xmltest.c

index bea95da444a0ad73dfc328532b95630ec9bcd1e4..0fe0d188af304fcc190325c2775364a0978b8b1d 100644 (file)
@@ -1097,10 +1097,14 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
      * that don't yet have a corresponding controller in the domain
      * config.
      */
-    if (hasPCIeRoot)
+    if (qemuDomainIsPSeries(def)) {
+        /* pSeries guests should use PHBs (pci-root controllers) */
+        defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT;
+    } else if (hasPCIeRoot) {
         defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT;
-    else
+    } else {
         defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE;
+    }
 
     for (i = 1; i < addrs->nbuses; i++) {
 
@@ -2160,7 +2164,13 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
             dev.data.controller = def->controllers[contIndex];
             /* set connect flags so it will be properly addressed */
             qemuDomainFillDevicePCIConnectFlags(def, &dev, qemuCaps, driver);
-            if (qemuDomainPCIAddressReserveNextAddr(addrs,
+
+            /* Reserve an address for the controller. pci-root and pcie-root
+             * controllers don't plug into any other PCI controller, hence
+             * they should skip this step */
+            if (bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
+                bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT &&
+                qemuDomainPCIAddressReserveNextAddr(addrs,
                                                     &dev.data.controller->info) < 0) {
                 goto cleanup;
             }
index 1cb583132d2e913e5e8c9bb0bac8dcc46aa8ab92..13fed02f809d645a31386beef6d1dc32c8248450 100644 (file)
@@ -19,4 +19,4 @@ server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=readline \
 -boot c \
 -device spapr-pci-host-bridge,index=1,id=pci.2 \
--device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1
+-device spapr-pci-host-bridge,index=2,id=pci.1
index 6eeca0aab3bea4b29b4213671b28bad50c66aa2c..35c06ef247507ab15078b6bd3c2ef6508b64d02f 100644 (file)
@@ -1767,7 +1767,6 @@ mymain(void)
     DO_TEST("pseries-many-buses-2",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-hostdevs-1",
             QEMU_CAPS_NODEFCONFIG,
index 75dfabfcabf45c0de47046bb79b8c0d5251a6d77..14f3e36244ce8613f79023988fca73c712cdb66c 100644 (file)
       <target index='1'/>
     </controller>
     <controller type='usb' index='0' model='none'/>
-    <controller type='pci' index='1' model='pci-bridge'>
-      <model name='pci-bridge'/>
-      <target chassisNr='1'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
+    <controller type='pci' index='1' model='pci-root'>
+      <model name='spapr-pci-host-bridge'/>
+      <target index='2'/>
     </controller>
     <memballoon model='none'/>
     <panic model='pseries'/>
index 05af6b17e2d709fb704973140179146b68649cc2..a948a61d8eb0f966cd910615773d7d4de6d25f36 100644 (file)
@@ -686,7 +686,6 @@ mymain(void)
     DO_TEST("pseries-many-buses-2",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-hostdevs-1",
             QEMU_CAPS_NODEFCONFIG,