render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
76f597
From dcd270ea2f82749f901df0ba5fa178ce0f73aef3 Mon Sep 17 00:00:00 2001
76f597
Message-Id: <dcd270ea2f82749f901df0ba5fa178ce0f73aef3@dist-git>
d76c62
From: Jiri Denemark <jdenemar@redhat.com>
d76c62
Date: Fri, 27 Mar 2015 12:48:40 +0100
d76c62
Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs
d76c62
d76c62
RHEL-only
d76c62
d76c62
Upstream tried to solve the change of Broadwell and Haswell CPUs by
d76c62
removing rtm and hle features from the corresponding CPU models for new
d76c62
machine types. Then they reverted this and introduced new *-noTSX models
d76c62
instead. However, the original fix was backported to RHEL.
d76c62
d76c62
This patch makes sure Broadwell and Haswell will always contain rtm and
d76c62
hle features regardless on RHEL version or machine type used.
d76c62
d76c62
https://bugzilla.redhat.com/show_bug.cgi?id=1199446
d76c62
d76c62
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
d76c62
---
76f597
 src/qemu/qemu_command.c                       | 22 +++++++++++++++++++
d76c62
 tests/qemuxml2argvdata/cpu-Haswell.args       |  2 +-
d76c62
 .../qemuxml2argvdata/cpu-host-model-cmt.args  |  2 +-
9de337
 .../cpu-translation.x86_64-4.0.0.args         |  2 +-
9de337
 .../cpu-translation.x86_64-latest.args        |  2 +-
9de337
 tests/qemuxml2argvdata/cpu-tsc-frequency.args |  2 +-
d76c62
 tests/qemuxml2argvdata/q35-acpi-nouefi.args   |  2 +-
d76c62
 tests/qemuxml2argvdata/q35-acpi-uefi.args     |  2 +-
d76c62
 tests/qemuxml2argvdata/q35-noacpi-nouefi.args |  2 +-
76f597
 9 files changed, 30 insertions(+), 8 deletions(-)
