For machinetypes with a pci-root bus (all legacy PCI), libvirt will
make a "fake" reservation for one extra slot prior to assigning
addresses to unaddressed PCI endpoint devices in the domain. This will
trigger auto-adding of a pci-bridge for the final device to be
assigned an address *if that device would have otherwise instead been
the last device on the last available pci-bridge*; thus it assures
that there will always be at least one slot left open in the domain's
bus topology for expansion (which is important both for hotplug (since
a new pci-bridge can't be added while the guest is running) as well as
for offline additions to the config (since adding a new device might
otherwise in some cases require re-addressing existing devices, which
we want to avoid)).

It's important to note that for the above case (legacy PCI), we must
check for the special case of all slots on all buses being occupied
*prior to assigning any addresses*, and avoid attempting to reserve
the extra address in that case, because there is no free address in
the existing topology, so no place to auto-add a pci-bridge for
expansion (i.e. it would always fail anyway). Since that condition can
only be reached by manual intervention, this is acceptable.

For machinetypes with pcie-root (Q35, aarch64 virt), libvirt's
methodology for automatically expanding the bus topology is different
- pcie-root-ports are plugged into slots (soon to be functions) of
pcie-root as needed, and the new endpoint devices are assigned to the
single slot in each pcie-root-port. This is done so that the devices
are, by default, hotpluggable (the slots of pcie-root don't support
hotplug, but the single slot of the pcie-root-port does). Since
pcie-root-ports can only be plugged into pcie-root, and we don't
auto-assign endpoint devices to the pcie-root slots, this means
topology expansion doesn't compete with endpoint devices for slots, so
we don't need to worry about checking for all "useful" slots being
free *prior* to assigning addresses to new endpoint devices - as a
matter of fact, if we attempt to reserve the open slots before the
used slots, it can lead to errors.

Instead this patch just reserves one slot for a "future potential"
PCIe device after doing the assignment for actual devices, but only
if the only PCI controller defined prior to starting address
assignment was pcie-root, and only if we auto-added at least one PCI
controller during address assignment.  This assures two things:

1) that reserving the open slots will only be done when the domain is
   initially defined, never at any time after, and

2) that if the user understands enough about PCI controllers that they
   are adding them manually, that we don't mess up their plan by
   adding extras - if they know enough to add one pcie-root-port, or
   to manually assign addresses such that no pcie-root-ports are
   needed, they know enough to add extra pcie-root-ports if they want
   them (this could be called the "libguestfs clause", since
   libguestfs needs to be able to create domains with as few
   devices/controllers as possible).

