libvirt/SOURCES/libvirt-cpu_x86-Introduce-virCPUx86FeatureFilter-MSR.patch
2021-10-08 13:11:16 +00:00

134 lines
3.9 KiB
Diff

From 016b5348df8fc1007c08b0d0deec68d923be2e75 Mon Sep 17 00:00:00 2001
Message-Id: <016b5348df8fc1007c08b0d0deec68d923be2e75@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:26:08 +0200
Subject: [PATCH] cpu_x86: Introduce virCPUx86FeatureFilter*MSR
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This functions may be used as a virCPUDefFeatureFilter callbacks for
virCPUDefCheckFeatures, virCPUDefFilerFeatures, and similar functions to
select (virCPUx86FeatureFilterSelectMSR) or drop
(virCPUx86FeatureFilterDropMSR) features reported via MSR.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit bcfed7f1c84cbff21d129a79cbd675b0cd51613c)
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
Conflicts:
src/cpu/cpu_x86.h
- downstream did not switch to #pragma once
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <1a0fd2733f3aaec22e4ad598086baac0f086bb47.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/cpu/cpu_x86.c | 57 ++++++++++++++++++++++++++++++++++++++++
src/cpu/cpu_x86.h | 6 +++++
src/libvirt_private.syms | 3 ++-
3 files changed, 65 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 75527fd28f..ec0e408f98 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -3351,6 +3351,63 @@ virCPUx86DataAddFeature(virCPUDataPtr cpuData,
}
+static bool
+virCPUx86FeatureIsMSR(const char *name)
+{
+ virCPUx86FeaturePtr feature;
+ virCPUx86DataIterator iter;
+ virCPUx86DataItemPtr item;
+ virCPUx86MapPtr map;
+
+ if (!(map = virCPUx86GetMap()))
+ return false;
+
+ if (!(feature = x86FeatureFind(map, name)) &&
+ !(feature = x86FeatureFindInternal(name)))
+ return false;
+
+ virCPUx86DataIteratorInit(&iter, &feature->data);
+ while ((item = virCPUx86DataNext(&iter))) {
+ if (item->type == VIR_CPU_X86_DATA_MSR)
+ return true;
+ }
+
+ return false;
+}
+
+
+/**
+ * virCPUx86FeatureFilterSelectMSR:
+ *
+ * This is a callback for functions filtering features in virCPUDef. The result
+ * will contain only MSR features.
+ *
+ * Returns true if @name is an MSR feature, false otherwise.
+ */
+bool
+virCPUx86FeatureFilterSelectMSR(const char *name,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ return virCPUx86FeatureIsMSR(name);
+}
+
+
+/**
+ * virCPUx86FeatureFilterDropMSR:
+ *
+ * This is a callback for functions filtering features in virCPUDef. The result
+ * will not contain any MSR feature.
+ *
+ * Returns true if @name is not an MSR feature, false otherwise.
+ */
+bool
+virCPUx86FeatureFilterDropMSR(const char *name,
+ void *opaque ATTRIBUTE_UNUSED)
+{
+ return !virCPUx86FeatureIsMSR(name);
+}
+
+
struct cpuArchDriver cpuDriverX86 = {
.name = "x86",
.arch = archs,
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
index 519024b7c0..5126679985 100644
--- a/src/cpu/cpu_x86.h
+++ b/src/cpu/cpu_x86.h
@@ -45,4 +45,10 @@ uint32_t virCPUx86DataGetSignature(virCPUDataPtr cpuData,
int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
const char *vendor);
+bool virCPUx86FeatureFilterSelectMSR(const char *name,
+ void *opaque);
+
+bool virCPUx86FeatureFilterDropMSR(const char *name,
+ void *opaque);
+
#endif /* __VIR_CPU_X86_H__ */
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 0290f960a0..f158a17b49 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1210,7 +1210,8 @@ virCPUx86DataAdd;
virCPUx86DataGetSignature;
virCPUx86DataSetSignature;
virCPUx86DataSetVendor;
-
+virCPUx86FeatureFilterDropMSR;
+virCPUx86FeatureFilterSelectMSR;
# datatypes.h
virConnectClass;
--
2.22.0