[libvirt PATCH 2/3] qemu: Don't assume that /usr/libexec/qemu-kvm exists

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On a machine where no QEMU binary is installed, we end up logging

  libvirtd: Cannot check QEMU binary /usr/libexec/qemu-kvm:
  No such file or directory

which is not very useful in general, and downright misleading in
the case of operating systems that are not derived from RHEL.

This is a consequence of treating that specific path in a different
way from all other possible QEMU binary paths, and specifically of
not checking whether the file actually exists but sort of assuming
that it must do if we haven't found another QEMU binary earlier.

Address the issue by trying this path out in
virQEMUCapsFindBinaryForArch(), along with all the other possible
ones, and making sure it exists before returning it.

Reported-by: Jim Fehlig <jfehlig@xxxxxxxx>
Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 68edf94ba5..41e9a3a3f5 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -945,6 +945,13 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
             return binary;
     }
 
+    /* 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)) {
+        if ((binary = virFindFileInPath("/usr/libexec/qemu-kvm")))
+            return binary;
+    }
+
     return NULL;
 }
 
@@ -953,18 +960,7 @@ char *
 virQEMUCapsGetDefaultEmulator(virArch hostarch,
                               virArch guestarch)
 {
-    char *binary = NULL;
-    /* Check for existence of base emulator, or alternate base
-     * which can be used with magic cpu choice
-     */
-    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)
-        binary = g_strdup("/usr/libexec/qemu-kvm");
-
-    return binary;
+    return virQEMUCapsFindBinaryForArch(hostarch, guestarch);
 }
 
 
-- 
2.35.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux