This is backed by the qemu device pxb-pcie, which will be available in qemu 2.6.0. As with pci-expander-bus (which uses qemu's pxb device), the busNr attribute and <node> subelement of <target> are used to set the bus_nr and numa_node options. During post-parse we validate that the domain's machinetype is q35-based (since the device shows up for 440fx-based machinetypes, but is unusable), as well as checking that <node> specifies a node that is actually configured 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 | 21 +++- src/qemu/qemu_domain_address.c | 2 + .../qemuxml2argv-pcie-expander-bus-bad-machine.xml | 36 ++++++ .../qemuxml2argv-pcie-expander-bus.args | 123 +++++++++++++++++++++ tests/qemuxml2argvtest.c | 15 +++ 6 files changed, 228 insertions(+), 6 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-machine.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.args diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3908176..f12c48c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2537,6 +2537,43 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef, modelName, def->opts.pciopts.port, def->opts.pciopts.chassis, def->info.alias); break; + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_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 pcie-expander-bus options not set")); + goto error; + } + + modelName = virDomainControllerPCIModelNameTypeToString(def->opts.pciopts.modelName); + if (!modelName) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown pcie-expander-bus model name value %d"), + def->opts.pciopts.modelName); + goto error; + } + if (def->opts.pciopts.modelName + != VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("PCI controller model name '%s' " + "is not valid for a pcie-expander-bus"), + modelName); + goto error; + } + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_PXB_PCIE)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("the pxb-pcie 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; } break; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3c00a13..c9261cd 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1623,28 +1623,37 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, 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)) { + if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS && + !qemuDomainMachineIsI440FX(def)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("pci-expander-bus controllers are only supported " "on 440fx-based machinetypes")); goto cleanup; } + if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS && + !qemuDomainMachineIsQ35(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("pcie-expander-bus controllers are only supported " + "on q35-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) + if ((cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS || + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS) && + (int) virDomainNumaGetNodeCount(def->numa) <= cont->opts.pciopts.numaNode) { virReportError(VIR_ERR_XML_ERROR, - _("pci-expander-bus with index %d is " + _("%s with index %d is " "configured for a NUMA node (%d) " "not present in the domain's " "<cpu><numa> array (%zu)"), + virDomainControllerModelPCITypeToString(cont->model), cont->idx, cont->opts.pciopts.numaNode, virDomainNumaGetNodeCount(def->numa)); goto cleanup; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 9006643..f5dc9c3 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1379,6 +1379,8 @@ qemuDomainPCIControllerSetDefaultModelName(virDomainControllerDefPtr cont) *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB; break; case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + *modelName = VIR_DOMAIN_CONTROLLER_PCI_MODEL_NAME_PXB_PCIE; + break; case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-machine.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-machine.xml new file mode 100644 index 0000000..dc64d97 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-machine.xml @@ -0,0 +1,36 @@ +<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> + <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='pcie-expander-bus'> + <model name='pxb-pcie'/> + <target busNr='254'> + <node>1</node> + </target> + </controller> + <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-pcie-expander-bus.args b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.args new file mode 100644 index 0000000..13f546c --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus.args @@ -0,0 +1,123 @@ +LC_ALL=C \ +PATH=/bin \ +HOME=/home/test \ +USER=test \ +LOGNAME=test \ +QEMU_AUDIO_DRV=none \ +/usr/libexec/qemu-kvm \ +-name pcie-expander-bus-test \ +-S \ +-M q35 \ +-m 214 \ +-smp 16 \ +-numa node,nodeid=0,cpus=0-7,mem=107 \ +-numa node,nodeid=1,cpus=8-15,mem=107 \ +-uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \ +-nographic \ +-nodefaults \ +-monitor unix:/tmp/lib/domain--1-pcie-expander-bus-te/monitor.sock,server,nowait \ +-no-acpi \ +-boot c \ +-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ +-device pci-bridge,chassis_nr=56,id=pci.2,bus=pci.1,addr=0x0 \ +-device pxb-pcie,bus_nr=254,id=pci.3,numa_node=0,bus=pcie.0,addr=0x4 \ +-device ioh3420,port=0x0,chassis=4,id=pci.4,bus=pci.3,addr=0x0 \ +-device x3130-upstream,id=pci.5,bus=pci.4,addr=0x0 \ +-device xio3130-downstream,port=0x0,chassis=6,id=pci.6,bus=pci.5,addr=0x0 \ +-device xio3130-downstream,port=0x1,chassis=7,id=pci.7,bus=pci.5,addr=0x1 \ +-device xio3130-downstream,port=0x2,chassis=8,id=pci.8,bus=pci.5,addr=0x2 \ +-device xio3130-downstream,port=0x3,chassis=9,id=pci.9,bus=pci.5,addr=0x3 \ +-device xio3130-downstream,port=0x4,chassis=10,id=pci.10,bus=pci.5,addr=0x4 \ +-device xio3130-downstream,port=0x5,chassis=11,id=pci.11,bus=pci.5,addr=0x5 \ +-device xio3130-downstream,port=0x6,chassis=12,id=pci.12,bus=pci.5,addr=0x6 \ +-device xio3130-downstream,port=0x7,chassis=13,id=pci.13,bus=pci.5,addr=0x7 \ +-device xio3130-downstream,port=0x8,chassis=14,id=pci.14,bus=pci.5,addr=0x8 \ +-device xio3130-downstream,port=0x9,chassis=15,id=pci.15,bus=pci.5,addr=0x9 \ +-device xio3130-downstream,port=0xa,chassis=16,id=pci.16,bus=pci.5,addr=0xa \ +-device xio3130-downstream,port=0xb,chassis=17,id=pci.17,bus=pci.5,addr=0xb \ +-device xio3130-downstream,port=0xc,chassis=18,id=pci.18,bus=pci.5,addr=0xc \ +-device xio3130-downstream,port=0xd,chassis=19,id=pci.19,bus=pci.5,addr=0xd \ +-device xio3130-downstream,port=0xe,chassis=20,id=pci.20,bus=pci.5,addr=0xe \ +-device xio3130-downstream,port=0xf,chassis=21,id=pci.21,bus=pci.5,addr=0xf \ +-device xio3130-downstream,port=0x10,chassis=22,id=pci.22,bus=pci.5,addr=0x10 \ +-device xio3130-downstream,port=0x11,chassis=23,id=pci.23,bus=pci.5,addr=0x11 \ +-device xio3130-downstream,port=0x12,chassis=24,id=pci.24,bus=pci.5,addr=0x12 \ +-device xio3130-downstream,port=0x13,chassis=25,id=pci.25,bus=pci.5,addr=0x13 \ +-device xio3130-downstream,port=0x14,chassis=26,id=pci.26,bus=pci.5,addr=0x14 \ +-device xio3130-downstream,port=0x15,chassis=27,id=pci.27,bus=pci.5,addr=0x15 \ +-device xio3130-downstream,port=0x16,chassis=28,id=pci.28,bus=pci.5,addr=0x16 \ +-device xio3130-downstream,port=0x17,chassis=29,id=pci.29,bus=pci.5,addr=0x17 \ +-device xio3130-downstream,port=0x18,chassis=30,id=pci.30,bus=pci.5,addr=0x18 \ +-device xio3130-downstream,port=0x19,chassis=31,id=pci.31,bus=pci.5,addr=0x19 \ +-device xio3130-downstream,port=0x1a,chassis=32,id=pci.32,bus=pci.5,addr=0x1a \ +-device xio3130-downstream,port=0x1b,chassis=33,id=pci.33,bus=pci.5,addr=0x1b \ +-device xio3130-downstream,port=0x1c,chassis=34,id=pci.34,bus=pci.5,addr=0x1c \ +-device xio3130-downstream,port=0x1d,chassis=35,id=pci.35,bus=pci.5,addr=0x1d \ +-device xio3130-downstream,port=0x1e,chassis=36,id=pci.36,bus=pci.5,addr=0x1e \ +-device xio3130-downstream,port=0x1f,chassis=37,id=pci.37,bus=pci.5,addr=0x1f \ +-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-sata0-0-0 \ +-device ide-drive,bus=ide.0,drive=drive-sata0-0-0,id=sata0-0-0 \ +-device rtl8139,vlan=0,id=net0,mac=52:54:00:f1:95:51,bus=pci.6,addr=0x0 \ +-net user,vlan=0,name=hostnet0 \ +-device e1000,vlan=1,id=net1,mac=52:54:00:5c:c6:1a,bus=pci.7,addr=0x0 \ +-net user,vlan=1,name=hostnet1 \ +-device e1000,vlan=2,id=net2,mac=52:54:00:39:97:ac,bus=pci.8,addr=0x0 \ +-net user,vlan=2,name=hostnet2 \ +-device e1000,vlan=3,id=net3,mac=52:54:00:ee:b9:a8,bus=pci.9,addr=0x0 \ +-net user,vlan=3,name=hostnet3 \ +-device e1000,vlan=4,id=net4,mac=52:54:00:a9:f7:17,bus=pci.10,addr=0x0 \ +-net user,vlan=4,name=hostnet4 \ +-device e1000,vlan=5,id=net5,mac=52:54:00:df:2b:f3,bus=pci.11,addr=0x0 \ +-net user,vlan=5,name=hostnet5 \ +-device e1000,vlan=6,id=net6,mac=52:54:00:78:94:b4,bus=pci.12,addr=0x0 \ +-net user,vlan=6,name=hostnet6 \ +-device e1000,vlan=7,id=net7,mac=52:54:00:6b:9b:06,bus=pci.13,addr=0x0 \ +-net user,vlan=7,name=hostnet7 \ +-device e1000,vlan=8,id=net8,mac=52:54:00:17:df:bc,bus=pci.14,addr=0x0 \ +-net user,vlan=8,name=hostnet8 \ +-device e1000,vlan=9,id=net9,mac=52:54:00:3b:d0:51,bus=pci.15,addr=0x0 \ +-net user,vlan=9,name=hostnet9 \ +-device e1000,vlan=10,id=net10,mac=52:54:00:8d:2d:17,bus=pci.16,addr=0x0 \ +-net user,vlan=10,name=hostnet10 \ +-device e1000,vlan=11,id=net11,mac=52:54:00:a7:66:af,bus=pci.17,addr=0x0 \ +-net user,vlan=11,name=hostnet11 \ +-device e1000,vlan=12,id=net12,mac=52:54:00:54:ab:d7,bus=pci.18,addr=0x0 \ +-net user,vlan=12,name=hostnet12 \ +-device e1000,vlan=13,id=net13,mac=52:54:00:1f:99:90,bus=pci.19,addr=0x0 \ +-net user,vlan=13,name=hostnet13 \ +-device e1000,vlan=14,id=net14,mac=52:54:00:c8:43:87,bus=pci.20,addr=0x0 \ +-net user,vlan=14,name=hostnet14 \ +-device e1000,vlan=15,id=net15,mac=52:54:00:df:22:b2,bus=pci.21,addr=0x0 \ +-net user,vlan=15,name=hostnet15 \ +-device e1000,vlan=16,id=net16,mac=52:54:00:d2:9a:47,bus=pci.22,addr=0x0 \ +-net user,vlan=16,name=hostnet16 \ +-device e1000,vlan=17,id=net17,mac=52:54:00:86:05:e2,bus=pci.23,addr=0x0 \ +-net user,vlan=17,name=hostnet17 \ +-device e1000,vlan=18,id=net18,mac=52:54:00:8c:1c:c2,bus=pci.24,addr=0x0 \ +-net user,vlan=18,name=hostnet18 \ +-device e1000,vlan=19,id=net19,mac=52:54:00:48:58:92,bus=pci.25,addr=0x0 \ +-net user,vlan=19,name=hostnet19 \ +-device e1000,vlan=20,id=net20,mac=52:54:00:99:e5:bf,bus=pci.26,addr=0x0 \ +-net user,vlan=20,name=hostnet20 \ +-device e1000,vlan=21,id=net21,mac=52:54:00:b1:8c:25,bus=pci.27,addr=0x0 \ +-net user,vlan=21,name=hostnet21 \ +-device e1000,vlan=22,id=net22,mac=52:54:00:60:e0:d0,bus=pci.28,addr=0x0 \ +-net user,vlan=22,name=hostnet22 \ +-device e1000,vlan=23,id=net23,mac=52:54:00:37:00:6a,bus=pci.29,addr=0x0 \ +-net user,vlan=23,name=hostnet23 \ +-device e1000,vlan=24,id=net24,mac=52:54:00:c7:c8:ad,bus=pci.30,addr=0x0 \ +-net user,vlan=24,name=hostnet24 \ +-device e1000,vlan=25,id=net25,mac=52:54:00:4e:a7:cf,bus=pci.31,addr=0x0 \ +-net user,vlan=25,name=hostnet25 \ +-device e1000,vlan=26,id=net26,mac=52:54:00:00:79:69,bus=pci.32,addr=0x0 \ +-net user,vlan=26,name=hostnet26 \ +-device e1000,vlan=27,id=net27,mac=52:54:00:47:00:6f,bus=pci.33,addr=0x0 \ +-net user,vlan=27,name=hostnet27 \ +-device e1000,vlan=28,id=net28,mac=52:54:00:2a:8c:8b,bus=pci.34,addr=0x0 \ +-net user,vlan=28,name=hostnet28 \ +-device e1000,vlan=29,id=net29,mac=52:54:00:ec:d5:e3,bus=pci.35,addr=0x0 \ +-net user,vlan=29,name=hostnet29 \ +-device e1000,vlan=30,id=net30,mac=52:54:00:7e:6e:c8,bus=pci.36,addr=0x0 \ +-net user,vlan=30,name=hostnet30 \ +-device e1000,vlan=31,id=net31,mac=52:54:00:7e:6d:c9,bus=pci.37,addr=0x0 \ +-net user,vlan=31,name=hostnet31 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 65be98f..7b62511 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1590,6 +1590,21 @@ mymain(void) QEMU_CAPS_DEVICE_PCI_BRIDGE, QEMU_CAPS_DEVICE_PXB); + DO_TEST("pcie-expander-bus", + 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_PARSE_ERROR("pcie-expander-bus-bad-machine", + 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("hostdev-scsi-lsi", QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, QEMU_CAPS_DEVICE_SCSI_GENERIC); -- 2.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list