1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-26 03:21:44 +03:00

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 <abologna@redhat.com>
This commit is contained in:
Andrea Bolognani 2018-09-18 16:49:40 +02:00
parent 0d131d3893
commit 83d86e348e

View 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;
}