render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
Blob Blame History Raw
From cdc937aeef0901ba76e3b51029b8ae3cef58c9de Mon Sep 17 00:00:00 2001
Message-Id: <cdc937aeef0901ba76e3b51029b8ae3cef58c9de@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Tue, 9 Aug 2016 15:15:20 +0200
Subject: [PATCH] cpu_x86: Fix host-model CPUs on hosts with CMT

Since the introduction of CMT features (commit v1.3.5-461-gf294b83)
starting a domain with host-model CPU on a host which supports CMT fails
because QEMU complains about unknown 'cmt' feature:

    qemu-system-x86_64: CPU feature cmt not found

https://bugzilla.redhat.com/show_bug.cgi?id=1355857

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

RHEL changes:
    - since commit v2.0.0-8-g0c8ec3b libvirt in RHEL always passes
      +rtm,+hle options to Haswell and Broadwell CPUs

https://bugzilla.redhat.com/show_bug.cgi?id=1365500

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/cpu/cpu_x86.c                                           | 8 ++++++--
 tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 24ef76b..670b02e 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -2542,12 +2542,16 @@ x86UpdateHostModel(virCPUDefPtr guest,
             goto cleanup;
     }
 
-    /* Remove non-migratable features by default
+    /* Remove non-migratable features and CMT related features which QEMU
+     * knows nothing about.
      * Note: this only works as long as no CPU model contains non-migratable
      * features directly */
     i = 0;
     while (i < guest->nfeatures) {
-        if (x86FeatureIsMigratable(guest->features[i].name, map)) {
+        if (x86FeatureIsMigratable(guest->features[i].name, map) &&
+            STRNEQ(guest->features[i].name, "cmt") &&
+            STRNEQ(guest->features[i].name, "mbm_total") &&
+            STRNEQ(guest->features[i].name, "mbm_local")) {
             i++;
         } else {
             VIR_FREE(guest->features[i].name);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
index 884ca57..b7fdf4b 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args
@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \
 -S \
 -M pc \
 -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\
-+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+cmt,+pdpe1gb,+abm,+rtm,+hle \
++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+rtm,+hle \
 -m 214 \
 -smp 6 \
 -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
-- 
2.9.2