forked from rpms/libvirt
92 lines
2.6 KiB
Diff
92 lines
2.6 KiB
Diff
From 296ff8fbba31a8052bdf24e409b0bb9e3c041c8f Mon Sep 17 00:00:00 2001
|
|
Message-Id: <296ff8fbba31a8052bdf24e409b0bb9e3c041c8f@dist-git>
|
|
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Date: Fri, 21 Jun 2019 09:25:46 +0200
|
|
Subject: [PATCH] cpu_conf: Introduce virCPUDefFilterFeatures
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
This new internal API can be used for in place filtering of CPU features
|
|
in virCPUDef.
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
(cherry picked from commit c145b660b8225f73db16660461077ef931730939)
|
|
|
|
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
|
|
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Message-Id: <b3bd18c6e9cdf5256a7369bd06e5f773e160d9f3.1561068591.git.jdenemar@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
src/conf/cpu_conf.c | 22 ++++++++++++++++++++++
|
|
src/conf/cpu_conf.h | 5 +++++
|
|
src/libvirt_private.syms | 1 +
|
|
3 files changed, 28 insertions(+)
|
|
|
|
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
index 43a3ab5dcd..51e2a83eae 100644
|
|
--- a/src/conf/cpu_conf.c
|
|
+++ b/src/conf/cpu_conf.c
|
|
@@ -850,6 +850,28 @@ virCPUDefFindFeature(virCPUDefPtr def,
|
|
}
|
|
|
|
|
|
+int
|
|
+virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|
+ virCPUDefFeatureFilter filter,
|
|
+ void *opaque)
|
|
+{
|
|
+ size_t i = 0;
|
|
+
|
|
+ while (i < cpu->nfeatures) {
|
|
+ if (filter(cpu->features[i].name, opaque)) {
|
|
+ i++;
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ VIR_FREE(cpu->features[i].name);
|
|
+ if (VIR_DELETE_ELEMENT_INPLACE(cpu->features, i, cpu->nfeatures) < 0)
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+
|
|
bool
|
|
virCPUDefIsEqual(virCPUDefPtr src,
|
|
virCPUDefPtr dst,
|
|
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
index 9f2e7ee264..ad25932b9b 100644
|
|
--- a/src/conf/cpu_conf.h
|
|
+++ b/src/conf/cpu_conf.h
|
|
@@ -220,6 +220,11 @@ virCPUFeatureDefPtr
|
|
virCPUDefFindFeature(virCPUDefPtr def,
|
|
const char *name);
|
|
|
|
+int
|
|
+virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|
+ virCPUDefFeatureFilter filter,
|
|
+ void *opaque);
|
|
+
|
|
virCPUDefPtr *
|
|
virCPUDefListParse(const char **xmlCPUs,
|
|
unsigned int ncpus,
|
|
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
index 9ebc5384fb..57508de0c1 100644
|
|
--- a/src/libvirt_private.syms
|
|
+++ b/src/libvirt_private.syms
|
|
@@ -76,6 +76,7 @@ virCPUDefCopy;
|
|
virCPUDefCopyModel;
|
|
virCPUDefCopyModelFilter;
|
|
virCPUDefCopyWithoutModel;
|
|
+virCPUDefFilterFeatures;
|
|
virCPUDefFindFeature;
|
|
virCPUDefFormat;
|
|
virCPUDefFormatBuf;
|
|
--
|
|
2.22.0
|
|
|