This is set to reserve a single free port for now, but could be
increased in the future if public sentiment goes in that direction
(it's easy to increase later, but essential impossible to decrease)
---
 src/qemu/qemu_domain_address.c                     | 30 ++++++++++++++++++++
 .../qemuxml2argv-bios-nvram-secure.args            |  1 +
 .../qemuxml2argv-machine-smm-opt.args              |  1 +
 .../qemuxml2argv-q35-default-devices-only.args     |  1 +
 .../qemuxml2argv-q35-pcie-autoadd.args             |  1 +
 .../qemuxml2argv-q35-pm-disable-fallback.args      |  1 +
 .../qemuxml2argv-q35-pm-disable.args               |  1 +
 .../qemuxml2argv-q35-virt-manager-basic.args       |  1 +
 tests/qemuxml2argvtest.c                           | 33 ++++++++++++++++++----
 .../qemuxml2xmlout-q35-default-devices-only.xml    |  5 ++++
 .../qemuxml2xmlout-q35-pcie-autoadd.xml            |  5 ++++
 .../qemuxml2xmlout-q35-virt-manager-basic.xml      |  5 ++++
 tests/qemuxml2xmltest.c                            | 19 +++++++++++--
 13 files changed, 96 insertions(+), 8 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index fbbcfb2..15d7c1a 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1929,6 +1929,36 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
         if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
             goto cleanup;
 
+        /* Only for *new* domains with pcie-root (and no other
+         * manually specified PCI controllers in the definition): If,
+         * after assigning addresses/reserving slots for all devices,
+         * we see that any extra buses have been auto-added, we
+         * understand that the application has left management of PCI
+         * addresses and controllers up to libvirt. In order to allow
+         * such applications to easily support hotplug, we will do a
+         * "one time" reservation of one extra PCIE|HOTPLUGGABLE
+         * slots, which should cause su to auto-add 1 extra
+         * pcie-root-ports The single slot in this root-port will be
+         * available for hotplug, or may also be used when a device is
+         * added to the config offline.
+         */
+
+        if (max_idx <= 0 &&
+            addrs->nbuses > max_idx + 1 &&
+            qemuDomainMachineHasPCIeRoot(def)) {
+            info.pciConnectFlags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
+                                    VIR_PCI_CONNECT_TYPE_PCIE_DEVICE);
+
+            /* if there isn't an empty pcie-root-port, this will
+             * cause one to be added
+             */
+            if (qemuDomainPCIAddressReserveNextSlot(addrs, &info) < 0)
+               goto cleanup;
+        }
+
+        /* now reflect any controllers auto-added to addrs into the
+         * domain controllers list
+         */
         for (i = 1; i < addrs->nbuses; i++) {
             virDomainDeviceDef dev;
             int contIndex;
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.args 
b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.args
index c014254..c5fe72b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.args
@@ -21,6 +21,7 @@ readonly=on \
 -boot c \
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
 -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \
 -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args 
b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args
index e49d7e9..cc9c355 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args
@@ -18,6 +18,7 @@ QEMU_AUDIO_DRV=none \
 -boot c \
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
 -device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1 \
 -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \
 -device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args 
b/tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args
index 9ac30dd..9d13466 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-default-devices-only.args
@@ -18,5 +18,6 @@ QEMU_AUDIO_DRV=none \
 -boot c \
 -device ioh3420,port=0x8,chassis=1,id=pci.1,bus=pcie.0,addr=0x1 \
 -device ioh3420,port=0x10,chassis=2,id=pci.2,bus=pcie.0,addr=0x2 \
+-device ioh3420,port=0x18,chassis=3,id=pci.3,bus=pcie.0,addr=0x3 \
 -device nec-usb-xhci,id=usb,bus=pci.1,addr=0x0 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x0
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args 
b/tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args
index daecf96..ba26326 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-pcie-autoadd.args
@@ -29,6 +29,7 @@ QEMU_AUDIO_DRV=none \
 -device ioh3420,port=0x60,chassis=11,id=pci.11,bus=pcie.0,addr=0xc \
 -device ioh3420,port=0x68,chassis=12,id=pci.12,bus=pcie.0,addr=0xd \
 -device ioh3420,port=0x70,chassis=13,id=pci.13,bus=pcie.0,addr=0xe \
+-device ioh3420,port=0x78,chassis=14,id=pci.14,bus=pcie.0,addr=0xf \
 -device nec-usb-xhci,id=usb,bus=pci.6,addr=0x0 \
 -device virtio-scsi-pci,id=scsi0,bus=pci.5,addr=0x0 \
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.4,addr=0x0 \
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable-fallback.args 
b/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable-fallback.args
index deae687..739c918 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable-fallback.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable-fallback.args
@@ -20,4 +20,5 @@ QEMU_AUDIO_DRV=none \
 -boot n \
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable.args 
b/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable.args
index 871340f..5ee16b7 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-pm-disable.args
@@ -20,4 +20,5 @@ QEMU_AUDIO_DRV=none \
 -boot n \
 -device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \
 -device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \
+-device ioh3420,port=0x10,chassis=3,id=pci.3,bus=pcie.0,addr=0x2 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x1
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args 
b/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
index d3217d5..60af251 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-virt-manager-basic.args
@@ -23,6 +23,7 @@ QEMU_AUDIO_DRV=spice \
 -device ioh3420,port=0x20,chassis=3,id=pci.3,bus=pcie.0,addr=0x4 \
 -device ioh3420,port=0x28,chassis=4,id=pci.4,bus=pcie.0,addr=0x5 \
 -device ioh3420,port=0x30,chassis=5,id=pci.5,bus=pcie.0,addr=0x6 \
+-device ioh3420,port=0x38,chassis=6,id=pci.6,bus=pcie.0,addr=0x7 \
 -device nec-usb-xhci,id=usb,bus=pci.2,addr=0x0 \
 -device virtio-serial-pci,id=virtio-serial0,bus=pci.3,addr=0x0 \
 -drive file=/var/lib/libvirt/images/basic.qcow2,format=qcow2,if=none,\
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index b29ca23..2b6ce10 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -656,6 +656,7 @@ mymain(void)
     DO_TEST("machine-smm-opt",
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_MACHINE_SMM_OPT,
@@ -673,10 +674,12 @@ mymain(void)
     DO_TEST("boot-floppy-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI);
     DO_TEST("bootindex-floppy-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_BOOT_MENU,
             QEMU_CAPS_BOOTINDEX);
     DO_TEST("boot-multi", QEMU_CAPS_BOOT_MENU);
@@ -723,6 +726,7 @@ mymain(void)
     DO_TEST("bios-nvram-secure",
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_MACHINE_SMM_OPT,
@@ -1336,18 +1340,22 @@ mymain(void)
             QEMU_CAPS_CHARDEV, QEMU_CAPS_NODEFCONFIG);
     DO_TEST("usb-controller-default-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
             QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI);
     DO_TEST_FAILURE("usb-controller-default-unavailable-q35",
                     QEMU_CAPS_DEVICE_PCI_BRIDGE,
+                    QEMU_CAPS_DEVICE_IOH3420,
                     QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
                     QEMU_CAPS_NEC_USB_XHCI);
     DO_TEST("usb-controller-explicit-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
             QEMU_CAPS_PIIX3_USB_UHCI, QEMU_CAPS_NEC_USB_XHCI);
     DO_TEST_FAILURE("usb-controller-explicit-unavailable-q35",
                     QEMU_CAPS_DEVICE_PCI_BRIDGE,
+                    QEMU_CAPS_DEVICE_IOH3420,
                     QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_PCI_OHCI,
                     QEMU_CAPS_PIIX3_USB_UHCI);
     DO_TEST("usb-controller-xhci",
@@ -1723,10 +1731,12 @@ mymain(void)
     DO_TEST("pcie-root",
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420);
     DO_TEST("q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
@@ -1741,16 +1751,19 @@ mymain(void)
                         QEMU_CAPS_DEVICE_IOH3420);
     DO_TEST("q35-pm-disable",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4,
             QEMU_CAPS_ICH9_DISABLE_S3, QEMU_CAPS_ICH9_DISABLE_S4);
     DO_TEST("q35-pm-disable-fallback",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PIIX_DISABLE_S3, QEMU_CAPS_PIIX_DISABLE_S4);
     DO_TEST("q35-usb2",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
@@ -1758,6 +1771,7 @@ mymain(void)
     DO_TEST("q35-usb2-multi",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
@@ -1765,6 +1779,7 @@ mymain(void)
     DO_TEST("q35-usb2-reorder",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
@@ -1927,6 +1942,7 @@ mymain(void)
     DO_TEST_PARSE_ERROR("q35-wrong-root",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
@@ -2040,6 +2056,7 @@ mymain(void)
     DO_TEST("pcihole64-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL,
@@ -2072,13 +2089,15 @@ mymain(void)
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420);
     DO_TEST("aarch64-virt-2.6-virtio-pci-default",
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420);
     /* Example of using virtio-pci with no explicit PCI controller
        but with manual PCI addresses */
     DO_TEST("aarch64-virtio-pci-manual-addresses",
@@ -2086,7 +2105,9 @@ mymain(void)
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
+            QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("aarch64-video-virtio-gpu-pci",
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_GPEX,
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
@@ -2345,7 +2366,9 @@ mymain(void)
 
     DO_TEST("acpi-table", NONE);
     DO_TEST("intel-iommu", QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_DEVICE_INTEL_IOMMU);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
+            QEMU_CAPS_DEVICE_INTEL_IOMMU);
     DO_TEST("intel-iommu-machine", QEMU_CAPS_DEVICE_PCI_BRIDGE, 
QEMU_CAPS_MACHINE_OPT,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_MACHINE_IOMMU);
 
diff --git 
a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml
index 8d7bc9d..e64b80c 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-default-devices-only.xml
@@ -31,6 +31,11 @@
       <target chassis='2' port='0x10'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x02' 
function='0x0'/>
     </controller>
+    <controller type='pci' index='3' model='pcie-root-port'>
+      <model name='ioh3420'/>
+      <target chassis='3' port='0x18'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' 
function='0x0'/>
+    </controller>
     <input type='mouse' bus='ps2'/>
     <input type='keyboard' bus='ps2'/>
     <memballoon model='virtio'>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml
index d784801..3742e14 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-pcie-autoadd.xml
@@ -97,6 +97,11 @@
       <target chassis='13' port='0x70'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x0e' 
function='0x0'/>
     </controller>
+    <controller type='pci' index='14' model='pcie-root-port'>
+      <model name='ioh3420'/>
+      <target chassis='14' port='0x78'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x0f' 
function='0x0'/>
+    </controller>
     <filesystem type='mount' accessmode='passthrough'>
       <source dir='/export/to/guest'/>
       <target dir='/import/from/host'/>
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml 
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
index fe9ea4e..236d955 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-q35-virt-manager-basic.xml
@@ -68,6 +68,11 @@
       <target chassis='5' port='0x30'/>
       <address type='pci' domain='0x0000' bus='0x00' slot='0x06' 
function='0x0'/>
     </controller>
+    <controller type='pci' index='6' model='pcie-root-port'>
+      <model name='ioh3420'/>
+      <target chassis='6' port='0x38'/>
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' 
function='0x0'/>
+    </controller>
     <interface type='user'>
       <mac address='52:54:00:9a:e6:c6'/>
       <model type='virtio'/>
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index eb95061..e22b63f 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -593,10 +593,12 @@ mymain(void)
             QEMU_CAPS_PIIX3_USB_UHCI);
     DO_TEST("usb-controller-default-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI,
             QEMU_CAPS_NEC_USB_XHCI);
     DO_TEST("usb-controller-explicit-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_PCI_OHCI, QEMU_CAPS_PIIX3_USB_UHCI,
             QEMU_CAPS_NEC_USB_XHCI);
     DO_TEST("ppc64-usb-controller",
@@ -676,23 +678,27 @@ mymain(void)
 
     DO_TEST("q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION,
             QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL);
     DO_TEST("q35-usb2",
             QEMU_CAPS_DEVICE_PCI_BRIDGE,
             QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI,
             QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
             QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL);
     DO_TEST("q35-usb2-multi",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION,
             QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL);
     DO_TEST("q35-usb2-reorder",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION,
             QEMU_CAPS_ICH9_USB_EHCI1, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL);
@@ -906,6 +912,7 @@ mymain(void)
     DO_TEST("pcihole64-none", NONE);
     DO_TEST("pcihole64-q35",
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
             QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
             QEMU_CAPS_DEVICE_QXL,
             QEMU_CAPS_Q35_PCI_HOLE64_SIZE);
@@ -950,13 +957,17 @@ mymain(void)
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
+            QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("aarch64-virtio-pci-manual-addresses",
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DTB,
             QEMU_CAPS_DEVICE_VIRTIO_MMIO,
             QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM,
             QEMU_CAPS_OBJECT_GPEX, QEMU_CAPS_DEVICE_PCI_BRIDGE,
-            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_VIRTIO_SCSI);
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420,
+            QEMU_CAPS_VIRTIO_SCSI);
     DO_TEST("aarch64-video-virtio-gpu-pci",
             QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_OBJECT_GPEX,
             QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_IOH3420,
@@ -1004,7 +1015,9 @@ mymain(void)
     DO_TEST("video-virtio-gpu-secondary", NONE);
 
     DO_TEST("intel-iommu",
-            QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE);
+            QEMU_CAPS_DEVICE_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
+            QEMU_CAPS_DEVICE_IOH3420);
 
     qemuTestDriverFree(&driver);
 
-- 
2.7.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to