qemu: Fix auto-adding PCI bridge when all slots are reserved

Commit 93c8ca tried to fix the issue with auto-adding of a PCI bridge
controller, but didn't work properly in all scenarios.

This patch provides a better fix of the issue when all slots on a PCI bus
are reserved by devices with user specified addresses and no additional
bridges need to be created.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1132900
This commit is contained in:
Erik Skultety 2015-01-23 13:17:42 +01:00 committed by Ján Tomko
parent a3ecd63e92
commit 5d6904b991

View File

@ -1910,6 +1910,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
int nbuses = 0;
size_t i;
int rv;
bool buses_reserved = true;
virDomainPCIConnectFlags flags = VIR_PCI_CONNECT_TYPE_PCI;
for (i = 0; i < def->ncontrollers; i++) {
@ -1932,17 +1934,20 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
if (qemuValidateDevicePCISlotsChipsets(def, qemuCaps, addrs) < 0)
goto cleanup;
if (qemuAssignDevicePCISlots(def, addrs) < 0)
for (i = 0; i < addrs->nbuses; i++) {
if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i]))
buses_reserved = false;
}
/* Reserve 1 extra slot for a (potential) bridge only if buses
* are not fully reserved yet
*/
if (!buses_reserved &&
virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
goto cleanup;
for (i = 0; i < addrs->nbuses; i++) {
if (!qemuDomainPCIBusFullyReserved(&addrs->buses[i])) {
/* Reserve 1 extra slot for a (potential) bridge */
if (virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
goto cleanup;
}
}
if (qemuAssignDevicePCISlots(def, addrs) < 0)
goto cleanup;
for (i = 1; i < addrs->nbuses; i++) {
virDomainPCIAddressBusPtr bus = &addrs->buses[i];