]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Stop looking after finding the first binary
authorAndrea Bolognani <abologna@redhat.com>
Tue, 18 Sep 2018 14:49:40 +0000 (16:49 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 21 Sep 2018 13:53:48 +0000 (15:53 +0200)
When the guest is native, we are currently looking at
potential KVM binaries regardless of whether or not we have
already located a QEMU binary suitable to run the guest.

This made sense back when KVM support was not part of QEMU
proper, but these days the KVM binaries are in most cases
just trivial wrapper scripts around the native QEMU binary
so it doesn't make sense to poke at them unless they're
the only binaries on the system, such as when running on
RHEL.

This will allow us to simplify both virQEMUCapsInitGuest()
and virQEMUCapsInitGuestFromBinary().

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
src/qemu/qemu_capabilities.c

index e51b07099adeec5296df39ef40af14587356e16a..a911ac41c27d57a6bf29fb76b925bd5c2ba77513 100644 (file)
@@ -747,10 +747,8 @@ virQEMUCapsInitGuest(virCapsPtr caps,
                      virArch guestarch)
 {
     size_t i;
-    char *kvmbin = NULL;
     char *binary = NULL;
     virQEMUCapsPtr qemubinCaps = NULL;
-    virQEMUCapsPtr kvmbinCaps = NULL;
     int ret = -1;
 
     /* Check for existence of base emulator, or alternate base
@@ -766,7 +764,7 @@ virQEMUCapsInitGuest(virCapsPtr caps,
         }
     }
 
-    if (virQEMUCapsGuestIsNative(hostarch, guestarch)) {
+    if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) {
         const char *kvmbins[] = {
             "/usr/libexec/qemu-kvm", /* RHEL */
             "qemu-kvm", /* Fedora */
@@ -774,36 +772,28 @@ virQEMUCapsInitGuest(virCapsPtr caps,
         };
 
         for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) {
-            kvmbin = virFindFileInPath(kvmbins[i]);
+            binary = virFindFileInPath(kvmbins[i]);
 
-            if (!kvmbin)
+            if (!binary)
                 continue;
 
-            if (!(kvmbinCaps = virQEMUCapsCacheLookup(cache, kvmbin))) {
+            if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) {
                 virResetLastError();
-                VIR_FREE(kvmbin);
+                VIR_FREE(binary);
                 continue;
             }
 
-            if (!binary) {
-                binary = kvmbin;
-                qemubinCaps = kvmbinCaps;
-                kvmbin = NULL;
-                kvmbinCaps = NULL;
-            }
             break;
         }
     }
 
     ret = virQEMUCapsInitGuestFromBinary(caps,
                                          binary, qemubinCaps,
-                                         kvmbin, kvmbinCaps,
+                                         NULL, NULL,
                                          guestarch);
 
     VIR_FREE(binary);
-    VIR_FREE(kvmbin);
     virObjectUnref(qemubinCaps);
-    virObjectUnref(kvmbinCaps);
 
     return ret;
 }