[libvirt] [PATCH v2 0/4] qemu: Add support for generic PCIe Root Ports

Blurby McBlurbface. Andrea Bolognani (4): qemu: Add support for generic PCIe Root Ports qemu: Use generic PCIe Root Ports by default when available tests: Test generic PCIe Root Ports news: Document support for generic PCIe Root Ports docs/news.xml | 10 ++++++ docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 4 ++- src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 18 ++++++++-- src/qemu/qemu_domain_address.c | 13 +++++-- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + .../qemuxml2argv-pcie-root-port-model-generic.args | 22 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-generic.xml | 22 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-ioh3420.args | 21 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-ioh3420.xml | 19 ++++++++++ tests/qemuxml2argvtest.c | 14 ++++++++ ...qemuxml2xmlout-pcie-root-port-model-generic.xml | 40 ++++++++++++++++++++++ ...qemuxml2xmlout-pcie-root-port-model-ioh3420.xml | 35 +++++++++++++++++++ tests/qemuxml2xmltest.c | 14 ++++++++ 17 files changed, 231 insertions(+), 7 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-generic.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-ioh3420.xml -- 2.7.4

QEMU 2.9 introduces the pcie-root-port device, which is a generic version of the existing ioh3420 device. Make the new device available to libvirt users. --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 18 +++++++++++++++--- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 7 files changed, 24 insertions(+), 4 deletions(-) diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index 8be5e08..24d1edb 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1904,6 +1904,7 @@ <value>i82801b11-bridge</value> <!-- implementations of 'pcie-root-port' --> <value>ioh3420</value> + <value>pcie-root-port</value> <!-- implementations of 'pcie-switch-upstream-port' --> <value>x3130-upstream</value> <!-- implementations of 'pcie-switch-downstream-port' --> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 11fde50..eaf46b2 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -338,7 +338,9 @@ VIR_ENUM_IMPL(virDomainControllerPCIModelName, "x3130-upstream", "xio3130-downstream", "pxb", - "pxb-pcie") + "pxb-pcie", + "pcie-root-port", +); VIR_ENUM_IMPL(virDomainControllerModelSCSI, VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST, "auto", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 826afb4..8e6d874 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -694,6 +694,7 @@ typedef enum { VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM, VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB, VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE, + VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT, VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST } virDomainControllerPCIModelName; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 5200b39..b85ca71 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -360,6 +360,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, "virtio-net.host_mtu", "spice-rendernode", "nvdimm", + "pcie-root-port", ); @@ -1621,6 +1622,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { { "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL }, { "vhost-scsi", QEMU_CAPS_DEVICE_VHOST_SCSI }, { "nvdimm", QEMU_CAPS_DEVICE_NVDIMM }, + { "pcie-root-port", QEMU_CAPS_DEVICE_PCIE_ROOT_PORT }, }; static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 1b4bcfb..ca8a517 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -395,6 +395,7 @@ typedef enum { QEMU_CAPS_VIRTIO_NET_HOST_MTU, /* virtio-net-*.host_mtu */ QEMU_CAPS_SPICE_RENDERNODE, /* -spice rendernode */ QEMU_CAPS_DEVICE_NVDIMM, /* -device nvdimm */ + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, /* -device pcie-root-port */ QEMU_CAPS_LAST /* this must always be the last item */ } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 61d9eb9..878d088 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2874,20 +2874,32 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, def->opts.pciopts.modelName); goto error; } - if (def->opts.pciopts.modelName - != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) { + if ((def->opts.pciopts.modelName != + VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && + (def->opts.pciopts.modelName != + VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("PCI controller model name '%s' " "is not valid for a pcie-root-port"), modelName); goto error; } - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { + if ((def->opts.pciopts.modelName == + VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_IOH3420)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("the pcie-root-port (ioh3420) " "controller is not supported in this QEMU binary")); goto error; } + if ((def->opts.pciopts.modelName == + VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT) && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pcie-root-port (pcie-root-port) " + "controller is not supported in this QEMU binary")); + goto error; + } virBufferAsprintf(&buf, "%s,port=0x%x,chassis=%d,id=%s", modelName, def->opts.pciopts.port, diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml index 334f8e7..a397615 100644 --- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml @@ -202,6 +202,7 @@ <flag name='drive-iotune-group'/> <flag name='query-cpu-model-expansion'/> <flag name='virtio-net.host_mtu'/> + <flag name='pcie-root-port'/> <version>2008050</version> <kvmVersion>0</kvmVersion> <package> (v2.8.0-1961-g5b10b94bd5)</package> -- 2.7.4

On 03/16/2017 01:14 PM, Andrea Bolognani wrote:
QEMU 2.9 introduces the pcie-root-port device, which is a generic version of the existing ioh3420 device.
Make the new device available to libvirt users. --- docs/schemas/domaincommon.rng | 1 + src/conf/domain_conf.c | 4 +++- src/conf/domain_conf.h | 1 + src/qemu/qemu_capabilities.c | 2 ++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_command.c | 18 +++++++++++++++--- tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + 7 files changed, 24 insertions(+), 4 deletions(-)
ACK.

ioh3420 is emulated Intel hardware, so it always looked quite out of place in aarch64/virt guests. Even for x86/q35 guests, the recently-introduced pcie-root-port is a better choice because, unlike ioh3420, it doesn't require IO space (a farily constrained resource) to work. If pcie-root-port is available in QEMU, use it; ioh3420 is still used as fallback for when pcie-root-port is not available. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1408808 --- Changes from v1: * Always use pcie-root-port if available, regardless of machine type. src/qemu/qemu_domain_address.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 64aa4ef..6d3a627 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1846,13 +1846,15 @@ qemuDomainSupportsPCI(virDomainDefPtr def, static void -qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) +qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps) { int *modelName = &cont->opts.pciopts.modelName; /* make sure it's not already set */ if (*modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) return; + switch ((virDomainControllerModelPCI)cont->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE; @@ -1861,7 +1863,12 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; + /* Use generic PCIe Root Ports if available, falling back to + * ioh3420 otherwise */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT; + else + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM; @@ -2143,7 +2150,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, * device in qemu) for any controller that doesn't yet * have it set. */ - qemuDomainPCIControllerSetDefaultModelName(cont); + qemuDomainPCIControllerSetDefaultModelName(cont, qemuCaps); /* set defaults for any other auto-generated config * options for this controller that haven't been -- 2.7.4

On 03/16/2017 01:14 PM, Andrea Bolognani wrote:
ioh3420 is emulated Intel hardware, so it always looked quite out of place in aarch64/virt guests. Even for x86/q35 guests, the recently-introduced pcie-root-port is a better choice because, unlike ioh3420, it doesn't require IO space (a farily constrained resource) to work.
s/farily/fairly/ (my understanding is that there is still an issue with the "disable IO space bit - apparently both Linux and Windows will still reserve and even *use* IO space even if the controller says that it doesn't support it! But at least *in theory* it won't use it :-P)
If pcie-root-port is available in QEMU, use it; ioh3420 is still used as fallback for when pcie-root-port is not available.
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1408808 --- Changes from v1:
* Always use pcie-root-port if available, regardless of machine type.
src/qemu/qemu_domain_address.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
ACK, although..... (see below)
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 64aa4ef..6d3a627 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1846,13 +1846,15 @@ qemuDomainSupportsPCI(virDomainDefPtr def,
static void -qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) +qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont, + virQEMUCapsPtr qemuCaps) { int *modelName = &cont->opts.pciopts.modelName;
/* make sure it's not already set */ if (*modelName != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) return; + switch ((virDomainControllerModelPCI)cont->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCI_BRIDGE; @@ -1861,7 +1863,12 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; + /* Use generic PCIe Root Ports if available, falling back to + * ioh3420 otherwise */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT; + else + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420;
I wonder if we should check caps for IOH3420 here just to be consistent (and log an error if neither is available). I realize that's not the way it worked before (existing code only checks the caps for a particular device at the time we generate the commandline), but I'll be the first to admit my original code was, err, "less than ideal". It's up to you though, add it or not.
break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM; @@ -2143,7 +2150,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, * device in qemu) for any controller that doesn't yet * have it set. */ - qemuDomainPCIControllerSetDefaultModelName(cont); + qemuDomainPCIControllerSetDefaultModelName(cont, qemuCaps);
/* set defaults for any other auto-generated config * options for this controller that haven't been

On Thu, 2017-03-16 at 18:30 -0400, Laine Stump wrote:
@@ -1861,7 +1863,12 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; + /* Use generic PCIe Root Ports if available, falling back to + * ioh3420 otherwise */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT; + else + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; I wonder if we should check caps for IOH3420 here just to be consistent (and log an error if neither is available). I realize that's not the way it worked before (existing code only checks the caps for a particular device at the time we generate the commandline), but I'll be the first to admit my original code was, err, "less than ideal". It's up to you though, add it or not.
We already check when building the QEMU command line, which is the appropriate place IMHO. I'd rather not duplicate the check here as well. I've pushed the patches now, thanks for reviewing! -- Andrea Bolognani / Red Hat / Virtualization

On 03/17/2017 05:06 AM, Andrea Bolognani wrote:
On Thu, 2017-03-16 at 18:30 -0400, Laine Stump wrote:
@@ -1861,7 +1863,12 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_I82801B11_BRIDGE; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420; + /* Use generic PCIe Root Ports if available, falling back to + * ioh3420 otherwise */ + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PCIE_ROOT_PORT)) + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PCIE_ROOT_PORT; + else + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_IOH3420;
I wonder if we should check caps for IOH3420 here just to be consistent (and log an error if neither is available). I realize that's not the way it worked before (existing code only checks the caps for a particular device at the time we generate the commandline), but I'll be the first to admit my original code was, err, "less than ideal".
It's up to you though, add it or not.
We already check when building the QEMU command line, which is the appropriate place IMHO. I'd rather not duplicate the check here as well.
It all depends on whether you want to get an error when you define the domain, or not until you try to start it. I prefer the latter, but in this case it's all just academic, since we know that all qemu binaries we recognize as having a PCIe root bus also support the ioh3420.