d76c62
d76c62
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
76f597
index 77977c396e..3bcc2ccd1d 100644
d76c62
--- a/src/qemu/qemu_command.c
d76c62
+++ b/src/qemu/qemu_command.c
76f597
@@ -6601,6 +6601,8 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
d76c62
 {
d76c62
     size_t i;
9de337
     virCPUDef *cpu = def->cpu;
d76c62
+    bool hle = false;
d76c62
+    bool rtm = false;
d76c62
 
d76c62
     switch ((virCPUMode) cpu->mode) {
d76c62
     case VIR_CPU_MODE_HOST_PASSTHROUGH:
76f597
@@ -6667,6 +6669,12 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
d76c62
     for (i = 0; i < cpu->nfeatures; i++) {
76f597
         const char *featname =
76f597
             virQEMUCapsCPUFeatureToQEMU(qemuCaps, cpu->features[i].name);
76f597
+
d76c62
+        if (STREQ("rtm", cpu->features[i].name))
d76c62
+            rtm = true;
d76c62
+        if (STREQ("hle", cpu->features[i].name))
d76c62
+            hle = true;
d76c62
+
d76c62
         switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
d76c62
         case VIR_CPU_FEATURE_FORCE:
d76c62
         case VIR_CPU_FEATURE_REQUIRE:
76f597
@@ -6684,6 +6692,20 @@ qemuBuildCpuModelArgStr(virQEMUDriver *driver,
d76c62
         }
d76c62
     }
d76c62
 
d76c62
+    /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU
d76c62
+     * models which lack rtm and hle features when used with some machine
d76c62
+     * types. Let's make sure Broadwell and Haswell will always have these
d76c62
+     * features. But only if the features were not explicitly mentioned in
d76c62
+     * the guest CPU definition.
d76c62
+     */
d76c62
+    if (STREQ_NULLABLE(cpu->model, "Broadwell") ||
d76c62
+        STREQ_NULLABLE(cpu->model, "Haswell")) {
d76c62
+        if (!rtm)
76f597
+            virBufferAddLit(buf, ",rtm=on");
d76c62
+        if (!hle)
76f597
+            virBufferAddLit(buf, ",hle=on");
d76c62
+    }
d76c62
+
d76c62
     return 0;
d76c62
 }
d76c62
 
d76c62
diff --git a/tests/qemuxml2argvdata/cpu-Haswell.args b/tests/qemuxml2argvdata/cpu-Haswell.args
76f597
index 6441a4c1eb..4bc2e0bc00 100644
d76c62
--- a/tests/qemuxml2argvdata/cpu-Haswell.args
d76c62
+++ b/tests/qemuxml2argvdata/cpu-Haswell.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d76c62
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
d76c62
--cpu Haswell \
76f597
+-cpu Haswell,rtm=on,hle=on \
d76c62
 -m 214 \
d76c62
 -realtime mlock=off \
d76c62
 -smp 6,sockets=6,cores=1,threads=1 \
d76c62
diff --git a/tests/qemuxml2argvdata/cpu-host-model-cmt.args b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
76f597
index 3f17100e5f..81ffd67f37 100644
d76c62
--- a/tests/qemuxml2argvdata/cpu-host-model-cmt.args
d76c62
+++ b/tests/qemuxml2argvdata/cpu-host-model-cmt.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d76c62
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
76f597
--cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on \
76f597
+-cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,rtm=on,hle=on \
d76c62
 -m 214 \
d76c62
 -realtime mlock=off \
d76c62
 -smp 6,sockets=6,cores=1,threads=1 \
d76c62
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
76f597
index e98eef243e..427b6f12a4 100644
d76c62
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
d76c62
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-4.0.0.args
9de337
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
9de337
 -S \
9de337
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d76c62
 -machine pc-i440fx-4.0,accel=tcg,usb=off,dump-guest-core=off \
76f597
--cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
76f597
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
d76c62
 -m 214 \
d76c62
 -overcommit mem-lock=off \
d76c62
 -smp 1,sockets=1,cores=1,threads=1 \
d76c62
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
76f597
index c24d8ec201..b3f06a2478 100644
d76c62
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
d76c62
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
9de337
@@ -11,7 +11,7 @@ XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
9de337
 -S \
9de337
 -object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
9de337
 -machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
9de337
--cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
9de337
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,kvm-pv-eoi=on,kvm-pv-unhalt=on \
d76c62
 -m 214 \
9de337
 -object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
d76c62
 -overcommit mem-lock=off \
d76c62
diff --git a/tests/qemuxml2argvdata/cpu-tsc-frequency.args b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
76f597
index c6d917f0f4..6063ad16f5 100644
d76c62
--- a/tests/qemuxml2argvdata/cpu-tsc-frequency.args
d76c62
+++ b/tests/qemuxml2argvdata/cpu-tsc-frequency.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
d76c62
 -machine pc,accel=kvm,usb=off,dump-guest-core=off \
76f597
--cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,invtsc=on,tsc-frequency=4567890000 \
76f597
+-cpu Haswell,vme=on,ds=on,acpi=on,ss=on,ht=on,tm=on,pbe=on,dtes64=on,monitor=on,ds-cpl=on,vmx=on,smx=on,est=on,tm2=on,xtpr=on,pdcm=on,f16c=on,rdrand=on,pdpe1gb=on,abm=on,lahf-lm=on,invtsc=on,rtm=on,hle=on,tsc-frequency=4567890000 \
d76c62
 -m 214 \
d76c62
 -realtime mlock=off \
d76c62
 -smp 1,sockets=1,cores=1,threads=1 \
d76c62
diff --git a/tests/qemuxml2argvdata/q35-acpi-nouefi.args b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
76f597
index 956ee3b6b7..1b592383a9 100644
d76c62
--- a/tests/qemuxml2argvdata/q35-acpi-nouefi.args
d76c62
+++ b/tests/qemuxml2argvdata/q35-acpi-nouefi.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d76c62
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
d76c62
--cpu Haswell \
76f597
+-cpu Haswell,rtm=on,hle=on \
d76c62
 -m 1024 \
d76c62
 -realtime mlock=off \
d76c62
 -smp 1,sockets=1,cores=1,threads=1 \
d76c62
diff --git a/tests/qemuxml2argvdata/q35-acpi-uefi.args b/tests/qemuxml2argvdata/q35-acpi-uefi.args
76f597
index 272369de22..303a5176fe 100644
d76c62
--- a/tests/qemuxml2argvdata/q35-acpi-uefi.args
d76c62
+++ b/tests/qemuxml2argvdata/q35-acpi-uefi.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d76c62
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
d76c62
--cpu Haswell \
76f597
+-cpu Haswell,rtm=on,hle=on \
9de337
 -drive file=/usr/share/OVMF/OVMF_CODE.fd,if=pflash,format=raw,unit=0,readonly=on \
9de337
 -drive file=/var/lib/libvirt/qemu/nvram/guest_VARS.fd,if=pflash,format=raw,unit=1 \
9de337
 -m 1024 \
d76c62
diff --git a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
76f597
index c6cffeea89..4538a63c24 100644
d76c62
--- a/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
d76c62
+++ b/tests/qemuxml2argvdata/q35-noacpi-nouefi.args
aa5bf2
@@ -12,7 +12,7 @@ QEMU_AUDIO_DRV=none \
d76c62
 -S \
aa5bf2
 -object secret,id=masterKey0,format=raw,file=/tmp/lib/domain--1-guest/master-key.aes \
d76c62
 -machine q35,accel=tcg,usb=off,dump-guest-core=off \
d76c62
--cpu Haswell \
76f597
+-cpu Haswell,rtm=on,hle=on \
d76c62
 -m 1024 \
d76c62
 -realtime mlock=off \
d76c62
 -smp 1,sockets=1,cores=1,threads=1 \
d76c62
-- 
76f597
2.33.1
d76c62