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

[libvirt] [PATCH] Reusing the result of virArchFromHost instead of calling it multiple times



Signed-off-by: Tal Kain <tal kain ravellosystems com>
---
 src/qemu/qemu_capabilities.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 50712b0..b235059 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -860,8 +860,8 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
 {
     virCapsPtr caps;
     int i;
-
-    if ((caps = virCapabilitiesNew(virArchFromHost(),
+    virArch hostarch = virArchFromHost();
+    if ((caps = virCapabilitiesNew(hostarch,
                                    1, 1)) == NULL)
         goto error;
 
@@ -874,7 +874,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
         VIR_WARN("Failed to query host NUMA topology, disabling NUMA capabilities");
     }
 
-    if (virQEMUCapsInitCPU(caps, virArchFromHost()) < 0)
+    if (virQEMUCapsInitCPU(caps, hostarch) < 0)
         VIR_WARN("Failed to get host CPU");
 
     /* Add the power management features of the host */
@@ -891,7 +891,7 @@ virCapsPtr virQEMUCapsInit(virQEMUCapsCachePtr cache)
      */
     for (i = 0 ; i < VIR_ARCH_LAST ; i++)
         if (virQEMUCapsInitGuest(caps, cache,
-                                 virArchFromHost(),
+                                 hostarch,
                                  i) < 0)
             goto error;
 
@@ -1639,13 +1639,14 @@ int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
     if (*version > 0)
         return 0;
 
+    virArch hostarch = virArchFromHost();
     if ((binary = virCapabilitiesDefaultGuestEmulator(caps,
                                                       "hvm",
-                                                      virArchFromHost(),
+                                                      hostarch,
                                                       "qemu")) == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("Cannot find suitable emulator for %s"),
-                       virArchToString(virArchFromHost()));
+                       virArchToString(hostarch));
         return -1;
     }
 
-- 
1.7.9.5


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