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