|
|
b971b8 |
From 0f8f59eee031729fb17dd9b70285665a44517850 Mon Sep 17 00:00:00 2001
|
|
|
b971b8 |
Message-Id: <0f8f59eee031729fb17dd9b70285665a44517850@dist-git>
|
|
|
b971b8 |
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
|
|
b971b8 |
Date: Fri, 15 May 2020 19:18:50 +0200
|
|
|
b971b8 |
Subject: [PATCH] qemu: fixing auto-detecting binary in domain capabilities
|
|
|
b971b8 |
MIME-Version: 1.0
|
|
|
b971b8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
b971b8 |
Content-Transfer-Encoding: 8bit
|
|
|
b971b8 |
|
|
|
b971b8 |
The virConnectGetDomainCapabilities API accepts either a binary path
|
|
|
b971b8 |
to the emulator, or desired guest arch. If guest arch is not given,
|
|
|
b971b8 |
then the host arch is assumed.
|
|
|
b971b8 |
|
|
|
b971b8 |
In the case where the binary is not given, the code tried to find the
|
|
|
b971b8 |
emulator binary in the existing list of cached emulator capabilities.
|
|
|
b971b8 |
This is not valid since we switched to lazy population of the cache in:
|
|
|
b971b8 |
|
|
|
b971b8 |
commit 3dd91af01f30c5bda6328454ef49f3afece755d6
|
|
|
b971b8 |
Author: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
b971b8 |
Date: Mon Dec 2 13:04:26 2019 +0000
|
|
|
b971b8 |
|
|
|
b971b8 |
qemu: stop creating capabilities at driver startup
|
|
|
b971b8 |
|
|
|
b971b8 |
As a result of this change, if there are no persistent guests defined
|
|
|
b971b8 |
using the requested guest architecture, virConnectGetDomainCapabilities
|
|
|
b971b8 |
will fail to find an emulator binary.
|
|
|
b971b8 |
|
|
|
b971b8 |
The solution is to stop relying on the cached capabilities to find the
|
|
|
b971b8 |
binary and instead use the same logic we use to pick default a binary
|
|
|
b971b8 |
per arch when populating capabilities.
|
|
|
b971b8 |
|
|
|
b971b8 |
Tested-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
b971b8 |
Tested-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
b971b8 |
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
b971b8 |
(cherry picked from commit 6d786f95a366600e7bbae68c1b324a8131f5e2c5)
|
|
|
b971b8 |
|
|
|
b971b8 |
https://bugzilla.redhat.com/show_bug.cgi?id=1836351
|
|
|
b971b8 |
|
|
|
b971b8 |
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
|
|
|
b971b8 |
Message-Id: <20200515171850.135870-2-abologna@redhat.com>
|
|
|
b971b8 |
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
b971b8 |
---
|
|
|
b971b8 |
src/qemu/qemu_capabilities.c | 45 ++++++++++++++++++------------------
|
|
|
b971b8 |
1 file changed, 22 insertions(+), 23 deletions(-)
|
|
|
b971b8 |
|
|
|
b971b8 |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
b971b8 |
index 3bbfb64c03..5b16796c6b 100644
|
|
|
b971b8 |
--- a/src/qemu/qemu_capabilities.c
|
|
|
b971b8 |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
b971b8 |
@@ -5432,10 +5432,13 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
|
|
|
b971b8 |
const char **retMachine)
|
|
|
b971b8 |
{
|
|
|
b971b8 |
int virttype = VIR_DOMAIN_VIRT_NONE;
|
|
|
b971b8 |
- int arch = virArchFromHost();
|
|
|
b971b8 |
+ virArch hostarch = virArchFromHost();
|
|
|
b971b8 |
+ virArch arch = hostarch;
|
|
|
b971b8 |
virDomainVirtType capsType;
|
|
|
b971b8 |
virQEMUCapsPtr qemuCaps = NULL;
|
|
|
b971b8 |
virQEMUCapsPtr ret = NULL;
|
|
|
b971b8 |
+ virArch arch_from_caps;
|
|
|
b971b8 |
+ g_autofree char *probedbinary = NULL;
|
|
|
b971b8 |
|
|
|
b971b8 |
if (virttypeStr &&
|
|
|
b971b8 |
(virttype = virDomainVirtTypeFromString(virttypeStr)) < 0) {
|
|
|
b971b8 |
@@ -5451,31 +5454,27 @@ virQEMUCapsCacheLookupDefault(virFileCachePtr cache,
|
|
|
b971b8 |
goto cleanup;
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (binary) {
|
|
|
b971b8 |
- virArch arch_from_caps;
|
|
|
b971b8 |
+ if (!binary) {
|
|
|
b971b8 |
+ probedbinary = virQEMUCapsGetDefaultEmulator(hostarch, arch);
|
|
|
b971b8 |
+ binary = probedbinary;
|
|
|
b971b8 |
+ }
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary)))
|
|
|
b971b8 |
- goto cleanup;
|
|
|
b971b8 |
+ if (!(qemuCaps = virQEMUCapsCacheLookup(cache, binary)))
|
|
|
b971b8 |
+ goto cleanup;
|
|
|
b971b8 |
|
|
|
b971b8 |
- arch_from_caps = virQEMUCapsGetArch(qemuCaps);
|
|
|
b971b8 |
+ arch_from_caps = virQEMUCapsGetArch(qemuCaps);
|
|
|
b971b8 |
|
|
|
b971b8 |
- if (arch_from_caps != arch &&
|
|
|
b971b8 |
- !((ARCH_IS_X86(arch) && ARCH_IS_X86(arch_from_caps)) ||
|
|
|
b971b8 |
- (ARCH_IS_PPC(arch) && ARCH_IS_PPC(arch_from_caps)) ||
|
|
|
b971b8 |
- (ARCH_IS_ARM(arch) && ARCH_IS_ARM(arch_from_caps)) ||
|
|
|
b971b8 |
- (ARCH_IS_S390(arch) && ARCH_IS_S390(arch_from_caps)))) {
|
|
|
b971b8 |
- virReportError(VIR_ERR_INVALID_ARG,
|
|
|
b971b8 |
- _("architecture from emulator '%s' doesn't "
|
|
|
b971b8 |
- "match given architecture '%s'"),
|
|
|
b971b8 |
- virArchToString(arch_from_caps),
|
|
|
b971b8 |
- virArchToString(arch));
|
|
|
b971b8 |
- goto cleanup;
|
|
|
b971b8 |
- }
|
|
|
b971b8 |
- } else {
|
|
|
b971b8 |
- if (!(qemuCaps = virQEMUCapsCacheLookupByArch(cache, arch)))
|
|
|
b971b8 |
- goto cleanup;
|
|
|
b971b8 |
-
|
|
|
b971b8 |
- binary = virQEMUCapsGetBinary(qemuCaps);
|
|
|
b971b8 |
+ if (arch_from_caps != arch &&
|
|
|
b971b8 |
+ !((ARCH_IS_X86(arch) && ARCH_IS_X86(arch_from_caps)) ||
|
|
|
b971b8 |
+ (ARCH_IS_PPC(arch) && ARCH_IS_PPC(arch_from_caps)) ||
|
|
|
b971b8 |
+ (ARCH_IS_ARM(arch) && ARCH_IS_ARM(arch_from_caps)) ||
|
|
|
b971b8 |
+ (ARCH_IS_S390(arch) && ARCH_IS_S390(arch_from_caps)))) {
|
|
|
b971b8 |
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
|
b971b8 |
+ _("architecture from emulator '%s' doesn't "
|
|
|
b971b8 |
+ "match given architecture '%s'"),
|
|
|
b971b8 |
+ virArchToString(arch_from_caps),
|
|
|
b971b8 |
+ virArchToString(arch));
|
|
|
b971b8 |
+ goto cleanup;
|
|
|
b971b8 |
}
|
|
|
b971b8 |
|
|
|
b971b8 |
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
|
|
b971b8 |
--
|
|
|
b971b8 |
2.26.2
|
|
|
b971b8 |
|