[libvirt PATCH 3/3] qemu: Invalidate capabilities cache on kernel command line mismatch

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

 



See https://bugzilla.redhat.com/show_bug.cgi?id=1953389.

Signed-off-by: Tim Wiederhake <twiederh@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 17 ++++++++++++++---
 src/qemu/qemu_capspriv.h     |  3 ++-
 tests/qemucapsprobe.c        |  2 +-
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index c2a885351f..abf161227f 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4984,6 +4984,15 @@ virQEMUCapsIsValid(void *data,
             return false;
         }
 
+        if (STRNEQ_NULLABLE(priv->kernelCmdline, qemuCaps->kernelCmdline)) {
+            VIR_DEBUG("Outdated capabilities for '%s': kernel command line "
+                      "changed ('%s' vs '%s')",
+                      qemuCaps->binary,
+                      priv->kernelCmdline,
+                      qemuCaps->kernelCmdline);
+            return false;
+        }
+
         kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
         if (kvmSupportsNesting != qemuCaps->kvmSupportsNesting) {
             VIR_DEBUG("Outdated capabilities for '%s': kvm kernel nested "
@@ -5460,7 +5469,8 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
                                 gid_t runGid,
                                 const char *hostCPUSignature,
                                 unsigned int microcodeVersion,
-                                const char *kernelVersion)
+                                const char *kernelVersion,
+                                const char *kernelCmdline)
 {
     virQEMUCaps *qemuCaps;
     struct stat sb;
@@ -5510,7 +5520,7 @@ virQEMUCapsNewForBinaryInternal(virArch hostArch,
         qemuCaps->microcodeVersion = microcodeVersion;
 
         qemuCaps->kernelVersion = g_strdup(kernelVersion);
-        qemuCaps->kernelCmdline = NULL;
+        qemuCaps->kernelCmdline = g_strdup(kernelCmdline);
 
         qemuCaps->kvmSupportsNesting = virQEMUCapsKVMSupportsNesting();
 
@@ -5537,7 +5547,8 @@ virQEMUCapsNewData(const char *binary,
                                            priv->runGid,
                                            priv->hostCPUSignature,
                                            virHostCPUGetMicrocodeVersion(priv->hostArch),
-                                           priv->kernelVersion);
+                                           priv->kernelVersion,
+                                           priv->kernelCmdline);
 }
 
 
diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h
index a54a22685e..80ceb1425f 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,
+                                const char *kernelCmdline);
 
 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




[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