[PATCH v3 06/18] qemu: use virDomainPCIAddressReserveNextAddr in qemuDomainAssignDevicePCISlots

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



instead of calling virDomainPCIAddressGetNextSlot() (which I want to
turn into a local static in domain_addr.c).
---
 src/qemu/qemu_domain_address.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 7f86c32..5a19f0b 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -1256,7 +1256,6 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 {
     size_t i, j;
     virDomainPCIConnectFlags flags = 0; /* initialize to quiet gcc warning */
-    virPCIDeviceAddress tmp_addr;
 
     /* PCI controllers */
     for (i = 0; i < def->ncontrollers; i++) {
@@ -1360,7 +1359,6 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             virPCIDeviceAddress addr = {0};
             bool foundAddr = false;
 
-            memset(&tmp_addr, 0, sizeof(tmp_addr));
             for (j = 0; j < def->ncontrollers; j++) {
                 if (IS_USB2_CONTROLLER(def->controllers[j]) &&
                     def->controllers[j]->idx == cont->idx &&
@@ -1390,26 +1388,23 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
                 break;
             }
 
-            if (!foundAddr) {
-                /* This is the first part of the controller, so need
-                 * to find a free slot & then reserve a function */
-                if (virDomainPCIAddressGetNextSlot(addrs, &tmp_addr, flags) < 0)
+            if (foundAddr) {
+                /* Reserve this function on the slot we found */
+                if (virDomainPCIAddressReserveAddr(addrs, &addr, flags,
+                                                   false, true) < 0)
                     goto error;
 
-                addr.bus = tmp_addr.bus;
-                addr.slot = tmp_addr.slot;
+                cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
+                cont->info.addr.pci = addr;
+            } else {
+                /* This is the first part of the controller, so need
+                 * to find a free slot & then reserve this function */
+                if (virDomainPCIAddressReserveNextAddr(addrs, &cont->info, flags,
+                                                       addr.function, false) < 0)
+                    goto error;
 
-                addrs->lastaddr = addr;
-                addrs->lastaddr.function = 0;
-                addrs->lastaddr.multi = VIR_TRISTATE_SWITCH_ABSENT;
+                cont->info.addr.pci.multi = addr.multi;
             }
-            /* Finally we can reserve the slot+function */
-            if (virDomainPCIAddressReserveAddr(addrs, &addr, flags,
-                                               false, foundAddr) < 0)
-                goto error;
-
-            cont->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
-            cont->info.addr.pci = addr;
         } else {
             if (virDomainPCIAddressReserveNextSlot(addrs, &cont->info, flags) < 0)
                 goto error;
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]