Blob Blame History Raw
From bfb6c327ab4a70d54ed03b8498030d4467b00cd2 Mon Sep 17 00:00:00 2001
Message-Id: <bfb6c327ab4a70d54ed03b8498030d4467b00cd2@dist-git>
From: Andrea Bolognani <abologna@redhat.com>
Date: Tue, 18 Jul 2017 12:10:04 +0200
Subject: [PATCH] qemu: Use PHBs when extending the guest PCI topology

When looking for slots suitable for a PCI device, libvirt
might need to add an extra PCI controller: for pSeries guests,
we want that extra controller to be a PHB (pci-root) rather
than a PCI bridge.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
(cherry picked from commit 64645b78a4ecb728c37ae6d769c550bf3c74819d)

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1280542

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/domain_addr.c                             | 56 +++++++++--------
 src/conf/domain_addr.h                             |  2 +
 src/qemu/qemu_domain_address.c                     |  4 ++
 .../qemuxml2argv-pseries-hostdevs-2.args           |  8 +--
 .../qemuxml2argv-pseries-hostdevs-3.args           |  8 +--
 .../qemuxml2argv-pseries-many-buses-1.args         |  4 +-
 .../qemuxml2argv-pseries-many-devices.args         | 66 ++++++++++----------
 tests/qemuxml2argvtest.c                           |  4 --
 .../qemuxml2xmlout-pseries-hostdevs-2.xml          |  9 ++-
 .../qemuxml2xmlout-pseries-hostdevs-3.xml          | 16 +++--
 .../qemuxml2xmlout-pseries-many-buses-1.xml        |  7 +--
 .../qemuxml2xmlout-pseries-many-devices.xml        | 71 +++++++++++-----------
 tests/qemuxml2xmltest.c                            |  4 --
 13 files changed, 129 insertions(+), 130 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index b8e5902c07..8990372ae0 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -397,33 +397,39 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSetPtr addrs,
      */
 
     if (flags & VIR_PCI_CONNECT_TYPE_PCI_DEVICE) {
-        model = VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE;
+        if (addrs->multipleRootsSupported) {
+            /* Use a pci-root controller to expand the guest's PCI
+             * topology if it supports having more than one */
+            model = VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT;
+        } else {
+            model = VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE;
 
-        /* if there aren't yet any buses that will accept a
-         * pci-bridge, and the caller is asking for one, we'll need to
-         * add a dmi-to-pci-bridge first.
-         */
-        needDMIToPCIBridge = true;
-        for (i = 0; i < addrs->nbuses; i++) {
-            if (addrs->buses[i].flags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) {
-                needDMIToPCIBridge = false;
-                break;
-            }
-        }
-        if (needDMIToPCIBridge && add == 1) {
-            /* We need to add a single pci-bridge to provide the bus
-             * our legacy PCI device will be plugged into; however, we
-             * have also determined that there isn't yet any proper
-             * place to connect that pci-bridge we're about to add (on
-             * a system with pcie-root, that "proper place" would be a
-             * dmi-to-pci-bridge". So, to give the pci-bridge a place
-             * to connect, we increase the count of buses to add,
-             * while also incrementing the bus number in the address
-             * for the device (since the pci-bridge will now be at an
-             * index 1 higher than the caller had anticipated).
+            /* if there aren't yet any buses that will accept a
+             * pci-bridge, and the caller is asking for one, we'll need to
+             * add a dmi-to-pci-bridge first.
              */
-            add++;
-            addr->bus++;
+            needDMIToPCIBridge = true;
+            for (i = 0; i < addrs->nbuses; i++) {
+                if (addrs->buses[i].flags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) {
+                    needDMIToPCIBridge = false;
+                    break;
+                }
+            }
+            if (needDMIToPCIBridge && add == 1) {
+                /* We need to add a single pci-bridge to provide the bus
+                 * our legacy PCI device will be plugged into; however, we
+                 * have also determined that there isn't yet any proper
+                 * place to connect that pci-bridge we're about to add (on
+                 * a system with pcie-root, that "proper place" would be a
+                 * dmi-to-pci-bridge". So, to give the pci-bridge a place
+                 * to connect, we increase the count of buses to add,
+                 * while also incrementing the bus number in the address
+                 * for the device (since the pci-bridge will now be at an
+                 * index 1 higher than the caller had anticipated).
+                 */
+                add++;
+                addr->bus++;
+            }
         }
     } else if (flags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE &&
                addrs->buses[0].model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT) {
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
index a5afefda95..49f30332f0 100644
--- a/src/conf/domain_addr.h
+++ b/src/conf/domain_addr.h
@@ -108,6 +108,8 @@ struct _virDomainPCIAddressSet {
     size_t nbuses;
     bool dryRun;          /* on a dry run, new buses are auto-added
                              and addresses aren't saved in device infos */
+    /* If true, the guest can have multiple pci-root controllers */
+    bool multipleRootsSupported;
 };
 typedef struct _virDomainPCIAddressSet virDomainPCIAddressSet;
 typedef virDomainPCIAddressSet *virDomainPCIAddressSetPtr;
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 4de868abdf..d19ffea7c9 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1056,6 +1056,10 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
 
     addrs->dryRun = dryRun;
 
+    /* pSeries domains support multiple pci-root controllers */
+    if (qemuDomainIsPSeries(def))
+        addrs->multipleRootsSupported = true;
+
     for (i = 0; i < def->ncontrollers; i++) {
         virDomainControllerDefPtr cont = def->controllers[i];
         size_t idx = cont->idx;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-2.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-2.args
index c43e15d456..83d4306036 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-2.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-2.args
@@ -18,7 +18,7 @@ QEMU_AUDIO_DRV=none \
 server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=readline \
 -boot c \
--device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1 \
--device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1 \
--device vfio-pci,host=0001:01:00.0,id=hostdev0,bus=pci.1,addr=0x2 \
--device vfio-pci,host=0005:90:01.0,id=hostdev1,bus=pci.0,addr=0x2
+-device spapr-pci-host-bridge,index=1,id=pci.1 \
+-device virtio-scsi-pci,id=scsi0,bus=pci.1.0,addr=0x1 \
+-device vfio-pci,host=0001:01:00.0,id=hostdev0,bus=pci.1.0,addr=0x2 \
+-device vfio-pci,host=0005:90:01.0,id=hostdev1,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-3.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-3.args
index 99df2e71c9..eda6cc73ac 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-3.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-hostdevs-3.args
@@ -18,7 +18,7 @@ QEMU_AUDIO_DRV=none \
 server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=readline \
 -boot c \
--device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1 \
--device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.0,addr=0x2 \
--device vfio-pci,host=0001:01:00.0,id=hostdev0,bus=pci.2,addr=0x1 \
--device vfio-pci,host=0001:01:00.1,id=hostdev1,bus=pci.0,addr=0x3
+-device spapr-pci-host-bridge,index=1,id=pci.1 \
+-device spapr-pci-host-bridge,index=2,id=pci.2 \
+-device vfio-pci,host=0001:01:00.0,id=hostdev0,bus=pci.2.0,addr=0x1 \
+-device vfio-pci,host=0001:01:00.1,id=hostdev1,bus=pci.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-1.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-1.args
index bf78fc19a4..eb5ccbd3a4 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-1.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-buses-1.args
@@ -18,5 +18,5 @@ QEMU_AUDIO_DRV=none \
 server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=readline \
 -boot c \
--device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1 \
--device virtio-scsi-pci,id=scsi0,bus=pci.1,addr=0x1
+-device spapr-pci-host-bridge,index=1,id=pci.1 \
+-device virtio-scsi-pci,id=scsi0,bus=pci.1.0,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-devices.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-devices.args
index 1db4533bf0..f20bc52f7c 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-devices.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-many-devices.args
@@ -18,36 +18,36 @@ QEMU_AUDIO_DRV=none \
 server,nowait \
 -mon chardev=charmonitor,id=monitor,mode=readline \
 -boot c \
--device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1 \
--device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x2 \
--device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x3 \
--device virtio-scsi-pci,id=scsi2,bus=pci.0,addr=0x4 \
--device virtio-scsi-pci,id=scsi3,bus=pci.0,addr=0x5 \
--device virtio-scsi-pci,id=scsi4,bus=pci.0,addr=0x6 \
--device virtio-scsi-pci,id=scsi5,bus=pci.0,addr=0x7 \
--device virtio-scsi-pci,id=scsi6,bus=pci.0,addr=0x8 \
--device virtio-scsi-pci,id=scsi7,bus=pci.0,addr=0x9 \
--device virtio-scsi-pci,id=scsi8,bus=pci.0,addr=0xa \
--device virtio-scsi-pci,id=scsi9,bus=pci.0,addr=0xb \
--device virtio-scsi-pci,id=scsi10,bus=pci.0,addr=0xc \
--device virtio-scsi-pci,id=scsi11,bus=pci.0,addr=0xd \
--device virtio-scsi-pci,id=scsi12,bus=pci.0,addr=0xe \
--device virtio-scsi-pci,id=scsi13,bus=pci.0,addr=0xf \
--device virtio-scsi-pci,id=scsi14,bus=pci.0,addr=0x10 \
--device virtio-scsi-pci,id=scsi15,bus=pci.0,addr=0x11 \
--device virtio-scsi-pci,id=scsi16,bus=pci.0,addr=0x12 \
--device virtio-scsi-pci,id=scsi17,bus=pci.0,addr=0x13 \
--device virtio-scsi-pci,id=scsi18,bus=pci.0,addr=0x14 \
--device virtio-scsi-pci,id=scsi19,bus=pci.0,addr=0x15 \
--device virtio-scsi-pci,id=scsi20,bus=pci.0,addr=0x16 \
--device virtio-scsi-pci,id=scsi21,bus=pci.0,addr=0x17 \
--device virtio-scsi-pci,id=scsi22,bus=pci.0,addr=0x18 \
--device virtio-scsi-pci,id=scsi23,bus=pci.0,addr=0x19 \
--device virtio-scsi-pci,id=scsi24,bus=pci.0,addr=0x1a \
--device virtio-scsi-pci,id=scsi25,bus=pci.0,addr=0x1b \
--device virtio-scsi-pci,id=scsi26,bus=pci.0,addr=0x1c \
--device virtio-scsi-pci,id=scsi27,bus=pci.0,addr=0x1d \
--device virtio-scsi-pci,id=scsi28,bus=pci.0,addr=0x1e \
--device virtio-scsi-pci,id=scsi29,bus=pci.0,addr=0x1f \
--device virtio-scsi-pci,id=scsi30,bus=pci.1,addr=0x1 \
--device virtio-scsi-pci,id=scsi31,bus=pci.1,addr=0x2
+-device spapr-pci-host-bridge,index=1,id=pci.1 \
+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x1 \
+-device virtio-scsi-pci,id=scsi1,bus=pci.0,addr=0x2 \
+-device virtio-scsi-pci,id=scsi2,bus=pci.0,addr=0x3 \
+-device virtio-scsi-pci,id=scsi3,bus=pci.0,addr=0x4 \
+-device virtio-scsi-pci,id=scsi4,bus=pci.0,addr=0x5 \
+-device virtio-scsi-pci,id=scsi5,bus=pci.0,addr=0x6 \
+-device virtio-scsi-pci,id=scsi6,bus=pci.0,addr=0x7 \
+-device virtio-scsi-pci,id=scsi7,bus=pci.0,addr=0x8 \
+-device virtio-scsi-pci,id=scsi8,bus=pci.0,addr=0x9 \
+-device virtio-scsi-pci,id=scsi9,bus=pci.0,addr=0xa \
+-device virtio-scsi-pci,id=scsi10,bus=pci.0,addr=0xb \
+-device virtio-scsi-pci,id=scsi11,bus=pci.0,addr=0xc \
+-device virtio-scsi-pci,id=scsi12,bus=pci.0,addr=0xd \
+-device virtio-scsi-pci,id=scsi13,bus=pci.0,addr=0xe \
+-device virtio-scsi-pci,id=scsi14,bus=pci.0,addr=0xf \
+-device virtio-scsi-pci,id=scsi15,bus=pci.0,addr=0x10 \
+-device virtio-scsi-pci,id=scsi16,bus=pci.0,addr=0x11 \
+-device virtio-scsi-pci,id=scsi17,bus=pci.0,addr=0x12 \
+-device virtio-scsi-pci,id=scsi18,bus=pci.0,addr=0x13 \
+-device virtio-scsi-pci,id=scsi19,bus=pci.0,addr=0x14 \
+-device virtio-scsi-pci,id=scsi20,bus=pci.0,addr=0x15 \
+-device virtio-scsi-pci,id=scsi21,bus=pci.0,addr=0x16 \
+-device virtio-scsi-pci,id=scsi22,bus=pci.0,addr=0x17 \
+-device virtio-scsi-pci,id=scsi23,bus=pci.0,addr=0x18 \
+-device virtio-scsi-pci,id=scsi24,bus=pci.0,addr=0x19 \
+-device virtio-scsi-pci,id=scsi25,bus=pci.0,addr=0x1a \
+-device virtio-scsi-pci,id=scsi26,bus=pci.0,addr=0x1b \
+-device virtio-scsi-pci,id=scsi27,bus=pci.0,addr=0x1c \
+-device virtio-scsi-pci,id=scsi28,bus=pci.0,addr=0x1d \
+-device virtio-scsi-pci,id=scsi29,bus=pci.0,addr=0x1e \
+-device virtio-scsi-pci,id=scsi30,bus=pci.0,addr=0x1f \
+-device virtio-scsi-pci,id=scsi31,bus=pci.1.0,addr=0x1
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index acbf15be91..2b9421cb7a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1765,12 +1765,10 @@ mymain(void)
     DO_TEST("pseries-many-devices",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-many-buses-1",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-many-buses-2",
             QEMU_CAPS_NODEFCONFIG,
@@ -1786,14 +1784,12 @@ mymain(void)
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_DEVICE_VFIO_PCI);
     DO_TEST("pseries-hostdevs-3",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_DEVICE_VFIO_PCI);
 
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-2.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-2.xml
index 62bead5032..17ff4c8537 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-2.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-2.xml
@@ -22,10 +22,9 @@
       <model name='spapr-pci-host-bridge'/>
       <target index='0'/>
     </controller>
-    <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='1'/>
     </controller>
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
@@ -39,7 +38,7 @@
       <source>
         <address domain='0x0005' bus='0x90' slot='0x01' function='0x0'/>
       </source>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
     </hostdev>
     <memballoon model='none'/>
     <panic model='pseries'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-3.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-3.xml
index 77c09094ff..58023ecd72 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-3.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-hostdevs-3.xml
@@ -19,15 +19,13 @@
       <model name='spapr-pci-host-bridge'/>
       <target index='0'/>
     </controller>
-    <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='1'/>
     </controller>
-    <controller type='pci' index='2' model='pci-bridge'>
-      <model name='pci-bridge'/>
-      <target chassisNr='2'/>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+    <controller type='pci' index='2' model='pci-root'>
+      <model name='spapr-pci-host-bridge'/>
+      <target index='2'/>
     </controller>
     <hostdev mode='subsystem' type='pci' managed='yes'>
       <driver name='vfio'/>
@@ -41,7 +39,7 @@
       <source>
         <address domain='0x0001' bus='0x01' slot='0x00' function='0x1'/>
       </source>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
     </hostdev>
     <memballoon model='none'/>
     <panic model='pseries'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-1.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-1.xml
index 9044936635..eb7bb80541 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-1.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-buses-1.xml
@@ -22,10 +22,9 @@
       <model name='spapr-pci-host-bridge'/>
       <target index='0'/>
     </controller>
-    <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='1'/>
     </controller>
     <memballoon model='none'/>
     <panic model='pseries'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-devices.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-devices.xml
index b596fe6891..ff7a08fec1 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-devices.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pseries-many-devices.xml
@@ -15,110 +15,109 @@
   <devices>
     <emulator>/usr/bin/qemu-system-ppc64</emulator>
     <controller type='scsi' index='0' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
     </controller>
     <controller type='scsi' index='1' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
     </controller>
     <controller type='scsi' index='2' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
     </controller>
     <controller type='scsi' index='3' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
     </controller>
     <controller type='scsi' index='4' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
     </controller>
     <controller type='scsi' index='5' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
     </controller>
     <controller type='scsi' index='6' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
     </controller>
     <controller type='scsi' index='7' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
     </controller>
     <controller type='scsi' index='8' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/>
     </controller>
     <controller type='scsi' index='9' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>
     </controller>
     <controller type='scsi' index='10' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0b' function='0x0'/>
     </controller>
     <controller type='scsi' index='11' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0c' function='0x0'/>
     </controller>
     <controller type='scsi' index='12' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0d' function='0x0'/>
     </controller>
     <controller type='scsi' index='13' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' function='0x0'/>
     </controller>
     <controller type='scsi' index='14' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' function='0x0'/>
     </controller>
     <controller type='scsi' index='15' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x10' function='0x0'/>
     </controller>
     <controller type='scsi' index='16' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x11' function='0x0'/>
     </controller>
     <controller type='scsi' index='17' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x13' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x12' function='0x0'/>
     </controller>
     <controller type='scsi' index='18' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x13' function='0x0'/>
     </controller>
     <controller type='scsi' index='19' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x15' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x14' function='0x0'/>
     </controller>
     <controller type='scsi' index='20' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x16' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x15' function='0x0'/>
     </controller>
     <controller type='scsi' index='21' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x17' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x16' function='0x0'/>
     </controller>
     <controller type='scsi' index='22' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x18' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x17' function='0x0'/>
     </controller>
     <controller type='scsi' index='23' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x18' function='0x0'/>
     </controller>
     <controller type='scsi' index='24' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1a' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x19' function='0x0'/>
     </controller>
     <controller type='scsi' index='25' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1a' function='0x0'/>
     </controller>
     <controller type='scsi' index='26' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
     </controller>
     <controller type='scsi' index='27' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1c' function='0x0'/>
     </controller>
     <controller type='scsi' index='28' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0'/>
     </controller>
     <controller type='scsi' index='29' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1e' function='0x0'/>
     </controller>
     <controller type='scsi' index='30' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x0'/>
     </controller>
     <controller type='scsi' index='31' model='virtio-scsi'>
-      <address type='pci' domain='0x0000' bus='0x01' slot='0x02' function='0x0'/>
+      <address type='pci' domain='0x0000' bus='0x01' slot='0x01' function='0x0'/>
     </controller>
     <controller type='usb' index='0' model='none'/>
     <controller type='pci' index='0' model='pci-root'>
       <model name='spapr-pci-host-bridge'/>
       <target index='0'/>
     </controller>
-    <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='1'/>
     </controller>
     <memballoon model='none'/>
     <panic model='pseries'/>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index 84098b7ef3..6762145470 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -676,12 +676,10 @@ mymain(void)
     DO_TEST("pseries-many-devices",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-many-buses-1",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("pseries-many-buses-2",
             QEMU_CAPS_NODEFCONFIG,
@@ -697,14 +695,12 @@ mymain(void)
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_DEVICE_VFIO_PCI);
     DO_TEST("pseries-hostdevs-3",
             QEMU_CAPS_NODEFCONFIG,
             QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
             QEMU_CAPS_HOST_PCI_MULTIDOMAIN,
-            QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_VIRTIO_SCSI,
             QEMU_CAPS_DEVICE_VFIO_PCI);
 
-- 
2.13.3