6ae9ed
From 0c8ec3bc6be11a4043f6f4bb697fbca4bc46e448 Mon Sep 17 00:00:00 2001
6ae9ed
Message-Id: <0c8ec3bc6be11a4043f6f4bb697fbca4bc46e448@dist-git>
7a3408
From: Jiri Denemark <jdenemar@redhat.com>
7a3408
Date: Fri, 27 Mar 2015 12:48:40 +0100
7a3408
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
7a3408
7a3408
RHEL-only
7a3408
7a3408
Upstream tried to solve the change of Broadwell and Haswell CPUs by
7a3408
removing rtm and hle features from the corresponding CPU models for new
7a3408
machine types. Then they reverted this and introduced new *-noTSX models
7a3408
instead. However, the original fix was backported to RHEL.
7a3408
7a3408
This patch makes sue Broadwell and Haswell will always contain rtm and
7a3408
hle features regardless on RHEL version or machine type used.
7a3408
7a3408
https://bugzilla.redhat.com/show_bug.cgi?id=1199446
7a3408
7a3408
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
7a3408
---
7a3408
 src/qemu/qemu_command.c                             | 21 +++++++++++++++++++++
7a3408
 .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args  |  2 +-
7a3408
 .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args |  2 +-
7a3408
 3 files changed, 23 insertions(+), 2 deletions(-)
7a3408
7a3408
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6ae9ed
index 71e9e63..5b2f041 100644
7a3408
--- a/src/qemu/qemu_command.c
7a3408
+++ b/src/qemu/qemu_command.c
6ae9ed
@@ -6251,6 +6251,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
7a3408
     virCPUCompareResult cmp;
7a3408
     const char *preferred;
7a3408
     virCapsPtr caps = NULL;
7a3408
+    bool hle = false;
7a3408
+    bool rtm = false;
7a3408
     bool compareAgainstHost = ((def->virtType == VIR_DOMAIN_VIRT_KVM ||
7a3408
                                 def->cpu->mode != VIR_CPU_MODE_CUSTOM) &&
7a3408
                                def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH);
6ae9ed
@@ -6404,8 +6406,27 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
7a3408
             else
7a3408
                 sign = '+';
7a3408
 
7a3408
+            if (STREQ("rtm", featCpu->features[i].name))
7a3408
+                rtm = true;
7a3408
+            if (STREQ("hle", featCpu->features[i].name))
7a3408
+                hle = true;
7a3408
+
7a3408
             virBufferAsprintf(buf, ",%c%s", sign, featCpu->features[i].name);
7a3408
         }
7a3408
+
7a3408
+        /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
7a3408
+         * models which lack rtm and hle features when used with some machine
7a3408
+         * types. Let's make sure Broadwell and Haswell will always have these
7a3408
+         * features. But only if the features were not explicitly mentioned in
7a3408
+         * the guest CPU definition.
7a3408
+         */
7a3408
+        if (STREQ_NULLABLE(featCpu->model, "Broadwell") ||
7a3408
+            STREQ_NULLABLE(featCpu->model, "Haswell")) {
7a3408
+            if (!rtm)
7a3408
+                virBufferAddLit(buf, ",+rtm");
7a3408
+            if (!hle)
7a3408
+                virBufferAddLit(buf, ",+hle");
7a3408
+        }
7a3408
     }
7a3408
 
7a3408
     ret = 0;
7a3408
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
6ae9ed
index d00a619..29cf688 100644
7a3408
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
7a3408
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
6ae9ed
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -name QEMUGuest1 \
6ae9ed
 -S \
6ae9ed
 -M pc \
6ae9ed
--cpu Haswell \
6ae9ed
+-cpu Haswell,+rtm,+hle \
6ae9ed
 -m 214 \
6ae9ed
 -smp 6 \
6ae9ed
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
7a3408
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
6ae9ed
index d00a619..29cf688 100644
7a3408
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
7a3408
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
6ae9ed
@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \
6ae9ed
 -name QEMUGuest1 \
6ae9ed
 -S \
6ae9ed
 -M pc \
6ae9ed
--cpu Haswell \
6ae9ed
+-cpu Haswell,+rtm,+hle \
6ae9ed
 -m 214 \
6ae9ed
 -smp 6 \
6ae9ed
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
7a3408
-- 
6ae9ed
2.9.0
7a3408