We want pcie-root-ports to be used when available in QEMU, but at the same time we need to ensure that hosts running older QEMU releases keep working and that the user can override the default at any time. Add a comment for the original pcie-root-port test cases to make it clear how these new test cases are different. --- Changes from v1: * Don't change existing test cases; * Only test the new feature once. .../qemuxml2argv-pcie-root-port-model-generic.args | 22 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-generic.xml | 22 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-ioh3420.args | 21 ++++++++++++ .../qemuxml2argv-pcie-root-port-model-ioh3420.xml | 19 ++++++++++ tests/qemuxml2argvtest.c | 14 ++++++++ ...qemuxml2xmlout-pcie-root-port-model-generic.xml | 40 ++++++++++++++++++++++ ...qemuxml2xmlout-pcie-root-port-model-ioh3420.xml | 35 +++++++++++++++++++ tests/qemuxml2xmltest.c | 14 ++++++++ 8 files changed, 187 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-generic.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-ioh3420.xml diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.args b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.args new file mode 100644 index 0000000..96239bd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.args @@ -0,0 +1,22 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest \ +-S \ +-M q35 \ +-m 2048 \ +-smp 2,sockets=2,cores=1,threads=1 \ +-uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device pcie-root-port,port=0x10,chassis=1,id=pci.1,bus=pcie.0,\ +multifunction=on,addr=0x2 \ +-device pcie-root-port,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 \ +-device ioh3420,port=0x12,chassis=3,id=pci.3,bus=pcie.0,addr=0x2.0x2 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.xml new file mode 100644 index 0000000..7acfb95 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-generic.xml @@ -0,0 +1,22 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'/> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + </controller> + <controller type='pci' index='3' model='pcie-root-port'> + <model name='ioh3420'/> + </controller> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.args b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.args new file mode 100644 index 0000000..73f533b --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.args @@ -0,0 +1,21 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/bin/qemu-system-x86_64 \ +-name guest \ +-S \ +-M q35 \ +-m 2048 \ +-smp 2,sockets=2,cores=1,threads=1 \ +-uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-guest/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device ioh3420,port=0x10,chassis=1,id=pci.1,bus=pcie.0,multifunction=on,\ +addr=0x2 \ +-device ioh3420,port=0x11,chassis=2,id=pci.2,bus=pcie.0,addr=0x2.0x1 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.xml new file mode 100644 index 0000000..4cba3f9 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-root-port-model-ioh3420.xml @@ -0,0 +1,19 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + </os> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'/> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='ioh3420'/> + </controller> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 5716509..4a66136 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2011,12 +2011,26 @@ mymain(void) QEMU_CAPS_DEVICE_QXL, QEMU_CAPS_HDA_DUPLEX, QEMU_CAPS_USB_REDIR); + + /* Test automatic and manual setting of pcie-root-port attributes */ DO_TEST("pcie-root-port", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_QXL); + + /* Make sure the default model for PCIe Root Ports is picked correctly + * based on QEMU binary capabilities. We use x86/q35 for the test, but + * any PCIe machine type (such as aarch64/virt) will behave the same */ + DO_TEST("pcie-root-port-model-generic", + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_MULTIFUNCTION); + DO_TEST("pcie-root-port-model-ioh3420", + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_MULTIFUNCTION); + DO_TEST("autoindex", QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-generic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-generic.xml new file mode 100644 index 0000000..0de0d3e --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-generic.xml @@ -0,0 +1,40 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='1' port='0x10'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='pcie-root-port'/> + <target chassis='2' port='0x11'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/> + </controller> + <controller type='pci' index='3' model='pcie-root-port'> + <model name='ioh3420'/> + <target chassis='3' port='0x12'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/> + </controller> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> + </controller> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-ioh3420.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-ioh3420.xml new file mode 100644 index 0000000..3bbecf7 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-root-port-model-ioh3420.xml @@ -0,0 +1,35 @@ +<domain type='qemu'> + <name>guest</name> + <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid> + <memory unit='KiB'>2097152</memory> + <currentMemory unit='KiB'>2097152</currentMemory> + <vcpu placement='static'>2</vcpu> + <os> + <type arch='x86_64' machine='q35'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/qemu-system-x86_64</emulator> + <controller type='pci' index='0' model='pcie-root'/> + <controller type='pci' index='1' model='pcie-root-port'> + <model name='ioh3420'/> + <target chassis='1' port='0x10'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/> + </controller> + <controller type='pci' index='2' model='pcie-root-port'> + <model name='ioh3420'/> + <target chassis='2' port='0x11'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/> + </controller> + <controller type='sata' index='0'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/> + </controller> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <memballoon model='none'/> + </devices> +</domain> diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index bf62dbb..7199175 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -884,12 +884,26 @@ mymain(void) QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_QXL); + + /* Test automatic and manual setting of pcie-root-port attributes */ DO_TEST("pcie-root-port", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_DEVICE_VIDEO_PRIMARY, QEMU_CAPS_DEVICE_QXL); + + /* Make sure the default model for PCIe Root Ports is picked correctly + * based on QEMU binary capabilities. We use x86/q35 for the test, but + * any PCIe machine type (such as aarch64/virt) will behave the same */ + DO_TEST("pcie-root-port-model-generic", + QEMU_CAPS_DEVICE_PCIE_ROOT_PORT, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_MULTIFUNCTION); + DO_TEST("pcie-root-port-model-ioh3420", + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_PCI_MULTIFUNCTION); + DO_TEST("pcie-switch-upstream-port", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_DEVICE_X3130_UPSTREAM, -- 2.7.4

