|
Pablo Greco |
40546a |
From 0bed2e17ea6469ccabb374c0520a97706b281911 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <0bed2e17ea6469ccabb374c0520a97706b281911@dist-git>
|
|
Pablo Greco |
40546a |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Fri, 21 Jun 2019 09:26:06 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] conf: Introduce virCPUDefCheckFeatures
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
This API can be used to check whether a CPU definition contains features
|
|
Pablo Greco |
40546a |
matching a given filter.
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 4e6f58b8d55d44fa9f80736b2745b44710f6e25a)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
https://bugzilla.redhat.com/show_bug.cgi?id=1697627
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <ea489f203e2d52250acb1b9656de6aba8355f3a6.1561068591.git.jdenemar@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/conf/cpu_conf.c | 33 +++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
src/conf/cpu_conf.h | 6 ++++++
|
|
Pablo Greco |
40546a |
src/libvirt_private.syms | 1 +
|
|
Pablo Greco |
40546a |
3 files changed, 40 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
Pablo Greco |
40546a |
index 51e2a83eae..4cccea9981 100644
|
|
Pablo Greco |
40546a |
--- a/src/conf/cpu_conf.c
|
|
Pablo Greco |
40546a |
+++ b/src/conf/cpu_conf.c
|
|
Pablo Greco |
40546a |
@@ -872,6 +872,39 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+/**
|
|
Pablo Greco |
40546a |
+ * virCPUDefCheckFeatures:
|
|
Pablo Greco |
40546a |
+ *
|
|
Pablo Greco |
40546a |
+ * Check CPU features for which @filter reports true and store them in a NULL
|
|
Pablo Greco |
40546a |
+ * terminated list returned via @features.
|
|
Pablo Greco |
40546a |
+ *
|
|
Pablo Greco |
40546a |
+ * Returns the number of features matching @filter or -1 on error.
|
|
Pablo Greco |
40546a |
+ */
|
|
Pablo Greco |
40546a |
+int
|
|
Pablo Greco |
40546a |
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
|
|
Pablo Greco |
40546a |
+ virCPUDefFeatureFilter filter,
|
|
Pablo Greco |
40546a |
+ void *opaque,
|
|
Pablo Greco |
40546a |
+ char ***features)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOSTRINGLIST list = NULL;
|
|
Pablo Greco |
40546a |
+ size_t n = 0;
|
|
Pablo Greco |
40546a |
+ size_t i;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ *features = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ for (i = 0; i < cpu->nfeatures; i++) {
|
|
Pablo Greco |
40546a |
+ if (filter(cpu->features[i].name, opaque)) {
|
|
Pablo Greco |
40546a |
+ if (virStringListAdd(&list, cpu->features[i].name) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ n++;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ VIR_STEAL_PTR(*features, list);
|
|
Pablo Greco |
40546a |
+ return n;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
bool
|
|
Pablo Greco |
40546a |
virCPUDefIsEqual(virCPUDefPtr src,
|
|
Pablo Greco |
40546a |
virCPUDefPtr dst,
|
|
Pablo Greco |
40546a |
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
Pablo Greco |
40546a |
index ad25932b9b..cba0ec7c81 100644
|
|
Pablo Greco |
40546a |
--- a/src/conf/cpu_conf.h
|
|
Pablo Greco |
40546a |
+++ b/src/conf/cpu_conf.h
|
|
Pablo Greco |
40546a |
@@ -225,6 +225,12 @@ virCPUDefFilterFeatures(virCPUDefPtr cpu,
|
|
Pablo Greco |
40546a |
virCPUDefFeatureFilter filter,
|
|
Pablo Greco |
40546a |
void *opaque);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+int
|
|
Pablo Greco |
40546a |
+virCPUDefCheckFeatures(virCPUDefPtr cpu,
|
|
Pablo Greco |
40546a |
+ virCPUDefFeatureFilter filter,
|
|
Pablo Greco |
40546a |
+ void *opaque,
|
|
Pablo Greco |
40546a |
+ char ***features);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCPUDefPtr *
|
|
Pablo Greco |
40546a |
virCPUDefListParse(const char **xmlCPUs,
|
|
Pablo Greco |
40546a |
unsigned int ncpus,
|
|
Pablo Greco |
40546a |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
index 06374deaae..0290f960a0 100644
|
|
Pablo Greco |
40546a |
--- a/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
+++ b/src/libvirt_private.syms
|
|
Pablo Greco |
40546a |
@@ -72,6 +72,7 @@ virCapabilitiesSetNetPrefix;
|
|
Pablo Greco |
40546a |
virCPUCacheModeTypeFromString;
|
|
Pablo Greco |
40546a |
virCPUCacheModeTypeToString;
|
|
Pablo Greco |
40546a |
virCPUDefAddFeature;
|
|
Pablo Greco |
40546a |
+virCPUDefCheckFeatures;
|
|
Pablo Greco |
40546a |
virCPUDefCopy;
|
|
Pablo Greco |
40546a |
virCPUDefCopyModel;
|
|
Pablo Greco |
40546a |
virCPUDefCopyModelFilter;
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|