
On 22.04.2013 20:43, Ján Tomko wrote:
Add a "dry run" address allocation to figure out how many bridges will be needed for all the devices without explicit addresses.
Auto-add just enough bridges to put all the devices on, or up to the bridge with the largest specified index. --- src/conf/domain_conf.c | 26 ++- src/qemu/qemu_command.c | 211 +++++++++++++++++---- src/qemu/qemu_command.h | 4 +- tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml | 210 ++++++++++++++++++++ tests/qemuxml2xmltest.c | 1 + 5 files changed, 411 insertions(+), 41 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-bridge.xml
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 3787ff1..ec7d0e6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c
@@ -1519,41 +1609,58 @@ void qemuDomainPCIAddressSetFree(qemuDomainPCIAddressSetPtr addrs) VIR_FREE(addrs); }
- static int qemuDomainPCIAddressGetNextSlot(qemuDomainPCIAddressSetPtr addrs, virDevicePCIAddressPtr next_addr) { - virDevicePCIAddress tmp_addr = addrs->lastaddr; - int i; - char *addr; + virDevicePCIAddress a = addrs->lastaddr;
- tmp_addr.slot++; - for (i = 0; i < QEMU_PCI_ADDRESS_SLOT_LAST; i++, tmp_addr.slot++) { - if (QEMU_PCI_ADDRESS_SLOT_LAST <= tmp_addr.slot) { - tmp_addr.slot = 0; - } + if (addrs->nbuses == 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("No PCI buses available")); + return -1; + }
- if (!(addr = qemuPCIAddressAsString(&tmp_addr))) - return -1; + /* Start the search at the last used bus and slot */ + for (a.slot++; a.bus < addrs->nbuses; a.bus++) { + for ( ; a.slot < QEMU_PCI_ADDRESS_SLOT_LAST; a.slot++) {
I know I am too late, but this causes 'make syntax-check' fail. I've just pushed trivial patch for that.
+ if (!qemuDomainPCIAddressSlotInUse(addrs, &a)) + goto success;
Michal