On 03/16/2017 01:14 PM, Andrea Bolognani wrote:
We want pcie-root-ports to be used when available in QEMU, but at the same time we need to ensure that hosts running older QEMU releases keep working and that the user can override the default at any time.
Add a comment for the original pcie-root-port test cases to make it clear how these new test cases are different. --- Changes from v1:
* Don't change existing test cases; * Only test the new feature once.
ACK. (every time I see a new test added to qemuxml2argvtest and qemuxml2xmltest it makes me want them to share a common list of DO_TEST() invocations so that all that hard work you did to bring them in sync doesn't get trampled.) (Nudge nudge, wink wink. Know what I mean, mate?)

--- Changes from v1: * Include model names; * Reword slightly. docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/news.xml b/docs/news.xml index 097a09a..3501f89 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -29,6 +29,16 @@ for QEMUs older than 2.9.0. </description> </change> + <change> + <summary> + qemu: Introduce support for generic PCIe Root Ports + </summary> + <description> + For new controllers, a generic device (pcie-root-port) will be used + by default instead of the Intel-specific device (ioh3420), provided + the QEMU binary supports it. + </description> + </change> </section> <section title="Improvements"> <change> -- 2.7.4

On 03/16/2017 01:14 PM, Andrea Bolognani wrote:
--- Changes from v1:
* Include model names; * Reword slightly.
docs/news.xml | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/docs/news.xml b/docs/news.xml index 097a09a..3501f89 100644 --- a/docs/news.xml +++ b/docs/news.xml @@ -29,6 +29,16 @@ for QEMUs older than 2.9.0. </description> </change> + <change> + <summary> + qemu: Introduce support for generic PCIe Root Ports + </summary> + <description> + For new controllers, a generic device (pcie-root-port) will be used + by default instead of the Intel-specific device (ioh3420), provided + the QEMU binary supports it. + </description> + </change> </section> <section title="Improvements"> <change>
ACK.
participants (2)
-
Andrea Bolognani
-
Laine Stump