Rewrite way QEMU PCI addresses are allocated

The current QEMU code allocates PCI addresses incrementally starting
at 4. This is not satisfactory because the user may have given some
addresses in their XML config, which need to be skipped over when
allocating addresses to remaining devices.

It is thus neccessary to maintain a list of already allocated PCI
addresses and then only allocate ones that remain unused. This is
also required for domain device hotplug to work properly later.

* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Add APIs for creating
  list of existing PCI addresses, and allocating new addresses.
  Refactor address assignment to use this code
* src/qemu/qemu_driver.c: Pull PCI address assignment up into the
  qemuStartVMDaemon() method, as a prelude to moving it into the
  'define' method. Update list of allocated addresses when connecting
  to a running VM at daemon startup.
* tests/qemuxml2argvtest.c, tests/qemuargv2xmltest.c,
  tests/qemuxml2xmltest.c: Remove USB product test since all
  passthrough is done based on address
* tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args,
  tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.xml: Kil
  unused data files
This commit is contained in:
Daniel P. Berrange
2010-01-27 17:03:54 +00:00
parent 3fdef8cfca
commit 9258ec0a2e
8 changed files with 246 additions and 70 deletions

View File

@@ -62,6 +62,18 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (qemudCanonicalizeMachine(&driver, vmdef) < 0)
goto fail;
if (flags & QEMUD_CMD_FLAG_DEVICE) {
qemuDomainPCIAddressSetPtr pciaddrs;
if (!(pciaddrs = qemuDomainPCIAddressSetCreate(vmdef)))
goto fail;
if (qemuAssignDevicePCISlots(vmdef, pciaddrs) < 0)
goto fail;
qemuDomainPCIAddressSetFree(pciaddrs);
}
if (qemudBuildCommandLine(NULL, &driver,
vmdef, &monitor_chr, 0, flags,
&argv, &qenv,
@@ -303,7 +315,6 @@ mymain(int argc, char **argv)
DO_TEST("sound", 0);
DO_TEST("sound-device", QEMUD_CMD_FLAG_DEVICE);
DO_TEST("hostdev-usb-product", 0);
DO_TEST("hostdev-usb-address", 0);
DO_TEST("hostdev-usb-address-device", QEMUD_CMD_FLAG_DEVICE);
DO_TEST("hostdev-pci-address", QEMUD_CMD_FLAG_PCIDEVICE);