render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
43fe83
From 16e88f683d1a8d41596202d1dfa3d3c6b52655c5 Mon Sep 17 00:00:00 2001
43fe83
Message-Id: <16e88f683d1a8d41596202d1dfa3d3c6b52655c5.1377873636.git.jdenemar@redhat.com>
43fe83
From: Laine Stump <laine@laine.org>
43fe83
Date: Tue, 6 Aug 2013 13:23:19 -0600
43fe83
Subject: [PATCH] qemu: rename some functions in qemu_command.c
43fe83
43fe83
This patch is part of the resolution to:
43fe83
43fe83
   https://bugzilla.redhat.com/show_bug.cgi?id=819968
43fe83
43fe83
* qemuDomainPCIAddressSetNextAddr
43fe83
43fe83
The name of this function was confusing because 1) other functions in
43fe83
the file that end in "Addr" are only operating on a single function of
43fe83
one PCI slot, not the entire slot, while functions that do something
43fe83
with the entire slot end in "Slot", and 2) it didn't contain a verb
43fe83
describing what it is doing (the "Set" refers to the set that contains
43fe83
all PCI buses in the system, used to keep track of which slots in
43fe83
which buses are already reserved for use).
43fe83
43fe83
It is now renamed to qemuDomainPCIAddressReserveNextSlot, which more
43fe83
clearly describes what it is doing. Arguably, it could have been
43fe83
changed to qemuDomainPCIAddressSetReserveNextSlot, but 1) the word
43fe83
"set" is confusing in this context because it could be intended as a
43fe83
verb or as a noun, and 2) most other functions that operate on a
43fe83
single slot or address within this set are also named
43fe83
qemuDomainPCIAddress... rather than qemuDomainPCIAddressSet... Only
43fe83
the Create, Free, and Grow functions for an address set (which modify the
43fe83
entire set, not just one element) use "Set" in their name.
43fe83
43fe83
* qemuPCIAddressAsString, qemuPCIAddressValidate
43fe83
43fe83
All the other functions in this set are named
43fe83
qemuDomainPCIAddressxxxxx, so I renamed these to be consistent.
43fe83
(cherry picked from commit 29e3a1df474aeb35b5eeca4930e7748cd2664472)
43fe83
---
43fe83
 src/qemu/qemu_command.c | 78 ++++++++++++++++++++++++++++++-------------------
43fe83
 src/qemu/qemu_command.h |  6 ++--
43fe83
 2 files changed, 51 insertions(+), 33 deletions(-)
