We can as well generate the number of buses inside that function. Fewer parameters will be useful when recalculating the pci address set on demand. --- src/qemu/qemu_domain_address.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index f916df2..ade4b64 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -924,14 +924,24 @@ qemuDomainValidateDevicePCISlotsChipsets(virDomainDefPtr def, static virDomainPCIAddressSetPtr qemuDomainPCIAddressSetCreate(virDomainDefPtr def, - unsigned int nbuses, virQEMUCapsPtr qemuCaps, bool dryRun, bool assign) { virDomainPCIAddressSetPtr addrs; + int max_idx = -1; + int nbuses = 0; size_t i; + for (i = 0; i < def->ncontrollers; i++) { + if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) { + if ((int) def->controllers[i]->idx > max_idx) + max_idx = def->controllers[i]->idx; + } + } + + nbuses = max_idx + 1; + if ((addrs = virDomainPCIAddressSetAlloc(nbuses)) == NULL) return NULL; @@ -1500,7 +1510,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, virDomainDeviceInfo info; /* 1st pass to figure out how many PCI bridges we need */ - if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, qemuCaps, + if (!(addrs = qemuDomainPCIAddressSetCreate(def, qemuCaps, true, true))) goto cleanup; @@ -1537,7 +1547,6 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0) goto cleanup; } - nbuses = addrs->nbuses; virDomainPCIAddressSetFree(addrs); addrs = NULL; @@ -1549,7 +1558,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, } if (qemuDomainSupportsPCI(def, qemuCaps)) { - if (!(addrs = qemuDomainPCIAddressSetCreate(def, nbuses, qemuCaps, + if (!(addrs = qemuDomainPCIAddressSetCreate(def, qemuCaps, false, true))) goto cleanup; -- 1.9.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list