From 83d86e348ef35160c535dfb6b5af774d65eaf29d Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 18 Sep 2018 16:49:40 +0200 Subject: [PATCH] qemu: Stop looking after finding the first binary 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 --- src/qemu/qemu_capabilities.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e51b07099a..a911ac41c2 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -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; }