From bc07251f59ecf828c3f9a82c9ef485937fd6c9bb Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Wed, 16 Mar 2016 13:37:14 -0400 Subject: [PATCH] conf: new pci controller model pcie-expander-bus This controller provides a single PCIe port on a new root. It is similar to pci-expander-bus, intended to provide a bus that can be associated with a guest-identifiable NUMA node, but is for machinetypes with PCIe rather than PCI (e.g. q35-based machinetypes). Aside from PCIe vs. PCI, the other main difference is that a pci-expander-bus has a companion pci-bridge that is automatically attached along with it, but pcie-expander-bus has only a single port, and that port will only connect to a pcie-root-port, or to a pcie-switch-upstream-port. In order for the bus to be of any use in the guest, it must have either a pcie-root-port or a pcie-switch-upstream-port attached (and one or more pcie-switch-downstream-ports attached to the pcie-switch-upstream-port). --- docs/formatdomain.html.in | 40 +- docs/schemas/domaincommon.rng | 3 + src/conf/domain_addr.c | 17 +- src/conf/domain_conf.c | 6 +- src/conf/domain_conf.h | 2 + src/qemu/qemu_domain_address.c | 2 + .../qemuxml2argv-pcie-expander-bus.xml | 247 +++++++++++ .../qemuxml2xmlout-pcie-expander-bus.xml | 384 ++++++++++++++++++ tests/qemuxml2xmltest.c | 7 + 9 files changed, 694 insertions(+), 14 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.xml create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-expander-bus.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 43102c8d11..9bcef6a290 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -3103,15 +3103,18 @@ possible values pci-root, pcie-root, pcie-root-port, pci-bridge, dmi-to-pci-bridge, pcie-switch-upstream-port, - pcie-switch-downstream-port, or pci-expander-bus. - (pci-root and pci-bridge since 1.0.5, - pcie-root and dmi-to-pci-bridge since - 1.1.2, pcie-root-port, pcie-switch-upstream-port, - pcie-switch-downstream-port since 1.2.19, - and pci-expander-bus since 1.3.4) - The root controllers (pci-root and pcie-root) - have an optional pcihole64 element specifying how big - (in kilobytes, or in the unit specified by pcihole64's + pcie-switch-downstream-port, pci-expander-bus, + or pcie-expander-bus. (pci-root and + pci-bridge since 1.0.5, pcie-root and + dmi-to-pci-bridge since 1.1.2, + pcie-root-port, pcie-switch-upstream-port, + pcie-switch-downstream-port since + 1.2.19, and pci-expander-bus and + pcie-expander-bus since 1.3.4) The + root controllers (pci-root + and pcie-root) have an + optional pcihole64 element specifying how big (in + kilobytes, or in the unit specified by pcihole64's unit attribute) the 64-bit PCI hole should be. Some guests (like Windows XP or Windows Server 2003) might crash when QEMU and Seabios are recent enough to support 64-bit PCI holes, unless this is disabled @@ -3173,7 +3176,7 @@
busNr
- pci-expander-bus controllers can have an + pci-expander-bus and pcie-expander-bus controllers can have an optional busNr attribute (1-254). This will be the bus number of the new bus; All bus numbers between that specified and 255 will be available only for assignment to @@ -3188,6 +3191,23 @@ for the pci-bridge that is automatically attached to it (if you plan on adding more pci-bridges to the hierarchy of the bus, you should manually set busNr to a lower value). +

+ A similar algorithm is used for automatically determining + the busNr attribute for pcie-expander-bus, but since the + pcie-expander-bus doesn't have any built-in pci-bridge, the + 2nd bus-number is just being reserved for the pcie-root-port + that must necessarily be connected to the bus in order to + actually plug in an endpoint device. If you intend to plug + multiple devices into a pcie-expander-bus, you must instead + connect a pcie-switch-upstream-port to the + pcie-expander-bus, and multiple pcie-switch-downstream-ports + to the pcie-switch-downstream-port, and of course for this + to work properly, you will need to decrease the + pcie-expander-bus' busNr accordingly so that there are + enough unused bus numbers above it to accomodate giving out + one bus number for the upstream-port and one for each + downstream-port). +

