See
https://bugzilla.redhat.com/show_bug.cgi?id=1953389.
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
src/qemu/qemu_capabilities.c | 15 ++++++++++++---
src/qemu/qemu_capspriv.h | 3 ++-
tests/qemucapsprobe.c | 2 +-
3 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 5fa3111201..67fae46a34 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4907,6 +4907,13 @@ virQEMUCapsIsValid(void *data,
return false;
}
+ if (virCPUDataIsIdentical(priv->cpuData, qemuCaps->cpuData) !=
+ VIR_CPU_COMPARE_IDENTICAL) {
+ VIR_DEBUG("Outdated capabilities for '%s': host cpuid
changed",
+ qemuCaps->binary);
+ return false;
+ }
+
kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
if (kvmSupportsNesting != qemuCaps->kvmSupportsNesting) {
VIR_DEBUG("Outdated capabilities for '%s': kvm kernel nested
"
@@ -5387,7 +5394,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
gid_t runGid,
const char *hostCPUSignature,
unsigned int microcodeVersion,
- const char *kernelVersion)
+ const char *kernelVersion,
+ virCPUData* cpuData)
{
g_autoptr(virQEMUCaps) qemuCaps = NULL;
struct stat sb;
@@ -5435,7 +5443,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
qemuCaps->hostCPUSignature = g_strdup(hostCPUSignature);
qemuCaps->microcodeVersion = microcodeVersion;
- qemuCaps->cpuData = NULL;
+ qemuCaps->cpuData = virCPUDataNewCopy(cpuData);
qemuCaps->kernelVersion = g_strdup(kernelVersion);
@@ -5460,7 +5468,8 @@ virQEMUCapsNewData(const char *binary,
priv->runGid,
priv->hostCPUSignature,
virHostCPUGetMicrocodeVersion(priv->hostArch),
- priv->kernelVersion);
+ priv->kernelVersion,
+ priv->cpuData);
}
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index a54a22685e..f4f4a99d32 100644
--- a/src/qemu/qemu_capspriv.h
+++ b/src/qemu/qemu_capspriv.h
@@ -35,7 +35,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
gid_t runGid,
const char *hostCPUSignature,
unsigned int microcodeVersion,
- const char *kernelVersion);
+ const char *kernelVersion,
+ virCPUData* cpuData);
int virQEMUCapsLoadCache(virArch hostArch,
virQEMUCaps *qemuCaps,
diff --git a/tests/qemucapsprobe.c b/tests/qemucapsprobe.c
index bfa8ae8db7..76c18f0dcd 100644
--- a/tests/qemucapsprobe.c
+++ b/tests/qemucapsprobe.c
@@ -79,7 +79,7 @@ main(int argc, char **argv)
return EXIT_FAILURE;
if (!(caps = virQEMUCapsNewForBinaryInternal(VIR_ARCH_NONE, argv[1],
"/tmp",
- -1, -1, NULL, 0, NULL)))
+ -1, -1, NULL, 0, NULL, NULL)))
return EXIT_FAILURE;
host = virArchFromHost();
--
2.31.1