|
|
c313de |
From acb2d441abd4b584c40748cbaf4f6f7a376753aa Mon Sep 17 00:00:00 2001
|
|
|
c313de |
Message-Id: <acb2d441abd4b584c40748cbaf4f6f7a376753aa@dist-git>
|
|
|
c313de |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Date: Fri, 15 Nov 2019 17:52:32 +0100
|
|
|
c313de |
Subject: [PATCH] cpu_conf: Pass policy to CPU feature filtering callbacks
|
|
|
c313de |
MIME-Version: 1.0
|
|
|
c313de |
Content-Type: text/plain; charset=UTF-8
|
|
|
c313de |
Content-Transfer-Encoding: 8bit
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
|
|
|
c313de |
(cherry picked from commit 668797dc5cb474585609559dbe610e09517e23e6)
|
|
|
c313de |
|
|
|
c313de |
https://bugzilla.redhat.com/show_bug.cgi?id=1749672
|
|
|
c313de |
https://bugzilla.redhat.com/show_bug.cgi?id=1756156
|
|
|
c313de |
https://bugzilla.redhat.com/show_bug.cgi?id=1721608
|
|
|
c313de |
|
|
|
c313de |
Conflicts:
|
|
|
c313de |
src/cpu/cpu_x86.c
|
|
|
c313de |
src/qemu/qemu_capabilities.c
|
|
|
c313de |
- no glib stuff downstream
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
c313de |
Message-Id: <e35cd40bd84f7304288051c24fa0d4581c3d43cb.1573836581.git.jdenemar@redhat.com>
|
|
|
c313de |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
c313de |
---
|
|
|
c313de |
src/conf/cpu_conf.c | 6 +++---
|
|
|
c313de |
src/conf/cpu_conf.h | 1 +
|
|
|
c313de |
src/cpu/cpu_x86.c | 13 ++++++++++++-
|
|
|
c313de |
src/cpu/cpu_x86.h | 2 ++
|
|
|
c313de |
src/qemu/qemu_capabilities.c | 1 +
|
|
|
c313de |
src/qemu/qemu_capabilities.h | 1 +
|
|
|
c313de |
6 files changed, 20 insertions(+), 4 deletions(-)
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
|
c313de |
index 4cccea9981..d4e3c81145 100644
|
|
|
c313de |
--- a/src/conf/cpu_conf.c
|
|
|
c313de |
+++ b/src/conf/cpu_conf.c
|
|
|
c313de |
@@ -135,7 +135,7 @@ virCPUDefCopyModelFilter(virCPUDefPtr dst,
|
|
|
c313de |
dst->nfeatures = 0;
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < src->nfeatures; i++) {
|
|
|
c313de |
- if (filter && !filter(src->features[i].name, opaque))
|
|
|
c313de |
+ if (filter && !filter(src->features[i].name, src->features[i].policy, opaque))
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
n = dst->nfeatures++;
|
|
|
c313de |
@@ -858,7 +858,7 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|
|
c313de |
size_t i = 0;
|
|
|
c313de |
|
|
|
c313de |
while (i < cpu->nfeatures) {
|
|
|
c313de |
- if (filter(cpu->features[i].name, opaque)) {
|
|
|
c313de |
+ if (filter(cpu->features[i].name, cpu->features[i].policy, opaque)) {
|
|
|
c313de |
i++;
|
|
|
c313de |
continue;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -893,7 +893,7 @@ virCPUDefCheckFeatures(virCPUDefPtr cpu,
|
|
|
c313de |
*features = NULL;
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < cpu->nfeatures; i++) {
|
|
|
c313de |
- if (filter(cpu->features[i].name, opaque)) {
|
|
|
c313de |
+ if (filter(cpu->features[i].name, cpu->features[i].policy, opaque)) {
|
|
|
c313de |
if (virStringListAdd(&list, cpu->features[i].name) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
n++;
|
|
|
c313de |
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
|
c313de |
index cba0ec7c81..687e1b09d2 100644
|
|
|
c313de |
--- a/src/conf/cpu_conf.h
|
|
|
c313de |
+++ b/src/conf/cpu_conf.h
|
|
|
c313de |
@@ -162,6 +162,7 @@ virCPUDefCopyModel(virCPUDefPtr dst,
|
|
|
c313de |
* Returns true if feature @name should copied, false otherwise.
|
|
|
c313de |
*/
|
|
|
c313de |
typedef bool (*virCPUDefFeatureFilter)(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy,
|
|
|
c313de |
void *opaque);
|
|
|
c313de |
|
|
|
c313de |
int
|
|
|
c313de |
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
|
|
|
c313de |
index 9104bdbf1e..cf5ef442e7 100644
|
|
|
c313de |
--- a/src/cpu/cpu_x86.c
|
|
|
c313de |
+++ b/src/cpu/cpu_x86.c
|
|
|
c313de |
@@ -3260,6 +3260,15 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu)
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
|
|
|
c313de |
+static bool
|
|
|
c313de |
+x86FeatureFilterMigratable(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
|
|
|
c313de |
+ void *cpu_map)
|
|
|
c313de |
+{
|
|
|
c313de |
+ return x86FeatureIsMigratable(name, cpu_map);
|
|
|
c313de |
+}
|
|
|
c313de |
+
|
|
|
c313de |
+
|
|
|
c313de |
static virCPUDefPtr
|
|
|
c313de |
virCPUx86CopyMigratable(virCPUDefPtr cpu)
|
|
|
c313de |
{
|
|
|
c313de |
@@ -3273,7 +3282,7 @@ virCPUx86CopyMigratable(virCPUDefPtr cpu)
|
|
|
c313de |
return NULL;
|
|
|
c313de |
|
|
|
c313de |
if (virCPUDefCopyModelFilter(copy, cpu, false,
|
|
|
c313de |
- x86FeatureIsMigratable, map) < 0)
|
|
|
c313de |
+ x86FeatureFilterMigratable, map) < 0)
|
|
|
c313de |
goto error;
|
|
|
c313de |
|
|
|
c313de |
return copy;
|
|
|
c313de |
@@ -3408,6 +3417,7 @@ virCPUx86FeatureIsMSR(const char *name)
|
|
|
c313de |
*/
|
|
|
c313de |
bool
|
|
|
c313de |
virCPUx86FeatureFilterSelectMSR(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
|
|
|
c313de |
void *opaque ATTRIBUTE_UNUSED)
|
|
|
c313de |
{
|
|
|
c313de |
return virCPUx86FeatureIsMSR(name);
|
|
|
c313de |
@@ -3424,6 +3434,7 @@ virCPUx86FeatureFilterSelectMSR(const char *name,
|
|
|
c313de |
*/
|
|
|
c313de |
bool
|
|
|
c313de |
virCPUx86FeatureFilterDropMSR(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
|
|
|
c313de |
void *opaque ATTRIBUTE_UNUSED)
|
|
|
c313de |
{
|
|
|
c313de |
return !virCPUx86FeatureIsMSR(name);
|
|
|
c313de |
diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h
|
|
|
c313de |
index 5126679985..866fe17e88 100644
|
|
|
c313de |
--- a/src/cpu/cpu_x86.h
|
|
|
c313de |
+++ b/src/cpu/cpu_x86.h
|
|
|
c313de |
@@ -46,9 +46,11 @@ int virCPUx86DataSetVendor(virCPUDataPtr cpuData,
|
|
|
c313de |
const char *vendor);
|
|
|
c313de |
|
|
|
c313de |
bool virCPUx86FeatureFilterSelectMSR(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy,
|
|
|
c313de |
void *opaque);
|
|
|
c313de |
|
|
|
c313de |
bool virCPUx86FeatureFilterDropMSR(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy,
|
|
|
c313de |
void *opaque);
|
|
|
c313de |
|
|
|
c313de |
#endif /* __VIR_CPU_X86_H__ */
|
|
|
c313de |
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
|
|
|
c313de |
index fbfe74d45b..c25d8c3e1a 100644
|
|
|
c313de |
--- a/src/qemu/qemu_capabilities.c
|
|
|
c313de |
+++ b/src/qemu/qemu_capabilities.c
|
|
|
c313de |
@@ -2753,6 +2753,7 @@ virQEMUCapsProbeQMPSEVCapabilities(virQEMUCapsPtr qemuCaps,
|
|
|
c313de |
|
|
|
c313de |
bool
|
|
|
c313de |
virQEMUCapsCPUFilterFeatures(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy ATTRIBUTE_UNUSED,
|
|
|
c313de |
void *opaque)
|
|
|
c313de |
{
|
|
|
c313de |
virArch *arch = opaque;
|
|
|
c313de |
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
|
|
|
c313de |
index 1767b2ab6c..a4055d5458 100644
|
|
|
c313de |
--- a/src/qemu/qemu_capabilities.h
|
|
|
c313de |
+++ b/src/qemu/qemu_capabilities.h
|
|
|
c313de |
@@ -629,6 +629,7 @@ bool virQEMUCapsGuestIsNative(virArch host,
|
|
|
c313de |
virArch guest);
|
|
|
c313de |
|
|
|
c313de |
bool virQEMUCapsCPUFilterFeatures(const char *name,
|
|
|
c313de |
+ virCPUFeaturePolicy policy,
|
|
|
c313de |
void *opaque);
|
|
|
c313de |
|
|
|
c313de |
const char *
|
|
|
c313de |
--
|
|
|
c313de |
2.24.0
|
|
|
c313de |
|