render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 243a37dbf1a42f75a2529b954dac40bb0dd4059e Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <243a37dbf1a42f75a2529b954dac40bb0dd4059e@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:25:55 +0200
c480ed
Subject: [PATCH] qemu_command: Use canonical names of CPU features
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
When building QEMU command line, we should use the preferred spelling of
c480ed
each CPU feature without relying on compatibility aliases (which may be
c480ed
removed at some point).
c480ed
c480ed
The "unavailable-features" CPU property is used as a witness for the
c480ed
correct names of the features in our translation table.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit 5030a7450b0f0117a7903303572c6bda6c012327)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
c480ed
c480ed
Conflicts:
c480ed
	src/qemu/qemu_capabilities.c
c480ed
            - several refactors are missing
c480ed
c480ed
	tests/qemuxml2argvdata/eoi-disabled.x86_64-latest.args
c480ed
	tests/qemuxml2argvdata/eoi-enabled.x86_64-latest.args
c480ed
	tests/qemuxml2argvdata/kvmclock+eoi-disabled.x86_64-latest.args
c480ed
	tests/qemuxml2argvdata/pv-spinlock-disabled.x86_64-latest.args
c480ed
	tests/qemuxml2argvdata/pv-spinlock-enabled.x86_64-latest.args
c480ed
            - these were not backported
c480ed
c480ed
	tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
            - downstream patch to add rtm=on and hle=on for Haswell
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <5d34d0b9087230e4dc0f0936b34e73b5f1781832.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/qemu/qemu_capabilities.c                              | 8 +++++++-
c480ed
 src/qemu/qemu_capabilities.h                              | 1 +
c480ed
 src/qemu/qemu_command.c                                   | 2 ++
c480ed
 tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml          | 1 +
c480ed
 tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args | 6 +++---
c480ed
 5 files changed, 14 insertions(+), 4 deletions(-)
c480ed
c480ed
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
c480ed
index fb260eae96..c48d66b39b 100644
c480ed
--- a/src/qemu/qemu_capabilities.c
c480ed
+++ b/src/qemu/qemu_capabilities.c
c480ed
@@ -516,6 +516,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
c480ed
               "machine.pseries.cap-nested-hv",
c480ed
               "x86-max-cpu",
c480ed
               "cpu-unavailable-features",
c480ed
+              "canonical-cpu-features",
c480ed
     );
c480ed
 
c480ed
 
c480ed
@@ -2799,7 +2800,9 @@ virQEMUCapsCPUFeatureTranslate(virQEMUCapsPtr qemuCaps,
c480ed
     if (ARCH_IS_X86(qemuCaps->arch))
c480ed
         table = virQEMUCapsCPUFeaturesX86;
c480ed
 
c480ed
-    if (!table || !feature)
c480ed
+    if (!table ||
c480ed
+        !feature ||
c480ed
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES))
c480ed
         return feature;
c480ed
 
c480ed
     for (entry = table; entry->libvirt; entry++) {
c480ed
@@ -4381,6 +4384,9 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps,
c480ed
             virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_VFIO_CCW);
c480ed
     }
c480ed
 
c480ed
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_UNAVAILABLE_FEATURES))
c480ed
+        virQEMUCapsSet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES);
c480ed
+
c480ed
     /* Probe for SEV capabilities */
c480ed
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_SEV_GUEST)) {
c480ed
         int rc = virQEMUCapsProbeQMPSEVCapabilities(qemuCaps, mon);
c480ed
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
c480ed
index 5aa41efdb0..1767b2ab6c 100644
c480ed
--- a/src/qemu/qemu_capabilities.h
c480ed
+++ b/src/qemu/qemu_capabilities.h
c480ed
@@ -496,6 +496,7 @@ typedef enum { /* virQEMUCapsFlags grouping marker for syntax-check */
c480ed
     QEMU_CAPS_MACHINE_PSERIES_CAP_NESTED_HV, /* -machine pseries.cap-nested-hv */
c480ed
     QEMU_CAPS_X86_MAX_CPU, /* max-x86_64-cpu type exists */
c480ed
     QEMU_CAPS_CPU_UNAVAILABLE_FEATURES, /* "unavailable-features" CPU property */
c480ed
+    QEMU_CAPS_CANONICAL_CPU_FEATURES, /* avoid CPU feature aliases */
c480ed
 
c480ed
     QEMU_CAPS_LAST /* this must always be the last item */
c480ed
 } virQEMUCapsFlags;
c480ed
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
c480ed
index bea9a208e5..b5c0588e3c 100644
c480ed
--- a/src/qemu/qemu_command.c
c480ed
+++ b/src/qemu/qemu_command.c
c480ed
@@ -6819,6 +6819,8 @@ qemuBuildCpuFeature(virQEMUCapsPtr qemuCaps,
c480ed
                     const char *name,
c480ed
                     bool state)
c480ed
 {
c480ed
+    name = virQEMUCapsCPUFeatureToQEMU(qemuCaps, name);
c480ed
+
c480ed
     if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
c480ed
         virBufferAsprintf(buf, ",%s=%s", name, state ? "on" : "off");
c480ed
     else
c480ed
diff --git a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
c480ed
index 95d26dfce8..9245641df8 100644
c480ed
--- a/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
c480ed
+++ b/tests/qemucapabilitiesdata/caps_4.1.0.x86_64.xml
c480ed
@@ -216,6 +216,7 @@
c480ed
   <flag name='vfio-pci.display'/>
c480ed
   <flag name='x86-max-cpu'/>
c480ed
   <flag name='cpu-unavailable-features'/>
c480ed
+  <flag name='canonical-cpu-features'/>
c480ed
   <version>4000050</version>
c480ed
   <kvmVersion>0</kvmVersion>
c480ed
   <microcodeVersion>473743</microcodeVersion>
c480ed
diff --git a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
index 898b987086..6bc88bbe86 100644
c480ed
--- a/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
+++ b/tests/qemuxml2argvdata/cpu-translation.x86_64-latest.args
c480ed
@@ -10,9 +10,9 @@ QEMU_AUDIO_DRV=none \
c480ed
 -object secret,id=masterKey0,format=raw,\
c480ed
 file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
c480ed
 -machine pc,accel=tcg,usb=off,dump-guest-core=off \
c480ed
--cpu Haswell,pclmuldq=on,ds_cpl=on,tsc_adjust=on,fxsr_opt=on,lahf_lm=on,\
c480ed
-cmp_legacy=on,nodeid_msr=on,perfctr_core=on,perfctr_nb=on,rtm=on,hle=on,\
c480ed
-kvm_pv_eoi=on,kvm_pv_unhalt=on \
c480ed
+-cpu Haswell,pclmulqdq=on,ds-cpl=on,tsc-adjust=on,fxsr-opt=on,lahf-lm=on,\
c480ed
+cmp-legacy=on,nodeid-msr=on,perfctr-core=on,perfctr-nb=on,rtm=on,hle=on,\
c480ed
+kvm-pv-eoi=on,kvm-pv-unhalt=on \
c480ed
 -m 214 \
c480ed
 -realtime mlock=off \
c480ed
 -smp 1,sockets=1,cores=1,threads=1 \
c480ed
-- 
c480ed
2.22.0
c480ed