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