[PATCH v4 11/25] [ACKED] qemu: replace calls to virDomainPCIAddressReserveNext*() with static function

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

 



An upcoming commit will remove the "flag" argument from all the calls
to reserve the next available address|slot, but I don't want to change
the arguments in the hypervisor-agnostic
virDomainPCIAddressReserveNext*() functions, so this patch places a
simple qemu-specific wrapper around those functions - the new
functions don't take a flags arg, but grab it from the device's
info->pciConnectFlags.
---
Change: realigned/reformatted

 src/qemu/qemu_domain_address.c | 96 ++++++++++++++++++++++++++----------------
 1 file changed, 59 insertions(+), 37 deletions(-)

diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index fa52383..b4ea906 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -406,6 +406,27 @@ qemuDomainAssignARMVirtioMMIOAddresses(virDomainDefPtr def,
 
 
 static int
+qemuDomainPCIAddressReserveNextAddr(virDomainPCIAddressSetPtr addrs,
+                                    virDomainDeviceInfoPtr dev,
+                                    virDomainPCIConnectFlags flags,
+                                    unsigned int function,
+                                    bool reserveEntireSlot)
+{
+    return virDomainPCIAddressReserveNextAddr(addrs, dev, flags,
+                                              function, reserveEntireSlot);
+}
+
+
+static int
+qemuDomainPCIAddressReserveNextSlot(virDomainPCIAddressSetPtr addrs,
+                                    virDomainDeviceInfoPtr dev,
+                                    virDomainPCIConnectFlags flags)
+{
+    return qemuDomainPCIAddressReserveNextAddr(addrs, dev, flags, 0, true);
+}
+
+
+static int
 qemuDomainCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
                             virDomainDeviceDefPtr device,
                             virDomainDeviceInfoPtr info,
@@ -691,7 +712,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
 
             if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
                 if (qemuDeviceVideoUsable) {
-                    if (virDomainPCIAddressReserveNextSlot(addrs,
+                    if (qemuDomainPCIAddressReserveNextSlot(addrs,
                                                            &primaryVideo->info,
                                                            flags) < 0)
                         goto cleanup;
@@ -882,7 +903,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
 
             if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) {
                 if (qemuDeviceVideoUsable) {
-                    if (virDomainPCIAddressReserveNextSlot(addrs,
+                    if (qemuDomainPCIAddressReserveNextSlot(addrs,
                                                            &primaryVideo->info,
                                                            flags) < 0)
                         goto cleanup;
@@ -919,7 +940,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr def,
                       " device will not be possible without manual"
                       " intervention");
             virResetLastError();
-        } else if (virDomainPCIAddressReserveSlot(addrs, &tmp_addr, flags) < 0) {
+        } else if (virDomainPCIAddressReserveSlot(addrs,
+                                                  &tmp_addr, flags) < 0) {
             goto cleanup;
         }
     }
@@ -1023,8 +1045,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
              * controller/bus to connect it to on the upstream side.
              */
             flags = virDomainPCIControllerModelToConnectType(model);
-            if (virDomainPCIAddressReserveNextSlot(addrs,
-                                                   &cont->info, flags) < 0) {
+            if (qemuDomainPCIAddressReserveNextSlot(addrs,
+                                                    &cont->info, flags) < 0) {
                 goto error;
             }
         }
@@ -1043,8 +1065,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
 
         /* Only support VirtIO-9p-pci so far. If that changes,
          * we might need to skip devices here */
-        if (virDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1060,7 +1082,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             !virDeviceInfoPCIAddressWanted(&net->info)) {
             continue;
         }
-        if (virDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &net->info, flags) < 0)
             goto error;
     }
 
@@ -1076,7 +1098,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             sound->model == VIR_DOMAIN_SOUND_MODEL_USB)
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &sound->info, flags) < 0)
             goto error;
     }
 
@@ -1152,17 +1174,18 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             } 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) {
+                if (qemuDomainPCIAddressReserveNextAddr(addrs,
+                                                        &cont->info, flags,
+                                                        addr.function,
+                                                        false) < 0) {
                     goto error;
                 }
 
                 cont->info.addr.pci.multi = addr.multi;
             }
         } else {
-            if (virDomainPCIAddressReserveNextSlot(addrs,
-                                                   &cont->info, flags) < 0) {
+            if (qemuDomainPCIAddressReserveNextSlot(addrs,
+                                                    &cont->info, flags) < 0) {
                 goto error;
             }
         }
@@ -1195,8 +1218,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             goto error;
         }
 
-        if (virDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1208,9 +1231,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs,
-                                               def->hostdevs[i]->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, def->hostdevs[i]->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1218,9 +1240,9 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
     if (def->memballoon &&
         def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
         virDeviceInfoPCIAddressWanted(&def->memballoon->info)) {
-        if (virDomainPCIAddressReserveNextSlot(addrs,
-                                               &def->memballoon->info,
-                                               flags) < 0)
+
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->memballoon->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1230,8 +1252,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             !virDeviceInfoPCIAddressWanted(&def->rngs[i]->info))
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs,
-                                               &def->rngs[i]->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->rngs[i]->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1239,8 +1261,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
     if (def->watchdog &&
         def->watchdog->model == VIR_DOMAIN_WATCHDOG_MODEL_I6300ESB &&
         virDeviceInfoPCIAddressWanted(&def->watchdog->info)) {
-        if (virDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1248,16 +1270,16 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
      * assigned address. */
     if (def->nvideos > 0 &&
         virDeviceInfoPCIAddressWanted(&def->videos[0]->info)) {
-        if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[0]->info,
+                                                flags) < 0)
             goto error;
     }
 
     for (i = 1; i < def->nvideos; i++) {
         if (!virDeviceInfoPCIAddressWanted(&def->videos[i]->info))
             continue;
-        if (virDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
-                                               flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
+                                                flags) < 0)
             goto error;
     }
 
@@ -1266,8 +1288,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
         if (!virDeviceInfoPCIAddressWanted(&def->shmems[i]->info))
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs,
-                                               &def->shmems[i]->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->shmems[i]->info,
+                                                flags) < 0)
             goto error;
     }
     for (i = 0; i < def->ninputs; i++) {
@@ -1275,8 +1297,8 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             !virDeviceInfoPCIAddressWanted(&def->inputs[i]->info))
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs,
-                                               &def->inputs[i]->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->inputs[i]->info,
+                                                flags) < 0)
             goto error;
     }
     for (i = 0; i < def->nparallels; i++) {
@@ -1289,7 +1311,7 @@ qemuDomainAssignDevicePCISlots(virDomainDefPtr def,
             !virDeviceInfoPCIAddressWanted(&chr->info))
             continue;
 
-        if (virDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &chr->info, flags) < 0)
             goto error;
     }
     for (i = 0; i < def->nchannels; i++) {
@@ -1486,7 +1508,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
          */
         if (!buses_reserved &&
             !qemuDomainMachineIsVirt(def) &&
-            virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
+            qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
             goto cleanup;
 
         if (qemuDomainAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
@@ -1501,7 +1523,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
                 goto cleanup;
             /* If we added a new bridge, we will need one more address */
             if (rv > 0 &&
-                virDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
+                qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
                 goto cleanup;
         }
         nbuses = addrs->nbuses;
-- 
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]