提交 83d86e34 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
上级 0d131d38
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册