[libvirt] [PATCH 1/6] Cleanup qemu binary detection logic in qemudCapsInitGuest()

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

 



There's no need for the hasbase/hasaltbase confusion, just store the
first binary path found in a variable.

* src/qemu_conf.c: kill hasbase/hasaltbase logic in qemudCapsInitGuest()
---
 src/qemu_conf.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index 96f83cb..4bd511a 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -309,17 +309,18 @@ qemudCapsInitGuest(virCapsPtr caps,
                    int hvm) {
     virCapsGuestPtr guest;
     int i;
-    int hasbase = 0;
-    int hasaltbase = 0;
     int haskvm = 0;
     int haskqemu = 0;
     const char *kvmbin = NULL;
+    const char *binary = NULL;
 
     /* Check for existance of base emulator, or alternate base
      * which can be used with magic cpu choice
      */
-    hasbase = (access(info->binary, X_OK) == 0);
-    hasaltbase = (info->altbinary && access(info->altbinary, X_OK) == 0);
+    if (access(info->binary, X_OK) == 0)
+        binary = info->binary;
+    else if (info->altbinary && access(info->altbinary, X_OK) == 0)
+        binary = info->altbinary;
 
     /* Can use acceleration for KVM/KQEMU if
      *  - host & guest arches match
@@ -337,6 +338,8 @@ qemudCapsInitGuest(virCapsPtr caps,
                 access("/dev/kvm", F_OK) == 0) {
                 haskvm = 1;
                 kvmbin = kvmbins[i];
+                if (!binary)
+                    binary = kvmbin;
                 break;
             }
         }
@@ -345,8 +348,7 @@ qemudCapsInitGuest(virCapsPtr caps,
             haskqemu = 1;
     }
 
-
-    if (!hasbase && !hasaltbase && !haskvm)
+    if (!binary)
         return 0;
 
     /* We register kvm as the base emulator too, since we can
@@ -355,8 +357,7 @@ qemudCapsInitGuest(virCapsPtr caps,
                                          hvm ? "hvm" : "xen",
                                          info->arch,
                                          info->wordsize,
-                                         (hasbase ? info->binary :
-                                          (hasaltbase ? info->altbinary : kvmbin)),
+                                         binary,
                                          NULL,
                                          info->nmachines,
                                          info->machines)) == NULL)
-- 
1.6.2.5

--
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]