提交 045515d3 编写于 作者: A Andrea Bolognani

qemu: Use PHBs to fill holes in PCI bus numbering

PCI bus has to be numbered sequentially, and no index can be
missing, so libvirt will fill in the blanks automatically for
the user.

Up until now, it has done so using either pci-bridge, for machine
types based on legacy PCI, or pcie-root-port, for machine types
based on PCI Express. Neither choice is good for pSeries guests,
where PHBs (pci-root) should be used instead.
Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NLaine Stump <laine@laine.org>
上级 ca1c362a
...@@ -1097,10 +1097,14 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def, ...@@ -1097,10 +1097,14 @@ qemuDomainPCIAddressSetCreate(virDomainDefPtr def,
* that don't yet have a corresponding controller in the domain * that don't yet have a corresponding controller in the domain
* config. * config.
*/ */
if (hasPCIeRoot) if (qemuDomainIsPSeries(def)) {
/* pSeries guests should use PHBs (pci-root controllers) */
defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT;
} else if (hasPCIeRoot) {
defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT; defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT;
else } else {
defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE; defaultModel = VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE;
}
for (i = 1; i < addrs->nbuses; i++) { for (i = 1; i < addrs->nbuses; i++) {
...@@ -2160,7 +2164,13 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, ...@@ -2160,7 +2164,13 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
dev.data.controller = def->controllers[contIndex]; dev.data.controller = def->controllers[contIndex];
/* set connect flags so it will be properly addressed */ /* set connect flags so it will be properly addressed */
qemuDomainFillDevicePCIConnectFlags(def, &dev, qemuCaps, driver); qemuDomainFillDevicePCIConnectFlags(def, &dev, qemuCaps, driver);
if (qemuDomainPCIAddressReserveNextAddr(addrs,
/* Reserve an address for the controller. pci-root and pcie-root
* controllers don't plug into any other PCI controller, hence
* they should skip this step */
if (bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT &&
bus->model != VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT &&
qemuDomainPCIAddressReserveNextAddr(addrs,
&dev.data.controller->info) < 0) { &dev.data.controller->info) < 0) {
goto cleanup; goto cleanup;
} }
......
...@@ -19,4 +19,4 @@ server,nowait \ ...@@ -19,4 +19,4 @@ server,nowait \
-mon chardev=charmonitor,id=monitor,mode=readline \ -mon chardev=charmonitor,id=monitor,mode=readline \
-boot c \ -boot c \
-device spapr-pci-host-bridge,index=1,id=pci.2 \ -device spapr-pci-host-bridge,index=1,id=pci.2 \
-device pci-bridge,chassis_nr=1,id=pci.1,bus=pci.0,addr=0x1 -device spapr-pci-host-bridge,index=2,id=pci.1
...@@ -1767,7 +1767,6 @@ mymain(void) ...@@ -1767,7 +1767,6 @@ mymain(void)
DO_TEST("pseries-many-buses-2", DO_TEST("pseries-many-buses-2",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_VIRTIO_SCSI); QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("pseries-hostdevs-1", DO_TEST("pseries-hostdevs-1",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_NODEFCONFIG,
......
...@@ -23,10 +23,9 @@ ...@@ -23,10 +23,9 @@
<target index='1'/> <target index='1'/>
</controller> </controller>
<controller type='usb' index='0' model='none'/> <controller type='usb' index='0' model='none'/>
<controller type='pci' index='1' model='pci-bridge'> <controller type='pci' index='1' model='pci-root'>
<model name='pci-bridge'/> <model name='spapr-pci-host-bridge'/>
<target chassisNr='1'/> <target index='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
</controller> </controller>
<memballoon model='none'/> <memballoon model='none'/>
<panic model='pseries'/> <panic model='pseries'/>
......
...@@ -686,7 +686,6 @@ mymain(void) ...@@ -686,7 +686,6 @@ mymain(void)
DO_TEST("pseries-many-buses-2", DO_TEST("pseries-many-buses-2",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_NODEFCONFIG,
QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE,
QEMU_CAPS_DEVICE_PCI_BRIDGE,
QEMU_CAPS_VIRTIO_SCSI); QEMU_CAPS_VIRTIO_SCSI);
DO_TEST("pseries-hostdevs-1", DO_TEST("pseries-hostdevs-1",
QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_NODEFCONFIG,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册