提交 3df26408 编写于 作者: A Andrea Bolognani

qemu: Simplify QEMU binary search

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