]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Give hint about -noTSX CPU model
authorJiri Denemark <jdenemar@redhat.com>
Tue, 24 Mar 2015 13:12:07 +0000 (14:12 +0100)
committerCole Robinson <crobinso@redhat.com>
Tue, 28 Apr 2015 15:06:43 +0000 (11:06 -0400)
Because of the microcode update to Haswell/Broadwell CPUs, existing
domains using these CPUs may fail to start even though they used to run
just fine. To help users solve this issue we try to suggest switching to
-noTSX variant of the CPU model:

    virsh # start cd
    error: Failed to start domain cd
    error: unsupported configuration: guest and host CPU are not
    compatible: Host CPU does not provide required features: rtm, hle;
    try using 'Haswell-noTSX' CPU model

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 53c8062f7eb7028043a314f2f18bf34ff0e82f0d)

src/qemu/qemu_command.c

index 4a6efc2d6545ca670ce83c39da116c5ba9362323..3d01cc50d86d8b77d1583d14709b3397f454b95e 100644 (file)
@@ -6612,6 +6612,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
     size_t ncpus = 0;
     char **cpus = NULL;
     virCPUDataPtr data = NULL;
+    virCPUDataPtr hostData = NULL;
     char *compare_msg = NULL;
     virCPUCompareResult cmp;
     const char *preferred;
@@ -6643,16 +6644,42 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
 
     /* For non-KVM, CPU features are emulated, so host compat doesn't matter */
     if (compareAgainstHost) {
+        bool noTSX = false;
+
         cmp = cpuGuestData(host, cpu, &data, &compare_msg);
         switch (cmp) {
         case VIR_CPU_COMPARE_INCOMPATIBLE:
+            if (cpuEncode(host->arch, host, NULL, &hostData,
+                          NULL, NULL, NULL, NULL) == 0 &&
+                (!cpuHasFeature(hostData, "hle") ||
+                 !cpuHasFeature(hostData, "rtm")) &&
+                (STREQ_NULLABLE(cpu->model, "Haswell") ||
+                 STREQ_NULLABLE(cpu->model, "Broadwell")))
+                noTSX = true;
+
             if (compare_msg) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                               _("guest and host CPU are not compatible: %s"),
-                               compare_msg);
+                if (noTSX) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("guest and host CPU are not compatible: "
+                                     "%s; try using '%s-noTSX' CPU model"),
+                                   compare_msg, cpu->model);
+                } else {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("guest and host CPU are not compatible: "
+                                     "%s"),
+                                   compare_msg);
+                }
             } else {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("guest CPU is not compatible with host CPU"));
+                if (noTSX) {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                   _("guest CPU is not compatible with host "
+                                     "CPU; try using '%s-noTSX' CPU model"),
+                                   cpu->model);
+                } else {
+                    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                                   _("guest CPU is not compatible with host "
+                                     "CPU"));
+                }
             }
             /* fall through */
         case VIR_CPU_COMPARE_ERROR:
@@ -6746,6 +6773,7 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
     virObjectUnref(caps);
     VIR_FREE(compare_msg);
     cpuDataFree(data);
+    cpuDataFree(hostData);
     virCPUDefFree(guest);
     virCPUDefFree(cpu);
     return ret;