[libvirt] [PATCH 1/2] qemu: switch PCI address alocation to use virDevicePCIAddress

Ján Tomko jtomko at redhat.com
Wed Feb 20 13:10:34 UTC 2013


On 02/19/13 04:02, Laine Stump wrote:
> There were a lot of mechanical changes in this. Assuming that you've run
> make syntax-check, and tried out several cases of defining new domains
> with devices that have no pci address specified (with satisfactory
> results!), and that you fix the two small nits I found above, then ACK.
>

Thanks and pushed now.

I've tried a few different combinations as well as hotplugging to see if
the cleanup cycle for qemuDomainPCIAddressReserveSlot works.

This is the Thunderbird-mangled diff of the fixes for those two nits:

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b50e779..dee493f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1197,7 +1197,7 @@ int
qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
 {
     virDevicePCIAddress tmp_addr = *addr;
     unsigned int *func = &tmp_addr.function;
-    int i;
+    unsigned int last;

     for (*func = 0; *func < QEMU_PCI_ADDRESS_LAST_FUNCTION; (*func)++) {
         if (qemuDomainPCIAddressReserveAddr(addrs, &tmp_addr) < 0)
@@ -1207,10 +1207,8 @@ int
qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
     return 0;

 cleanup:
-    for (i = *func; i >= 0; i--) {
-        *func = i;
+    for (last = *func, *func = 0; *func < last; (*func)++)
         qemuDomainPCIAddressReleaseAddr(addrs, &tmp_addr);
-    }
     return -1;
 }

@@ -1479,7 +1477,7 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
             if (qemuDomainPCIAddressCheckSlot(addrs, addrptr) < 0) {
                 if (qemuDeviceVideoUsable) {
                     virResetLastError();
-                    if
(qemuDomainPCIAddressSetNextAddr(addrs,&primaryVideo->info) < 0)
+                    if (qemuDomainPCIAddressSetNextAddr(addrs,
&primaryVideo->info) < 0)
                         goto error;
                 } else {
                     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",




More information about the libvir-list mailing list