|
|
c480ed |
From cb2374042f3e998b90e6ea025dadfae9333b49cd Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <cb2374042f3e998b90e6ea025dadfae9333b49cd@dist-git>
|
|
|
c480ed |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Date: Fri, 21 Jun 2019 09:25:51 +0200
|
|
|
c480ed |
Subject: [PATCH] qemu: Add APIs for translating CPU features
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
So far we always used libvirt's name of each CPU feature relying on
|
|
|
c480ed |
backward compatible aliases in QEMU. The new translation table can be
|
|
|
c480ed |
used whenever QEMU mandates or prefers canonical feature names.
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 61ee757e2002507d711c195628619b9eff38b57a)
|
|
|
c480ed |
|
|
|
c480ed |
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c480ed |
Message-Id: <5b080656d143733a77780affc6dd0d322216d6e7.1561068591.git.jdenemar@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/qemu/qemu_capabilities.c | 64 ++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
src/qemu/qemu_capabilities.h | 8 +++++
|
|
|
c480ed |
2 files changed, 72 insertions(+)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
c480ed |
index 851cb73cfc..d2a2f7418a 100644
|
|
|
c480ed |
--- a/src/qemu/qemu_capabilities.c
|
|
|
c480ed |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
c480ed |
@@ -2755,6 +2755,70 @@ virQEMUCapsCPUFilterFeatures(const char *name,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+typedef struct _virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeatureTranslationTable;
|
|
|
c480ed |
+typedef virQEMUCapsCPUFeatureTranslationTable *virQEMUCapsCPUFeatureTranslationTablePtr;
|
|
|
c480ed |
+struct _virQEMUCapsCPUFeatureTranslationTable {
|
|
|
c480ed |
+ const char *libvirt;
|
|
|
c480ed |
+ const char *qemu;
|
|
|
c480ed |
+};
|
|
|
c480ed |
+
|
|
|
c480ed |
+virQEMUCapsCPUFeatureTranslationTable virQEMUCapsCPUFeaturesX86[] = {
|
|
|
c480ed |
+ {"cmp_legacy", "cmp-legacy"},
|
|
|
c480ed |
+ {"ds_cpl", "ds-cpl"},
|
|
|
c480ed |
+ {"fxsr_opt", "fxsr-opt"},
|
|
|
c480ed |
+ {"kvm_pv_eoi", "kvm-pv-eoi"},
|
|
|
c480ed |
+ {"kvm_pv_unhalt", "kvm-pv-unhalt"},
|
|
|
c480ed |
+ {"lahf_lm", "lahf-lm"},
|
|
|
c480ed |
+ {"nodeid_msr", "nodeid-msr"},
|
|
|
c480ed |
+ {"pclmuldq", "pclmulqdq"},
|
|
|
c480ed |
+ {"perfctr_core", "perfctr-core"},
|
|
|
c480ed |
+ {"perfctr_nb", "perfctr-nb"},
|
|
|
c480ed |
+ {"tsc_adjust", "tsc-adjust"},
|
|
|
c480ed |
+ {NULL, NULL}
|
|
|
c480ed |
+};
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static const char *
|
|
|
c480ed |
+virQEMUCapsCPUFeatureTranslate(virQEMUCapsPtr qemuCaps,
|
|
|
c480ed |
+ const char *feature,
|
|
|
c480ed |
+ bool reversed)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ virQEMUCapsCPUFeatureTranslationTablePtr table = NULL;
|
|
|
c480ed |
+ virQEMUCapsCPUFeatureTranslationTablePtr entry;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (ARCH_IS_X86(qemuCaps->arch))
|
|
|
c480ed |
+ table = virQEMUCapsCPUFeaturesX86;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!table || !feature)
|
|
|
c480ed |
+ return feature;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ for (entry = table; entry->libvirt; entry++) {
|
|
|
c480ed |
+ const char *key = reversed ? entry->qemu : entry->libvirt;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (STREQ(feature, key))
|
|
|
c480ed |
+ return reversed ? entry->libvirt : entry->qemu;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return feature;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+const char *
|
|
|
c480ed |
+virQEMUCapsCPUFeatureToQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
c480ed |
+ const char *feature)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, false);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+const char *
|
|
|
c480ed |
+virQEMUCapsCPUFeatureFromQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
c480ed |
+ const char *feature)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ return virQEMUCapsCPUFeatureTranslate(qemuCaps, feature, true);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
/**
|
|
|
c480ed |
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
|
|
c480ed |
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
|
|
c480ed |
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
|
|
c480ed |
index bea4767f3c..8a27acd8a4 100644
|
|
|
c480ed |
--- a/src/qemu/qemu_capabilities.h
|
|
|
c480ed |
+++ b/src/qemu/qemu_capabilities.h
|
|
|
c480ed |
@@ -628,6 +628,14 @@ bool virQEMUCapsGuestIsNative(virArch host,
|
|
|
c480ed |
bool virQEMUCapsCPUFilterFeatures(const char *name,
|
|
|
c480ed |
void *opaque);
|
|
|
c480ed |
|
|
|
c480ed |
+const char *
|
|
|
c480ed |
+virQEMUCapsCPUFeatureToQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
c480ed |
+ const char *feature);
|
|
|
c480ed |
+
|
|
|
c480ed |
+const char *
|
|
|
c480ed |
+virQEMUCapsCPUFeatureFromQEMU(virQEMUCapsPtr qemuCaps,
|
|
|
c480ed |
+ const char *feature);
|
|
|
c480ed |
+
|
|
|
c480ed |
virSEVCapabilityPtr
|
|
|
c480ed |
virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps);
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|