Signed-off-by: liguang <lig.fnst@xxxxxxxxxxxxxx> --- src/conf/device_conf.c | 8 +++++++- src/conf/device_conf.h | 1 + src/qemu/qemu_capabilities.c | 11 +++++++++++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 4 +++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 7b97f45..3fca853 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -51,7 +51,7 @@ int virDevicePCIAddressParseXML(xmlNodePtr node, virDevicePCIAddressPtr addr) { - char *domain, *slot, *bus, *function, *multi; + char *domain, *slot, *bus, *function, *multi, *expr; int ret = -1; memset(addr, 0, sizeof(*addr)); @@ -61,6 +61,7 @@ virDevicePCIAddressParseXML(xmlNodePtr node, slot = virXMLPropString(node, "slot"); function = virXMLPropString(node, "function"); multi = virXMLPropString(node, "multifunction"); + expr = virXMLPropString(node, "express"); if (domain && virStrToLong_ui(domain, NULL, 0, &addr->domain) < 0) { @@ -98,6 +99,10 @@ virDevicePCIAddressParseXML(xmlNodePtr node, goto cleanup; } + + if (expr) + addr->express = true; + if (!virDevicePCIAddressIsValid(addr)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Insufficient specification for PCI address")); @@ -112,6 +117,7 @@ cleanup: VIR_FREE(slot); VIR_FREE(function); VIR_FREE(multi); + VIR_FREE(expr); return ret; } diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h index 5318738..5c87f48 100644 --- a/src/conf/device_conf.h +++ b/src/conf/device_conf.h @@ -48,6 +48,7 @@ struct _virDevicePCIAddress { unsigned int slot; unsigned int function; int multi; /* enum virDomainDeviceAddressPciMulti */ + bool express; /* if it is a pci-e device */ }; int virDevicePCIAddressIsValid(virDevicePCIAddressPtr addr); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 104a3f8..c7fbb35 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -298,6 +298,17 @@ qemuCapsProbeCommand(const char *qemu, return cmd; } +int qemuMachineTypeIdx(const char *machine, qemuCapsPtr caps) +{ + size_t i; + + for (i = 0; i < caps->nmachineTypes; i++) { + if (STRPREFIX(caps->machineTypes[i], machine)) + return i; + } + + return -1; +} static void qemuSetDefaultMachine(qemuCapsPtr caps, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index bf4eef8..715d625 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -238,6 +238,7 @@ int qemuCapsParseHelpStr(const char *qemu, bool check_yajl); /* Only for use by test suite */ int qemuCapsParseDeviceStr(qemuCapsPtr caps, const char *str); +int qemuMachineTypeIdx(const char *machine, qemuCapsPtr caps); VIR_ENUM_DECL(qemuCaps); diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 04a9512..f40e1a5 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -1801,7 +1801,9 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, * When QEMU grows support for > 1 PCI domain, then pci.0 change * to pciNN.0 where NN is the domain number */ - if (qemuCapsGet(caps, QEMU_CAPS_PCI_MULTIBUS)) + if (qemuMachineTypeIdx("q35", caps) >= 0 && info->addr.pci.express) + virBufferAsprintf(buf, ",bus=pcie.0"); + else if (qemuCapsGet(caps, QEMU_CAPS_PCI_MULTIBUS)) virBufferAsprintf(buf, ",bus=pci.0"); else virBufferAsprintf(buf, ",bus=pci"); -- 1.7.2.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list