Now that we have reduced the number of sensible options down to either the native QEMU binary or RHEL's qemu-kvm, we can make virQEMUCapsInitGuest() a bit simpler. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- src/qemu/qemu_capabilities.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index fd8badc60b..72fa19a2b7 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -746,7 +746,6 @@ virQEMUCapsInitGuest(virCapsPtr caps, virArch hostarch, virArch guestarch) { - size_t i; char *binary = NULL; virQEMUCapsPtr qemubinCaps = NULL; int ret = -1; @@ -756,6 +755,13 @@ virQEMUCapsInitGuest(virCapsPtr caps, */ binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch); + /* RHEL doesn't follow the usual naming for QEMU binaries and ships + * a single binary named qemu-kvm outside of $PATH instead */ + if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) { + if (VIR_STRDUP(binary, "/usr/libexec/qemu-kvm") < 0) + return -1; + } + /* Ignore binary if extracting version info fails */ if (binary) { if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) { @@ -764,27 +770,6 @@ virQEMUCapsInitGuest(virCapsPtr caps, } } - if (virQEMUCapsGuestIsNative(hostarch, guestarch) && !binary) { - const char *kvmbins[] = { - "/usr/libexec/qemu-kvm", /* RHEL */ - }; - - for (i = 0; i < ARRAY_CARDINALITY(kvmbins); ++i) { - binary = virFindFileInPath(kvmbins[i]); - - if (!binary) - continue; - - if (!(qemubinCaps = virQEMUCapsCacheLookup(cache, binary))) { - virResetLastError(); - VIR_FREE(binary); - continue; - } - - break; - } - } - ret = virQEMUCapsInitGuestFromBinary(caps, binary, qemubinCaps, guestarch); -- 2.17.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list