render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
7a3408
From c920fb815413e588dfa36da3221196762a77e6fd Mon Sep 17 00:00:00 2001
7a3408
Message-Id: <c920fb815413e588dfa36da3221196762a77e6fd@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
7a3408
index 25a7bc6..ca14ffc 100644
7a3408
--- a/src/qemu/qemu_command.c
7a3408
+++ b/src/qemu/qemu_command.c
7a3408
@@ -7011,6 +7011,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);
7a3408
@@ -7171,8 +7173,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
7a3408
index f9bea62..6c11291 100644
7a3408
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
7a3408
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args
7a3408
@@ -1,4 +1,4 @@
7a3408
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
7a3408
-/usr/bin/qemu-kvm -S -M pc -cpu Haswell -m 214 -smp 6 \
7a3408
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell,+rtm,+hle -m 214 -smp 6 \
7a3408
 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
7a3408
 none -serial none -parallel none
7a3408
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
7a3408
index f9bea62..6c11291 100644
7a3408
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
7a3408
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args
7a3408
@@ -1,4 +1,4 @@
7a3408
 LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
7a3408
-/usr/bin/qemu-kvm -S -M pc -cpu Haswell -m 214 -smp 6 \
7a3408
+/usr/bin/qemu-kvm -S -M pc -cpu Haswell,+rtm,+hle -m 214 -smp 6 \
7a3408
 -nographic -monitor unix:/tmp/test-monitor,server,nowait -no-acpi -boot n -usb -net \
7a3408
 none -serial none -parallel none
7a3408
-- 
7a3408
2.4.5
7a3408