]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Forbid MSR features with old QEMU
authorJiri Denemark <jdenemar@redhat.com>
Wed, 19 Jun 2019 19:59:49 +0000 (21:59 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 20 Jun 2019 12:02:36 +0000 (14:02 +0200)
Without "unavailable-features" CPU property we cannot properly detect
whether a specific MSR feature we asked for (either explicitly or
implicitly via a CPU model) was disabled by QEMU for some reason.
Because this could break migration, snapshots, and save/restore
operaions, it's better to just forbid any use of MSR features with QEMU
which lacks "unavailable-features" CPU property.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_process.c

index 28aa34c62d24febd132068d1c42004daed490cba..c9f8a0f311fbc73fd673307b36a68495485072cd 100644 (file)
@@ -59,6 +59,7 @@
 #include "qemu_firmware.h"
 
 #include "cpu/cpu.h"
+#include "cpu/cpu_x86.h"
 #include "datatypes.h"
 #include "virlog.h"
 #include "virerror.h"
@@ -5406,9 +5407,32 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
     if (qemuProcessStartValidateShmem(vm) < 0)
         return -1;
 
-    if (vm->def->cpu &&
-        virCPUValidateFeatures(vm->def->os.arch, vm->def->cpu) < 0)
-        return -1;
+    if (vm->def->cpu) {
+        if (virCPUValidateFeatures(vm->def->os.arch, vm->def->cpu) < 0)
+            return -1;
+
+        if (ARCH_IS_X86(vm->def->os.arch) &&
+            !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES)) {
+            VIR_AUTOSTRINGLIST features = NULL;
+            int n;
+
+            if ((n = virCPUDefCheckFeatures(vm->def->cpu,
+                                            virCPUx86FeatureFilterSelectMSR,
+                                            NULL,
+                                            &features)) < 0)
+                return -1;
+
+            if (n > 0) {
+                VIR_AUTOFREE(char *) str = NULL;
+
+                str = virStringListJoin((const char **)features, ", ");
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                               _("Some features cannot be reliably used "
+                                 "with this QEMU: %s"), str);
+                return -1;
+            }
+        }
+    }
 
     if (qemuProcessStartValidateDisks(vm, qemuCaps) < 0)
         return -1;