This is backed by the qemu device "pxb".
The pxb device always includes a pci-bridge that is at the bus number
of the pxb + 1.
busNr and <node> from the <target> subelement are used to set the
bus_nr and numa_node options for pxb.
During post-parse we validate that the domain's machinetype is
440fx-based (since the pxb device only works on 440fx-based machines),
and <node> also gets a sanity check to assure that the NUMA node
specified for the pxb (if any - it's optional) actually exists on the
guest.
This patch and its prerequisites are part of the resolution for:
https://bugzilla.redhat.com/show_bug.cgi?id=1103314
---
src/qemu/qemu_command.c | 37 +++++
src/qemu/qemu_domain.c | 33 ++++
src/qemu/qemu_domain_address.c | 82 ++++++++++
.../qemuxml2argv-pci-expander-bus-bad-machine.xml | 167 +++++++++++++++++++++
.../qemuxml2argv-pci-expander-bus-bad-node.xml | 160 ++++++++++++++++++++
.../qemuxml2argv-pci-expander-bus.args | 87 +++++++++++
tests/qemuxml2argvtest.c | 10 ++
.../qemuxml2xmlout-pci-expander-bus.xml | 1 +
8 files changed, 577 insertions(+)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-machine.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-node.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.args
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0331789..3908176 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2368,6 +2368,43 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
modelName, def->opts.pciopts.chassisNr,
def->info.alias);
break;
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
+ if (def->opts.pciopts.modelName
+ == VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE ||
+ def->opts.pciopts.busNr == -1) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("autogenerated pci-expander-bus options not
set"));
+ goto error;
+ }
+
+ modelName =
virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName);
+ if (!modelName) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("unknown pci-expander-bus model name value
%d"),
+ def->opts.pciopts.modelName);
+ goto error;
+ }
+ if (def->opts.pciopts.modelName
+ != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("PCI controller model name '%s' "
+ "is not valid for a pci-expander-bus"),
+ modelName);
+ goto error;
+ }
+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("the pxb controller "
+ "is not supported in this QEMU binary"));
+ goto error;
+ }
+ virBufferAsprintf(&buf, "%s,bus_nr=%d,id=%s",
+ modelName, def->opts.pciopts.busNr,
+ def->info.alias);
+ if (def->opts.pciopts.numaNode != -1)
+ virBufferAsprintf(&buf, ",numa_node=%d",
+ def->opts.pciopts.numaNode);
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
if (def->opts.pciopts.modelName
== VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_NONE) {
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 53cb2b6..3c00a13 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1619,6 +1619,39 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
dev->data.panic->model = VIR_DOMAIN_PANIC_MODEL_ISA;
}
+
+ if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER) {
+ virDomainControllerDefPtr cont = dev->data.controller;
+
+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
+ cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS) {
+
+ if (!qemuDomainMachineIsI440FX(def)) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("pci-expander-bus controllers are only supported
"
+ "on 440fx-based machinetypes"));
+ goto cleanup;
+ }
+
+ /* if a PCI expander bus has a NUMA node set, make sure
+ * that NUMA node is configured in the guest <cpu><numa>
+ * array. NUMA cell id's in this array are numbered
+ * from 0 .. size-1.
+ */
+ if ((int) virDomainNumaGetNodeCount(def->numa)
+ <= cont->opts.pciopts.numaNode) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("pci-expander-bus with index %d is "
+ "configured for a NUMA node (%d) "
+ "not present in the domain's "
+ "<cpu><numa> array (%zu)"),
+ cont->idx, cont->opts.pciopts.numaNode,
+ virDomainNumaGetNodeCount(def->numa));
+ goto cleanup;
+ }
+ }
+ }
+
ret = 0;
cleanup:
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 0aca829..aaec7b5 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1376,6 +1376,8 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr
cont)
*modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_XIO3130_DOWNSTREAM;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
+ *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB;
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
@@ -1385,6 +1387,74 @@
qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont)
static int
+qemuDomainAddressFindNewBusNr(virDomainDefPtr def)
+{
+/* Try to find a nice default for busNr for a new pci-expander-bus.
+ * This is a bit tricky, since you need to satisfy the following:
+ *
+ * 1) There need to be enough unused bus numbers between busNr of this
+ * bus and busNr of the next highest bus for the guest to assign a
+ * unique bus number to each PCI bus that is a child of this
+ * bus. Each PCI controller. On top of this, the pxb device (which
+ * implements the pci-extender-bus) includes a pci-bridge within
+ * it, and that bridge also uses one bus number (so each pxb device
+ * requires at least 2 bus numbers).
+ *
+ * 2) There need to be enough bus numbers *below* this for all the
+ * child controllers of the pci-expander-bus with the next lower
+ * busNr (or the pci-root bus if there are no lower
+ * pci-expander-buses).
+ *
+ * 3) If at all possible, we want to avoid needing to change the busNr
+ * of a bus in the future, as that changes the guest's device ABI,
+ * which could potentially lead to issues with a guest OS that is
+ * picky about such things.
+ *
+ * Due to the impossibility of predicting what might be added to the
+ * config in the future, we can't make a foolproof choice, but since
+ * a pci-expander-bus (pxb) has slots for 32 devices, and the only
+ * practical use for it is to assign real devices on a particular
+ * NUMA node in the host, it's reasonably safe to assume it should
+ * never need any additional child buses (probably only a few of the
+ * 32 will ever be used). So for pci-expander-bus we find the lowest
+ * existing busNr, and set this one to the current lowest - 2 (one
+ * for the pxb, one for the intergrated pci-bridge), thus leaving the
+ * maximum possible bus numbers available for other buses plugged
+ * into pci-root (i.e. pci-bridges and other
+ * pci-expander-buses). Anyone who needs more than 32 devices
+ * descended from one pci-expander-bus should set the busNr manually
+ * in the config.
+ *
+ * There is room for more error checking here - in particular we
+ * can/should determine the ultimate parent (root-bus) of each PCI
+ * controller and determine if there is enough space for all the
+ * buses within the current range allotted to the bus just prior to
+ * this one.
+ */
+ size_t i;
+ int lowestBusNr = 256;
+
+ for (i = 0; i < def->ncontrollers; i++) {
+ if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
+ int thisBusNr = def->controllers[i]->opts.pciopts.busNr;
+
+ if (thisBusNr >= 0 && thisBusNr < lowestBusNr)
+ lowestBusNr = thisBusNr;
+ }
+ }
+
+ /* If we already have a busNR = 1, then we can't auto-assign (0 is
+ * the pci[e]-root, and the others may have been assigned
+ * purposefully).
+ */
+ if (lowestBusNr <= 2)
+ return -1;
+
+ return lowestBusNr - 2;
+}
+
+
+static int
qemuDomainAssignPCIAddresses(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps,
virDomainObjPtr obj)
@@ -1512,6 +1582,18 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
options->port = addr->slot;
break;
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
+ if (options->busNr == -1)
+ options->busNr = qemuDomainAddressFindNewBusNr(def);
+ if (options->busNr == -1) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("No free busNr lower than current "
+ "lowest busNr is available to "
+ "auto-assign to bus %d. Must be "
+ "manually assigned"),
+ addr->bus);
+ goto cleanup;
+ }
+ break;
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT:
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-machine.xml
b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-machine.xml
new file mode 100644
index 0000000..606ddfd
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-machine.xml
@@ -0,0 +1,167 @@
+<domain type='qemu'>
+ <name>expander-test</name>
+ <uuid>3ec6cbe1-b5a2-4515-b800-31a61855df41</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>16</vcpu>
+ <os>
+ <type arch='x86_64' machine='q35'>hvm</type>
+ </os>
+ <cpu>
+ <topology sockets='2' cores='4' threads='2'/>
+ <numa>
+ <cell cpus='0-7' memory='109550' unit='KiB'/>
+ <cell cpus='8-15' memory='109550' unit='KiB'/>
+ </numa>
+ </cpu>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='pci' index='1'
model='pci-expander-bus'>
+ <model name='pxb'/>
+ <target busNr='254'>
+ <node>1</node>
+ </target>
+ </controller>
+ <controller type='pci' index='2'
model='pci-expander-bus'>
+ <model name='pxb'/>
+ </controller>
+ <interface type='user'>
+ <mac address='52:54:00:f1:95:51'/>
+ <model type='rtl8139'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:5c:c6:1a'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:39:97:ac'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:45:28:cb'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:ee:b9:a8'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:a9:f7:17'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:df:2b:f3'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:78:94:b4'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:6b:9b:06'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:17:df:bc'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:3b:d0:51'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:8d:2d:17'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:a7:66:af'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:54:ab:d7'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:1f:99:90'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:c8:43:87'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:df:22:b2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:d2:9a:47'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:86:05:e2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:8c:1c:c2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:48:58:92'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:99:e5:bf'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:b1:8c:25'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:60:e0:d0'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:37:00:6a'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:c7:c8:ad'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:4e:a7:cf'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:00:79:69'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:47:00:6f'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:2a:8c:8b'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:ec:d5:e3'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:7e:6e:c8'/>
+ <model type='e1000'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x06' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-node.xml
b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-node.xml
new file mode 100644
index 0000000..2c390ea
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-node.xml
@@ -0,0 +1,160 @@
+<domain type='qemu'>
+ <name>expander-test</name>
+ <uuid>3ec6cbe1-b5a2-4515-b800-31a61855df41</uuid>
+ <memory unit='KiB'>219100</memory>
+ <currentMemory unit='KiB'>219100</currentMemory>
+ <vcpu placement='static'>16</vcpu>
+ <os>
+ <type arch='x86_64' machine='pc-i440fx-2.5'>hvm</type>
+ </os>
+ <devices>
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
+ <controller type='usb' index='0' model='none'/>
+ <controller type='ide' index='0'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x01' function='0x1'/>
+ </controller>
+ <controller type='pci' index='0' model='pci-root'/>
+ <controller type='pci' index='1'
model='pci-expander-bus'>
+ <model name='pxb'/>
+ <target busNr='254'>
+ <node>1</node>
+ </target>
+ </controller>
+ <controller type='pci' index='2'
model='pci-expander-bus'>
+ <model name='pxb'/>
+ </controller>
+ <interface type='user'>
+ <mac address='52:54:00:f1:95:51'/>
+ <model type='rtl8139'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:5c:c6:1a'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:39:97:ac'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:45:28:cb'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:ee:b9:a8'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:a9:f7:17'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:df:2b:f3'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:78:94:b4'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:6b:9b:06'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:17:df:bc'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:3b:d0:51'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:8d:2d:17'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:a7:66:af'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:54:ab:d7'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:1f:99:90'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:c8:43:87'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:df:22:b2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:d2:9a:47'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:86:05:e2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:8c:1c:c2'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:48:58:92'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:99:e5:bf'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:b1:8c:25'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:60:e0:d0'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:37:00:6a'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:c7:c8:ad'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:4e:a7:cf'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:00:79:69'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:47:00:6f'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:2a:8c:8b'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:ec:d5:e3'/>
+ <model type='e1000'/>
+ </interface>
+ <interface type='user'>
+ <mac address='52:54:00:7e:6e:c8'/>
+ <model type='e1000'/>
+ </interface>
+ <input type='mouse' bus='ps2'/>
+ <input type='keyboard' bus='ps2'/>
+ <memballoon model='virtio'>
+ <address type='pci' domain='0x0000' bus='0x00'
slot='0x06' function='0x0'/>
+ </memballoon>
+ </devices>
+</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.args
b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.args
new file mode 100644
index 0000000..268a301
--- /dev/null
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus.args
@@ -0,0 +1,87 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-x86_64 \
+-name expander-test \
+-S \
+-M pc-i440fx-2.5 \
+-m 214 \
+-smp 16 \
+-numa node,nodeid=0,cpus=0-7,mem=107 \
+-numa node,nodeid=1,cpus=8-15,mem=107 \
+-uuid 3ec6cbe1-b5a2-4515-b800-31a61855df41 \
+-nographic \
+-nodefaults \
+-monitor unix:/tmp/lib/domain--1-expander-test/monitor.sock,server,nowait \
+-no-acpi \
+-boot c \
+-device pxb,bus_nr=254,id=pci.1,numa_node=1,bus=pci.0,addr=0x3 \
+-device pxb,bus_nr=252,id=pci.2,bus=pci.0,addr=0x4 \
+-device rtl8139,vlan=0,id=net0,mac=52:54:00:f1:95:51,bus=pci.0,addr=0x5 \
+-net user,vlan=0,name=hostnet0 \
+-device e1000,vlan=1,id=net1,mac=52:54:00:5c:c6:1a,bus=pci.0,addr=0x7 \
+-net user,vlan=1,name=hostnet1 \
+-device e1000,vlan=2,id=net2,mac=52:54:00:39:97:ac,bus=pci.0,addr=0x8 \
+-net user,vlan=2,name=hostnet2 \
+-device e1000,vlan=3,id=net3,mac=52:54:00:45:28:cb,bus=pci.0,addr=0x9 \
+-net user,vlan=3,name=hostnet3 \
+-device e1000,vlan=4,id=net4,mac=52:54:00:ee:b9:a8,bus=pci.0,addr=0xa \
+-net user,vlan=4,name=hostnet4 \
+-device e1000,vlan=5,id=net5,mac=52:54:00:a9:f7:17,bus=pci.0,addr=0xb \
+-net user,vlan=5,name=hostnet5 \
+-device e1000,vlan=6,id=net6,mac=52:54:00:df:2b:f3,bus=pci.0,addr=0xc \
+-net user,vlan=6,name=hostnet6 \
+-device e1000,vlan=7,id=net7,mac=52:54:00:78:94:b4,bus=pci.0,addr=0xd \
+-net user,vlan=7,name=hostnet7 \
+-device e1000,vlan=8,id=net8,mac=52:54:00:6b:9b:06,bus=pci.0,addr=0xe \
+-net user,vlan=8,name=hostnet8 \
+-device e1000,vlan=9,id=net9,mac=52:54:00:17:df:bc,bus=pci.0,addr=0xf \
+-net user,vlan=9,name=hostnet9 \
+-device e1000,vlan=10,id=net10,mac=52:54:00:3b:d0:51,bus=pci.0,addr=0x10 \
+-net user,vlan=10,name=hostnet10 \
+-device e1000,vlan=11,id=net11,mac=52:54:00:8d:2d:17,bus=pci.0,addr=0x11 \
+-net user,vlan=11,name=hostnet11 \
+-device e1000,vlan=12,id=net12,mac=52:54:00:a7:66:af,bus=pci.0,addr=0x12 \
+-net user,vlan=12,name=hostnet12 \
+-device e1000,vlan=13,id=net13,mac=52:54:00:54:ab:d7,bus=pci.0,addr=0x13 \
+-net user,vlan=13,name=hostnet13 \
+-device e1000,vlan=14,id=net14,mac=52:54:00:1f:99:90,bus=pci.0,addr=0x14 \
+-net user,vlan=14,name=hostnet14 \
+-device e1000,vlan=15,id=net15,mac=52:54:00:c8:43:87,bus=pci.0,addr=0x15 \
+-net user,vlan=15,name=hostnet15 \
+-device e1000,vlan=16,id=net16,mac=52:54:00:df:22:b2,bus=pci.0,addr=0x16 \
+-net user,vlan=16,name=hostnet16 \
+-device e1000,vlan=17,id=net17,mac=52:54:00:d2:9a:47,bus=pci.0,addr=0x17 \
+-net user,vlan=17,name=hostnet17 \
+-device e1000,vlan=18,id=net18,mac=52:54:00:86:05:e2,bus=pci.0,addr=0x18 \
+-net user,vlan=18,name=hostnet18 \
+-device e1000,vlan=19,id=net19,mac=52:54:00:8c:1c:c2,bus=pci.0,addr=0x19 \
+-net user,vlan=19,name=hostnet19 \
+-device e1000,vlan=20,id=net20,mac=52:54:00:48:58:92,bus=pci.0,addr=0x1a \
+-net user,vlan=20,name=hostnet20 \
+-device e1000,vlan=21,id=net21,mac=52:54:00:99:e5:bf,bus=pci.0,addr=0x1b \
+-net user,vlan=21,name=hostnet21 \
+-device e1000,vlan=22,id=net22,mac=52:54:00:b1:8c:25,bus=pci.0,addr=0x1c \
+-net user,vlan=22,name=hostnet22 \
+-device e1000,vlan=23,id=net23,mac=52:54:00:60:e0:d0,bus=pci.0,addr=0x1d \
+-net user,vlan=23,name=hostnet23 \
+-device e1000,vlan=24,id=net24,mac=52:54:00:37:00:6a,bus=pci.0,addr=0x1e \
+-net user,vlan=24,name=hostnet24 \
+-device e1000,vlan=25,id=net25,mac=52:54:00:c7:c8:ad,bus=pci.0,addr=0x1f \
+-net user,vlan=25,name=hostnet25 \
+-device e1000,vlan=26,id=net26,mac=52:54:00:4e:a7:cf,bus=pci.1,addr=0x0 \
+-net user,vlan=26,name=hostnet26 \
+-device e1000,vlan=27,id=net27,mac=52:54:00:00:79:69,bus=pci.1,addr=0x1 \
+-net user,vlan=27,name=hostnet27 \
+-device e1000,vlan=28,id=net28,mac=52:54:00:47:00:6f,bus=pci.1,addr=0x2 \
+-net user,vlan=28,name=hostnet28 \
+-device e1000,vlan=29,id=net29,mac=52:54:00:2a:8c:8b,bus=pci.1,addr=0x3 \
+-net user,vlan=29,name=hostnet29 \
+-device e1000,vlan=30,id=net30,mac=52:54:00:ec:d5:e3,bus=pci.1,addr=0x4 \
+-net user,vlan=30,name=hostnet30 \
+-device e1000,vlan=31,id=net31,mac=52:54:00:7e:6e:c8,bus=pci.1,addr=0x5 \
+-net user,vlan=31,name=hostnet31 \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e9b8d64..65be98f 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -1580,6 +1580,16 @@ mymain(void)
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
+ DO_TEST("pci-expander-bus",
+ QEMU_CAPS_DEVICE_PCI_BRIDGE,
+ QEMU_CAPS_DEVICE_PXB);
+ DO_TEST_PARSE_ERROR("pci-expander-bus-bad-node",
+ QEMU_CAPS_DEVICE_PCI_BRIDGE,
+ QEMU_CAPS_DEVICE_PXB);
+ DO_TEST_PARSE_ERROR("pci-expander-bus-bad-machine",
+ QEMU_CAPS_DEVICE_PCI_BRIDGE,
+ QEMU_CAPS_DEVICE_PXB);
+
DO_TEST("hostdev-scsi-lsi",
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
QEMU_CAPS_DEVICE_SCSI_GENERIC);
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-expander-bus.xml
b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-expander-bus.xml
index 946e94f..e0d787e 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-expander-bus.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-pci-expander-bus.xml
@@ -35,6 +35,7 @@
</controller>
<controller type='pci' index='2'
model='pci-expander-bus'>
<model name='pxb'/>
+ <target busNr='252'/>
<address type='pci' domain='0x0000' bus='0x00'
slot='0x04' function='0x0'/>
</controller>
<interface type='user'>
--
2.5.5