43fe83
43fe83
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
43fe83
index aa3a2fd..4345456 100644
43fe83
--- a/src/qemu/qemu_command.c
43fe83
+++ b/src/qemu/qemu_command.c
43fe83
@@ -1439,9 +1439,9 @@ struct _qemuDomainPCIAddressSet {
43fe83
  * with the specified PCI address set.
43fe83
  */
43fe83
 static bool
43fe83
-qemuPCIAddressValidate(qemuDomainPCIAddressSetPtr addrs ATTRIBUTE_UNUSED,
43fe83
-                       virDevicePCIAddressPtr addr,
43fe83
-                       qemuDomainPCIConnectFlags flags)
43fe83
+qemuDomainPCIAddressValidate(qemuDomainPCIAddressSetPtr addrs,
43fe83
+                             virDevicePCIAddressPtr addr,
43fe83
+                             qemuDomainPCIConnectFlags flags)
43fe83
 {
43fe83
     qemuDomainPCIAddressBusPtr bus;
43fe83
 
43fe83
@@ -1578,7 +1578,7 @@ qemuDomainPCIAddressSetGrow(qemuDomainPCIAddressSetPtr addrs,
43fe83
 
43fe83
 
43fe83
 static char *
43fe83
-qemuPCIAddressAsString(virDevicePCIAddressPtr addr)
43fe83
+qemuDomainPCIAddressAsString(virDevicePCIAddressPtr addr)
43fe83
 {
43fe83
     char *str;
43fe83
 
43fe83
@@ -1648,10 +1648,10 @@ qemuCollectPCIAddress(virDomainDefPtr def ATTRIBUTE_UNUSED,
43fe83
      * that the bus is of the correct type for the device (via
43fe83
      * comparing the flags).
43fe83
      */
43fe83
-    if (!qemuPCIAddressValidate(addrs, addr, flags))
43fe83
+    if (!qemuDomainPCIAddressValidate(addrs, addr, flags))
43fe83
         return -1;
43fe83
 
43fe83
-    if (!(str = qemuPCIAddressAsString(addr)))
43fe83
+    if (!(str = qemuDomainPCIAddressAsString(addr)))
43fe83
         goto cleanup;
43fe83
 
43fe83
     /* check if already in use */
43fe83
@@ -1729,7 +1729,7 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
43fe83
             if (qemuAssignDevicePCISlots(def, qemuCaps, addrs) < 0)
43fe83
                 goto cleanup;
43fe83
             /* Reserve 1 extra slot for a (potential) bridge */
43fe83
-            if (qemuDomainPCIAddressSetNextAddr(addrs, &info, flags) < 0)
43fe83
+            if (qemuDomainPCIAddressReserveNextSlot(addrs, &info, flags) < 0)
43fe83
                 goto cleanup;
43fe83
 
43fe83
             for (i = 1; i < addrs->nbuses; i++) {
43fe83
@@ -1740,7 +1740,8 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def,
43fe83
                          i, bus->model)) < 0)
43fe83
                     goto cleanup;
43fe83
                 /* If we added a new bridge, we will need one more address */
43fe83
-                if (rv > 0 && qemuDomainPCIAddressSetNextAddr(addrs, &info, flags) < 0)
43fe83
+                if (rv > 0 && qemuDomainPCIAddressReserveNextSlot(addrs, &info,
43fe83
+                                                                  flags) < 0)
43fe83
                         goto cleanup;
43fe83
             }
43fe83
             nbuses = addrs->nbuses;
43fe83
@@ -1881,7 +1882,7 @@ qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
     if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
43fe83
         return -1;
43fe83
 
43fe83
-    if (!(str = qemuPCIAddressAsString(addr)))
43fe83
+    if (!(str = qemuDomainPCIAddressAsString(addr)))
43fe83
         return -1;
43fe83
 
43fe83
     VIR_DEBUG("Reserving PCI addr %s", str);
43fe83
@@ -1923,7 +1924,7 @@ qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
43fe83
     if (addrs->dryRun && qemuDomainPCIAddressSetGrow(addrs, addr, flags) < 0)
43fe83
         return -1;
43fe83
 
43fe83
-    if (!(str = qemuPCIAddressAsString(addr)))
43fe83
+    if (!(str = qemuDomainPCIAddressAsString(addr)))
43fe83
         return -1;
43fe83
 
43fe83
     VIR_DEBUG("Reserving PCI slot %s", str);
43fe83
@@ -1959,12 +1960,12 @@ int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
             return -1;
43fe83
         }
43fe83
 
43fe83
-        if (!qemuPCIAddressValidate(addrs, &dev->addr.pci, flags))
43fe83
+        if (!qemuDomainPCIAddressValidate(addrs, &dev->addr.pci, flags))
43fe83
             return -1;
43fe83
 
43fe83
         ret = qemuDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
43fe83
     } else {
43fe83
-        ret = qemuDomainPCIAddressSetNextAddr(addrs, dev, flags);
43fe83
+        ret = qemuDomainPCIAddressReserveNextSlot(addrs, dev, flags);
43fe83
     }
43fe83
     return ret;
43fe83
 }
43fe83
@@ -1986,7 +1987,7 @@ qemuDomainPCIAddressReleaseSlot(qemuDomainPCIAddressSetPtr addrs,
43fe83
      */
43fe83
     qemuDomainPCIConnectFlags flags = QEMU_PCI_CONNECT_TYPES_MASK;
43fe83
 
43fe83
-    if (!qemuPCIAddressValidate(addrs, addr, flags))
43fe83
+    if (!qemuDomainPCIAddressValidate(addrs, addr, flags))
43fe83
         return -1;
43fe83
 
43fe83
     addrs->buses[addr->bus].slots[addr->slot] = 0;
43fe83
@@ -2059,9 +2060,9 @@ success:
43fe83
 }
43fe83
 
43fe83
 int
