[PATCH] qemu: capabilities: Remove check for /usr/libexec/qemu-kvm

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

 



A downstream packaging bug resulted in a scenario where no aarch64 emulator
binary was installed on a kvm host. Querying capabilities on the host
succeeds and the capabilities correctly report that no <guest>'s are
supported, but the following error is logged

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

This error is confusing and not very helpful. Additionally, comments in the
associated code note that /usr/libexec/qemu-kvm is disto-specific, which
suggests the logic is better suited for a downstream patch. Removing the
check for /usr/libexec/qemu-kvm leaves virQEMUCapsGetDefaultEmulator() as
nothing more than a needless wrapper around virQEMUCapsFindBinaryForArch.
Drop virQEMUCapsGetDefaultEmulator() and call virQEMUCapsFindBinaryForArch()
directly in its place, which squelches the unhelpful error.

Signed-off-by: Jim Fehlig <jfehlig@xxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 25 +++----------------------
 src/qemu/qemu_capabilities.h |  5 +++--
 src/qemu/qemu_domain.c       |  2 +-
 3 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 6b4ed08499..c866c5acf6 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -915,7 +915,7 @@ virQEMUCapsFindBinary(const char *format,
     return ret;
 }
 
-static char *
+char *
 virQEMUCapsFindBinaryForArch(virArch hostarch,
                              virArch guestarch)
 {
@@ -949,25 +949,6 @@ virQEMUCapsFindBinaryForArch(virArch hostarch,
 }
 
 
-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;
-}
-
-
 static int
 virQEMUCapsInitGuest(virCaps *caps,
                      virFileCache *cache,
@@ -978,7 +959,7 @@ virQEMUCapsInitGuest(virCaps *caps,
     virQEMUCaps *qemuCaps = NULL;
     int ret = -1;
 
-    binary = virQEMUCapsGetDefaultEmulator(hostarch, guestarch);
+    binary = virQEMUCapsFindBinaryForArch(hostarch, guestarch);
 
     /* Ignore binary if extracting version info fails */
     if (binary) {
@@ -5878,7 +5859,7 @@ virQEMUCapsCacheLookupDefault(virFileCache *cache,
     }
 
     if (!binary) {
-        probedbinary = virQEMUCapsGetDefaultEmulator(hostarch, arch);
+        probedbinary = virQEMUCapsFindBinaryForArch(hostarch, arch);
         binary = probedbinary;
     }
     if (!binary) {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 948029d60d..d0e776a5c4 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -752,8 +752,6 @@ const char *virQEMUCapsGetMachineDefaultRAMid(virQEMUCaps *qemuCaps,
 void virQEMUCapsFilterByMachineType(virQEMUCaps *qemuCaps,
                                     virDomainVirtType virtType,
                                     const char *machineType);
-char * virQEMUCapsGetDefaultEmulator(virArch hostarch,
-                                     virArch guestarch);
 
 virFileCache *virQEMUCapsCacheNew(const char *libDir,
                                     const char *cacheDir,
@@ -789,6 +787,9 @@ bool virQEMUCapsSupportsGICVersion(virQEMUCaps *qemuCaps,
 const char *virQEMUCapsGetPreferredMachine(virQEMUCaps *qemuCaps,
                                            virDomainVirtType virtType);
 
+char *virQEMUCapsFindBinaryForArch(virArch hostarch,
+                                   virArch guestarch);
+
 int virQEMUCapsInitGuestFromBinary(virCaps *caps,
                                    const char *binary,
                                    virQEMUCaps *qemuCaps,
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 18d403e099..81b56b4233 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4607,7 +4607,7 @@ qemuDomainDefPostParseBasic(virDomainDef *def,
 
     /* check for emulator and create a default one if needed */
     if (!def->emulator) {
-        if (!(def->emulator = virQEMUCapsGetDefaultEmulator(
+        if (!(def->emulator = virQEMUCapsFindBinaryForArch(
                   driver->hostarch, def->os.arch))) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("No emulator found for arch '%s'"),
-- 
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