<node>
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index c181713355..3605afeb72 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -1788,6 +1788,8 @@ xio3130-downstream pxb + + pxb-pcie @@ -1846,6 +1848,7 @@ pcie-switch-upstream-port pcie-switch-downstream-port pci-expander-bus + pcie-expander-bus diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index b8f897f173..c0afa21e05 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -59,8 +59,11 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model) return VIR_PCI_CONNECT_TYPE_PCI_DEVICE; case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - /* dmi-to-pci-bridge is treated like a PCIe device - * (e.g. it can be plugged directly into pcie-root) + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* dmi-to-pci-bridge and pcie-expander-bus are treated like + * PCIe devices (the part of pcie-expander-bus that is plugged + * in isn't the expander bus itself, but a companion device + * used for setting it up). */ return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; @@ -279,6 +282,16 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, bus->minSlot = 0; bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + /* single slot, no hotplug, only accepts pcie-root-port or + * pcie-switch-upstream-port. + */ + bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT + | VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT); + bus->minSlot = 0; + bus->maxSlot = 0; + break; + default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid PCI controller model %d"), model); diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b541b270fe..5952946557 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -321,7 +321,8 @@ VIR_ENUM_IMPL(virDomainControllerModelPCI, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST, "pcie-root-port", "pcie-switch-upstream-port", "pcie-switch-downstream-port", - "pci-expander-bus") + "pci-expander-bus", + "pcie-expander-bus") VIR_ENUM_IMPL(virDomainControllerPCIModelName, VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_LAST, @@ -331,7 +332,8 @@ VIR_ENUM_IMPL(virDomainControllerPCIModelName, "ioh3420", "x3130-upstream", "xio3130-downstream", - "pxb") + "pxb", + "pxb-pcie") 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 76093e4b67..ef7358bb57 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -760,6 +760,7 @@ typedef enum { VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT, VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT, VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS, + VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS, VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST } virDomainControllerModelPCI; @@ -772,6 +773,7 @@ typedef enum { VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_X3130_UPSTREAM, 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_LAST } virDomainControllerPCIModelName; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index a806355dda..53aae83605 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1375,6 +1375,7 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB; break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: @@ -1579,6 +1580,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, options->port = addr->slot; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: if (options->busNr == -1) options->busNr = qemuDomainAddressFindNewBusNr(def); if (options->busNr == -1) { diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.xml new file mode 100644 index 0000000000..72681ce730 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.xml @@ -0,0 +1,247 @@ + + pcie-expander-bus-test + 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 + 2097152 + 2097152 + 16 + + hvm + + + + + + + + + + + destroy + restart + destroy + + /usr/libexec/qemu-kvm + + + +
+ + + + + + + + + + + + + 0 + +
+ + + + 1 + +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-expander-bus.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-expander-bus.xml new file mode 100644 index 0000000000..7a37870e43 --- /dev/null +++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pcie-expander-bus.xml @@ -0,0 +1,384 @@ + + pcie-expander-bus-test + 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 + 2097152 + 2097152 + 16 + + hvm + + + + + + + + + + + destroy + restart + destroy + + /usr/libexec/qemu-kvm + + + +
+ + + + +
+ + + + +
+ + + + + 0 + +
+ + + + + 1 + +
+ + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 78b6dbe15b..f766f4dc52 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -647,6 +647,13 @@ mymain(void) DO_TEST_FULL("pci-expander-bus", WHEN_ACTIVE, QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PXB); + DO_TEST_FULL("pcie-expander-bus", WHEN_ACTIVE, + QEMU_CAPS_DEVICE_PCI_BRIDGE, + QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, + QEMU_CAPS_DEVICE_IOH3420, + QEMU_CAPS_DEVICE_X3130_UPSTREAM, + QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM, + QEMU_CAPS_DEVICE_PXB_PCIE); DO_TEST_FULL("hostdev-scsi-lsi", WHEN_ACTIVE,