43fe83
-qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
-                                virDomainDeviceInfoPtr dev,
43fe83
-                                qemuDomainPCIConnectFlags flags)
43fe83
+qemuDomainPCIAddressReserveNextSlot(qemuDomainPCIAddressSetPtr addrs,
43fe83
+                                    virDomainDeviceInfoPtr dev,
43fe83
+                                    qemuDomainPCIConnectFlags flags)
43fe83
 {
43fe83
     virDevicePCIAddress addr;
43fe83
     if (qemuDomainPCIAddressGetNextSlot(addrs, &addr, flags) < 0)
43fe83
@@ -2188,14 +2189,16 @@ qemuValidateDevicePCISlotsPIIX3(virDomainDefPtr def,
43fe83
             primaryVideo->info.addr.pci.function = 0;
43fe83
             addrptr = &primaryVideo->info.addr.pci;
43fe83
 
43fe83
-            if (!qemuPCIAddressValidate(addrs, addrptr, flags))
43fe83
+            if (!qemuDomainPCIAddressValidate(addrs, addrptr, flags))
43fe83
                 goto error;
43fe83
 
43fe83
             if (qemuDomainPCIAddressSlotInUse(addrs, addrptr)) {
43fe83
                 if (qemuDeviceVideoUsable) {
43fe83
                     virResetLastError();
43fe83
-                    if (qemuDomainPCIAddressSetNextAddr(addrs, &primaryVideo->info, flags) < 0)
43fe83
-                        goto error;;
43fe83
+                    if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                            &primaryVideo->info,
43fe83
+                                                            flags) < 0)
43fe83
+                        goto error;
43fe83
                 } else {
43fe83
                     virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
43fe83
                                    _("PCI address 0:0:2.0 is in use, "
43fe83
@@ -2296,7 +2299,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
                 continue;
43fe83
             if (def->controllers[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
43fe83
                 continue;
43fe83
-            if (qemuDomainPCIAddressSetNextAddr(addrs, &def->controllers[i]->info, flags) < 0)
43fe83
+            if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                    &def->controllers[i]->info,
43fe83
+                                                    flags) < 0)
43fe83
                 goto error;
43fe83
         }
43fe83
     }
43fe83
@@ -2307,7 +2312,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
 
43fe83
         /* Only support VirtIO-9p-pci so far. If that changes,
43fe83
          * we might need to skip devices here */
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->fss[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->fss[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2321,7 +2327,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
             (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) {
43fe83
             continue;
43fe83
         }
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->nets[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->nets[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2334,7 +2341,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
             def->sounds[i]->model == VIR_DOMAIN_SOUND_MODEL_PCSPK)
43fe83
             continue;
43fe83
 
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->sounds[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->sounds[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2409,7 +2417,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
             def->controllers[i]->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI;
43fe83
             def->controllers[i]->info.addr.pci = addr;
43fe83
         } else {
43fe83
-            if (qemuDomainPCIAddressSetNextAddr(addrs, &def->controllers[i]->info, flags) < 0)
43fe83
+            if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                    &def->controllers[i]->info,
43fe83
+                                                    flags) < 0)
43fe83
                 goto error;
43fe83
         }
43fe83
     }
43fe83
@@ -2434,7 +2444,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
             goto error;
43fe83
         }
43fe83
 
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->disks[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->disks[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2446,7 +2457,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
             def->hostdevs[i]->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
43fe83
             continue;
43fe83
 
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, def->hostdevs[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                def->hostdevs[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2454,7 +2467,9 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
     if (def->memballoon &&
43fe83
         def->memballoon->model == VIR_DOMAIN_MEMBALLOON_MODEL_VIRTIO &&
43fe83
         def->memballoon->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->memballoon->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                &def->memballoon->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2462,7 +2477,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
     if (def->rng &&
43fe83
         def->rng->model == VIR_DOMAIN_RNG_MODEL_VIRTIO &&
43fe83
         def->rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->rng->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs,
43fe83
+                                                &def->rng->info, flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2470,7 +2486,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
     if (def->watchdog &&
43fe83
         def->watchdog->model != VIR_DOMAIN_WATCHDOG_MODEL_IB700 &&
43fe83
         def->watchdog->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) {
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->watchdog->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->watchdog->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
 
43fe83
@@ -2483,7 +2500,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def,
43fe83
         }
43fe83
         if (def->videos[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)
43fe83
             continue;
43fe83
-        if (qemuDomainPCIAddressSetNextAddr(addrs, &def->videos[i]->info, flags) < 0)
43fe83
+        if (qemuDomainPCIAddressReserveNextSlot(addrs, &def->videos[i]->info,
43fe83
+                                                flags) < 0)
43fe83
             goto error;
43fe83
     }
43fe83
     for (i = 0; i < def->ninputs; i++) {
43fe83
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
43fe83
index 2b02d6e..c9f1600 100644
43fe83
--- a/src/qemu/qemu_command.h
43fe83
+++ b/src/qemu/qemu_command.h
43fe83
@@ -254,9 +254,9 @@ int qemuDomainPCIAddressReserveSlot(qemuDomainPCIAddressSetPtr addrs,
43fe83
 int qemuDomainPCIAddressReserveAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
                                     virDevicePCIAddressPtr addr,
43fe83
                                     qemuDomainPCIConnectFlags flags);
43fe83
-int qemuDomainPCIAddressSetNextAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
-                                    virDomainDeviceInfoPtr dev,
43fe83
-                                    qemuDomainPCIConnectFlags flags);
43fe83
+int qemuDomainPCIAddressReserveNextSlot(qemuDomainPCIAddressSetPtr addrs,
43fe83
+                                        virDomainDeviceInfoPtr dev,
43fe83
+                                        qemuDomainPCIConnectFlags flags);
43fe83
 int qemuDomainPCIAddressEnsureAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
                                    virDomainDeviceInfoPtr dev);
43fe83
 int qemuDomainPCIAddressReleaseAddr(qemuDomainPCIAddressSetPtr addrs,
43fe83
-- 
43fe83
1.8.3.2
43fe83