mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
conf: restrict where dmi-to-pci-bridge can be connected
libvirt had allowed a dmi-to-pci-bridge to be plugged in anywhere a normal PCIe endpoint can be connected, but this is wrong - it will only work if it's plugged into pcie-root (the PCIe root complex) or a pcie-expander-bus (the qemu device pxb-pcie). This patch adjusts the connection flags accordingly. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1363648
This commit is contained in:
parent
b70e54342b
commit
b70e3d0123
@ -58,15 +58,17 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
|
|||||||
*/
|
*/
|
||||||
return VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
|
return VIR_PCI_CONNECT_TYPE_PCI_DEVICE;
|
||||||
|
|
||||||
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
|
||||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
||||||
/* dmi-to-pci-bridge and pcie-expander-bus are treated like
|
/* pcie-expander-bus is treated like a standard PCIe endpoint
|
||||||
* PCIe devices (the part of pcie-expander-bus that is plugged
|
* device (the part of pcie-expander-bus that is plugged in
|
||||||
* in isn't the expander bus itself, but a companion device
|
* isn't the expander bus itself, but a companion device used
|
||||||
* used for setting it up).
|
* for setting it up).
|
||||||
*/
|
*/
|
||||||
return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
|
return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE;
|
||||||
|
|
||||||
|
case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE:
|
||||||
|
return VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE;
|
||||||
|
|
||||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
|
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT:
|
||||||
return VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT;
|
return VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT;
|
||||||
|
|
||||||
@ -133,6 +135,8 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr,
|
|||||||
connectStr = "pci-switch-upstream-port";
|
connectStr = "pci-switch-upstream-port";
|
||||||
} else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT) {
|
} else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT) {
|
||||||
connectStr = "pci-switch-downstream-port";
|
connectStr = "pci-switch-downstream-port";
|
||||||
|
} else if (devFlags & VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) {
|
||||||
|
connectStr = "dmi-to-pci-bridge";
|
||||||
} else {
|
} else {
|
||||||
/* this should never happen. If it does, there is a
|
/* this should never happen. If it does, there is a
|
||||||
* bug in the code that sets the flag bits for devices.
|
* bug in the code that sets the flag bits for devices.
|
||||||
@ -259,8 +263,9 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
|
|||||||
* user config *and* the particular device being attached also
|
* user config *and* the particular device being attached also
|
||||||
* allows it.
|
* allows it.
|
||||||
*/
|
*/
|
||||||
bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE
|
bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE |
|
||||||
| VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT);
|
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT |
|
||||||
|
VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE);
|
||||||
bus->minSlot = 1;
|
bus->minSlot = 1;
|
||||||
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
||||||
break;
|
break;
|
||||||
@ -291,8 +296,11 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus,
|
|||||||
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST;
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS:
|
||||||
/* single slot, no hotplug, only accepts pcie-root-port */
|
/* single slot, no hotplug, only accepts pcie-root-port or
|
||||||
bus->flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT;
|
* dmi-to-pci-bridge
|
||||||
|
*/
|
||||||
|
bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT |
|
||||||
|
VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE);
|
||||||
bus->minSlot = 0;
|
bus->minSlot = 0;
|
||||||
bus->maxSlot = 0;
|
bus->maxSlot = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -40,6 +40,7 @@ typedef enum {
|
|||||||
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 3,
|
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 3,
|
||||||
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 4,
|
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 4,
|
||||||
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 5,
|
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 5,
|
||||||
|
VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 6,
|
||||||
} virDomainPCIConnectFlags;
|
} virDomainPCIConnectFlags;
|
||||||
|
|
||||||
/* a combination of all bits that describe the type of connections
|
/* a combination of all bits that describe the type of connections
|
||||||
@ -49,7 +50,8 @@ typedef enum {
|
|||||||
(VIR_PCI_CONNECT_TYPE_PCI_DEVICE | VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | \
|
(VIR_PCI_CONNECT_TYPE_PCI_DEVICE | VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | \
|
||||||
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | \
|
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | \
|
||||||
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT | \
|
VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT | \
|
||||||
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT)
|
VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | \
|
||||||
|
VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE)
|
||||||
|
|
||||||
/* combination of all bits that could be used to connect a normal
|
/* combination of all bits that could be used to connect a normal
|
||||||
* endpoint device (i.e. excluding the connection possible between an
|
* endpoint device (i.e. excluding the connection possible between an
|
||||||
|
31
tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml
Normal file
31
tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>q35-test</name>
|
||||||
|
<uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='0-1'>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/libexec/qemu-kvm</emulator>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='dmi-to-pci-bridge'>
|
||||||
|
<model name='i82801b11-bridge'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pci-bridge'>
|
||||||
|
<model name='pci-bridge'/>
|
||||||
|
<target chassisNr='56'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'/>
|
||||||
|
<controller type='pci' index='4' model='dmi-to-pci-bridge'>
|
||||||
|
<address type='pci' bus='2' slot='3'/>
|
||||||
|
</controller>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
39
tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml
Normal file
39
tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>q35-test</name>
|
||||||
|
<uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static' cpuset='0-1'>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/libexec/qemu-kvm</emulator>
|
||||||
|
<disk type='block' device='disk'>
|
||||||
|
<source dev='/dev/HostVG/QEMUGuest1'/>
|
||||||
|
<target dev='sda' bus='sata'/>
|
||||||
|
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
|
||||||
|
</disk>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='dmi-to-pci-bridge'>
|
||||||
|
<model name='i82801b11-bridge'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pci-bridge'>
|
||||||
|
<model name='pci-bridge'/>
|
||||||
|
<target chassisNr='56'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'/>
|
||||||
|
<controller type='pci' index='4' model='dmi-to-pci-bridge'>
|
||||||
|
<address type='pci' bus='3'/>
|
||||||
|
</controller>
|
||||||
|
<video>
|
||||||
|
<model type='qxl' ram='65536' vram='32768' vgamem='8192' heads='1'/>
|
||||||
|
</video>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -1632,6 +1632,14 @@ mymain(void)
|
|||||||
QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
|
QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1,
|
||||||
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
|
QEMU_CAPS_DEVICE_VIDEO_PRIMARY,
|
||||||
QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
|
QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL);
|
||||||
|
DO_TEST_PARSE_ERROR("q35-dmi-bad-address1",
|
||||||
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_IOH3420);
|
||||||
|
DO_TEST_PARSE_ERROR("q35-dmi-bad-address2",
|
||||||
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE,
|
||||||
|
QEMU_CAPS_DEVICE_IOH3420);
|
||||||
DO_TEST("q35-pm-disable",
|
DO_TEST("q35-pm-disable",
|
||||||
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
QEMU_CAPS_DEVICE_PCI_BRIDGE,
|
||||||
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
|
QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI,
|
||||||
|
Loading…
Reference in New Issue
Block a user