|
|
6ae9ed |
From 646a880d28b878dc45decb1b6d6238bf42ad1006 Mon Sep 17 00:00:00 2001
|
|
|
6ae9ed |
Message-Id: <646a880d28b878dc45decb1b6d6238bf42ad1006@dist-git>
|
|
|
6ae9ed |
From: Laine Stump <laine@laine.org>
|
|
|
6ae9ed |
Date: Wed, 10 Aug 2016 11:00:14 -0400
|
|
|
6ae9ed |
Subject: [PATCH] conf: restrict expander buses to connect only to a root bus
|
|
|
6ae9ed |
|
|
|
6ae9ed |
More misunderstanding/mistaken assumptions on my part - I had thought
|
|
|
6ae9ed |
that a pci-expander-bus could be plugged into any legacy PCI slot, and
|
|
|
6ae9ed |
that pcie-expander-bus could be plugged into any PCIe slot. This isn't
|
|
|
6ae9ed |
correct - they can both be plugged ontly into their respective root
|
|
|
6ae9ed |
buses. This patch adds that restriction.
|
|
|
6ae9ed |
|
|
|
6ae9ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1358712
|
|
|
6ae9ed |
(cherry picked from commit a220f43a65cca6c6f2ca268cdbbf8f997b2e2b13)
|
|
|
6ae9ed |
---
|
|
|
6ae9ed |
src/conf/domain_addr.c | 32 +++++++++------
|
|
|
6ae9ed |
src/conf/domain_addr.h | 6 ++-
|
|
|
6ae9ed |
.../qemuxml2argv-pci-expander-bus-bad-bus.xml | 26 ++++++++++++
|
|
|
6ae9ed |
.../qemuxml2argv-pcie-expander-bus-bad-bus.xml | 48 ++++++++++++++++++++++
|
|
|
6ae9ed |
tests/qemuxml2argvtest.c | 8 ++++
|
|
|
6ae9ed |
5 files changed, 107 insertions(+), 13 deletions(-)
|
|
|
6ae9ed |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
|
|
|
6ae9ed |
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
|
|
|
6ae9ed |
index ea641a5..14baef7 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_addr.c
|
|
|
6ae9ed |
+++ b/src/conf/domain_addr.c
|
|
|
6ae9ed |
@@ -51,20 +51,17 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
|
|
|
6ae9ed |
return 0;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
|
|
6ae9ed |
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
|
|
|
6ae9ed |
- /* pci-bridge and pci-expander-bus are treated like a standard
|
|
|
6ae9ed |
- * PCI endpoint device, because they can plug into any
|
|
|
6ae9ed |
- * standard PCI slot.
|
|
|
6ae9ed |
+ /* pci-bridge is treated like a standard
|
|
|
6ae9ed |
+ * PCI endpoint device, because it can plug into any
|
|
|
6ae9ed |
+ * standard PCI slot (it just can't be hotplugged).
|
|
|
6ae9ed |
*/
|
|
|
6ae9ed |
return VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS:
|
|
|
6ae9ed |
+ return VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS;
|
|
|
6ae9ed |
+
|
|
|
6ae9ed |
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
|
|
6ae9ed |
- /* pcie-expander-bus is treated like a standard PCIe endpoint
|
|
|
6ae9ed |
- * device (the part of pcie-expander-bus that is plugged in
|
|
|
6ae9ed |
- * isn't the expander bus itself, but a companion device used
|
|
|
6ae9ed |
- * for setting it up).
|
|
|
6ae9ed |
- */
|
|
|
6ae9ed |
- return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
|
|
|
6ae9ed |
+ return VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
|
|
6ae9ed |
return VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE;
|
|
|
6ae9ed |
@@ -137,6 +134,10 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
|
|
|
6ae9ed |
connectStr = "pci-switch-downstream-port";
|
|
|
6ae9ed |
} else if (devFlags & VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) {
|
|
|
6ae9ed |
connectStr = "dmi-to-pci-bridge";
|
|
|
6ae9ed |
+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS) {
|
|
|
6ae9ed |
+ connectStr = "pci-expander-bus";
|
|
|
6ae9ed |
+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS) {
|
|
|
6ae9ed |
+ connectStr = "pcie-expander-bus";
|
|
|
6ae9ed |
} else {
|
|
|
6ae9ed |
/* this should never happen. If it does, there is a
|
|
|
6ae9ed |
* bug in the code that sets the flag bits for devices.
|
|
|
6ae9ed |
@@ -243,9 +244,15 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
|
|
|
6ae9ed |
* bus.
|
|
|
6ae9ed |
*/
|
|
|
6ae9ed |
switch (model) {
|
|
|
6ae9ed |
- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
|
|
6ae9ed |
case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT:
|
|
|
6ae9ed |
bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE |
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS);
|
|
|
6ae9ed |
+ bus->minSlot = 1;
|
|
|
6ae9ed |
+ bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
|
|
6ae9ed |
+ break;
|
|
|
6ae9ed |
+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE:
|
|
|
6ae9ed |
+ bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE |
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCI_DEVICE);
|
|
|
6ae9ed |
bus->minSlot = 1;
|
|
|
6ae9ed |
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
|
|
6ae9ed |
@@ -265,7 +272,8 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
|
|
|
6ae9ed |
*/
|
|
|
6ae9ed |
bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT |
|
|
|
6ae9ed |
- VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE);
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE |
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS);
|
|
|
6ae9ed |
bus->minSlot = 1;
|
|
|
6ae9ed |
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
|
|
6ae9ed |
break;
|
|
|
6ae9ed |
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
|
|
|
6ae9ed |
index 2d55c46..da19311 100644
|
|
|
6ae9ed |
--- a/src/conf/domain_addr.h
|
|
|
6ae9ed |
+++ b/src/conf/domain_addr.h
|
|
|
6ae9ed |
@@ -41,6 +41,8 @@ typedef enum {
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 4,
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 5,
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 6,
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 7,
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 8,
|
|
|
6ae9ed |
} virDomainPCIConnectFlags;
|
|
|
6ae9ed |
|
|
|
6ae9ed |
/* a combination of all bits that describe the type of connections
|
|
|
6ae9ed |
@@ -51,7 +53,9 @@ typedef enum {
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | \
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT | \
|
|
|
6ae9ed |
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | \
|
|
|
6ae9ed |
- VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE)
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE | \
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS | \
|
|
|
6ae9ed |
+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS)
|
|
|
6ae9ed |
|
|
|
6ae9ed |
/* combination of all bits that could be used to connect a normal
|
|
|
6ae9ed |
* endpoint device (i.e. excluding the connection possible between an
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
new file mode 100644
|
|
|
6ae9ed |
index 0000000..85c1115
|
|
|
6ae9ed |
--- /dev/null
|
|
|
6ae9ed |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
@@ -0,0 +1,26 @@
|
|
|
6ae9ed |
+<domain type='qemu'>
|
|
|
6ae9ed |
+ <name>expander-test</name>
|
|
|
6ae9ed |
+ <uuid>3ec6cbe1-b5a2-4515-b800-31a61855df41</uuid>
|
|
|
6ae9ed |
+ <memory unit='KiB'>219100</memory>
|
|
|
6ae9ed |
+ <currentMemory unit='KiB'>219100</currentMemory>
|
|
|
6ae9ed |
+ <vcpu placement='static'>16</vcpu>
|
|
|
6ae9ed |
+ <os>
|
|
|
6ae9ed |
+ <type arch='x86_64' machine='pc-i440fx-2.5'>hvm</type>
|
|
|
6ae9ed |
+ </os>
|
|
|
6ae9ed |
+ <devices>
|
|
|
6ae9ed |
+ <emulator>/usr/bin/qemu-system-x86_64</emulator>
|
|
|
6ae9ed |
+ <controller type='usb' index='0' model='none'/>
|
|
|
6ae9ed |
+ <controller type='ide' index='0'>
|
|
|
6ae9ed |
+ <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <controller type='pci' index='0' model='pci-root'/>
|
|
|
6ae9ed |
+ <controller type='pci' index='1' model='pci-bridge'>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <controller type='pci' index='2' model='pci-expander-bus'>
|
|
|
6ae9ed |
+ <address type='pci' bus='1' slot='1'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <input type='mouse' bus='ps2'/>
|
|
|
6ae9ed |
+ <input type='keyboard' bus='ps2'/>
|
|
|
6ae9ed |
+ <memballoon model='none'/>
|
|
|
6ae9ed |
+ </devices>
|
|
|
6ae9ed |
+</domain>
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
new file mode 100644
|
|
|
6ae9ed |
index 0000000..0305f35
|
|
|
6ae9ed |
--- /dev/null
|
|
|
6ae9ed |
+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml
|
|
|
6ae9ed |
@@ -0,0 +1,48 @@
|
|
|
6ae9ed |
+<domain type='qemu'>
|
|
|
6ae9ed |
+ <name>pcie-expander-bus-test</name>
|
|
|
6ae9ed |
+ <uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
|
|
|
6ae9ed |
+ <memory unit='KiB'>2097152</memory>
|
|
|
6ae9ed |
+ <currentMemory unit='KiB'>2097152</currentMemory>
|
|
|
6ae9ed |
+ <vcpu placement='static'>16</vcpu>
|
|
|
6ae9ed |
+ <os>
|
|
|
6ae9ed |
+ <type arch='x86_64' machine='q35'>hvm</type>
|
|
|
6ae9ed |
+ <boot dev='hd'/>
|
|
|
6ae9ed |
+ </os>
|
|
|
6ae9ed |
+ <cpu>
|
|
|
6ae9ed |
+ <topology sockets='2' cores='4' threads='2'/>
|
|
|
6ae9ed |
+ <numa>
|
|
|
6ae9ed |
+ <cell cpus='0-7' memory='109550' unit='KiB'/>
|
|
|
6ae9ed |
+ <cell cpus='8-15' memory='109550' unit='KiB'/>
|
|
|
6ae9ed |
+ </numa>
|
|
|
6ae9ed |
+ </cpu>
|
|
|
6ae9ed |
+ <clock offset='utc'/>
|
|
|
6ae9ed |
+ <on_poweroff>destroy</on_poweroff>
|
|
|
6ae9ed |
+ <on_reboot>restart</on_reboot>
|
|
|
6ae9ed |
+ <on_crash>destroy</on_crash>
|
|
|
6ae9ed |
+ <devices>
|
|
|
6ae9ed |
+ <emulator>/usr/libexec/qemu-kvm</emulator>
|
|
|
6ae9ed |
+ <disk type='block' device='disk'>
|
|
|
6ae9ed |
+ <source dev='/dev/HostVG/QEMUGuest1'/>
|
|
|
6ae9ed |
+ <target dev='sda' bus='sata'/>
|
|
|
6ae9ed |
+ <address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
|
|
6ae9ed |
+ </disk>
|
|
|
6ae9ed |
+ <controller type='pci' index='0' model='pcie-root'/>
|
|
|
6ae9ed |
+ <controller type='pci' index='1' model='dmi-to-pci-bridge'>
|
|
|
6ae9ed |
+ <model name='i82801b11-bridge'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <controller type='pci' index='2' model='pci-bridge'>
|
|
|
6ae9ed |
+ <model name='pci-bridge'/>
|
|
|
6ae9ed |
+ <target chassisNr='56'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <controller type='pci' index='3' model='pcie-root-port'>
|
|
|
6ae9ed |
+ <target busNr='220'>
|
|
|
6ae9ed |
+ <node>1</node>
|
|
|
6ae9ed |
+ </target>
|
|
|
6ae9ed |
+ <address type='pci' bus='0x00'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <controller type='pci' index='4' model='pcie-expander-bus'>
|
|
|
6ae9ed |
+ <address type='pci' bus='3'/>
|
|
|
6ae9ed |
+ </controller>
|
|
|
6ae9ed |
+ <memballoon model='none'/>
|
|
|
6ae9ed |
+ </devices>
|
|
|
6ae9ed |
+</domain>
|
|
|
6ae9ed |
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
|
|
|
6ae9ed |
index c7c0ff2..b86a8a1 100644
|
|
|
6ae9ed |
--- a/tests/qemuxml2argvtest.c
|
|
|
6ae9ed |
+++ b/tests/qemuxml2argvtest.c
|
|
|
6ae9ed |
@@ -1730,6 +1730,9 @@ mymain(void)
|
|
|
6ae9ed |
DO_TEST_PARSE_ERROR("pci-expander-bus-bad-machine",
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_PXB);
|
|
|
6ae9ed |
+ DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus",
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_PXB);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
DO_TEST("pcie-expander-bus",
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
6ae9ed |
@@ -1745,6 +1748,11 @@ mymain(void)
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM,
|
|
|
6ae9ed |
QEMU_CAPS_DEVICE_PXB_PCIE);
|
|
|
6ae9ed |
+ DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus",
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_IOH3420,
|
|
|
6ae9ed |
+ QEMU_CAPS_DEVICE_PXB_PCIE);
|
|
|
6ae9ed |
|
|
|
6ae9ed |
DO_TEST("hostdev-scsi-lsi",
|
|
|
6ae9ed |
QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI,
|
|
|
6ae9ed |
--
|
|
|
6ae9ed |
2.9.2
|
|
|
6ae9ed |
|