diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index ae0361840a..84cbfe1b4d 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1742,7 +1742,7 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED, } static bool -qemuDomainSupportsPCI(virDomainDefPtr def) +qemuDomainSupportsPCI(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) { if ((def->os.arch != VIR_ARCH_ARMV7L) && (def->os.arch != VIR_ARCH_AARCH64)) return true; @@ -1750,6 +1750,11 @@ qemuDomainSupportsPCI(virDomainDefPtr def) if (STREQ(def->os.machine, "versatilepb")) return true; + if ((STREQ(def->os.machine, "virt") || + STRPREFIX(def->os.machine, "virt-")) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_GPEX)) + return true; + return false; } @@ -2267,7 +2272,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, false))) goto cleanup; - if (qemuDomainSupportsPCI(def)) { + if (qemuDomainSupportsPCI(def, qemuCaps)) { if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0) goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ad9a8ac1aa..abf52c9c38 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1093,6 +1093,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, def, VIR_DOMAIN_CONTROLLER_TYPE_SATA, 0, -1) < 0) goto cleanup; + /* NB: any machine that sets addPCIRoot to true must also return + * true from the function qemuDomainSupportsPCI(). + */ if (addPCIRoot && virDomainDefMaybeAddController( def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 0, @@ -1102,6 +1105,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, /* When a machine has a pcie-root, make sure that there is always * a dmi-to-pci-bridge controller added as bus 1, and a pci-bridge * as bus 2, so that standard PCI devices can be connected + * + * NB: any machine that sets addPCIeRoot to true must also return + * true from the function qemuDomainSupportsPCI(). */ if (addPCIeRoot) { if (virDomainDefMaybeAddController(