|
|
0f4c8a |
From 2d9d40cfec0aa5db556ca62395671dc340b6bf93 Mon Sep 17 00:00:00 2001
|
|
|
0f4c8a |
Message-Id: <2d9d40cfec0aa5db556ca62395671dc340b6bf93@dist-git>
|
|
|
0f4c8a |
From: Jiri Denemark <jdenemar@redhat.com>
|
|
|
0f4c8a |
Date: Mon, 9 Oct 2017 16:20:43 +0200
|
|
|
0f4c8a |
Subject: [PATCH] conf: Introduce virCPUDefFindFeature
|
|
|
0f4c8a |
|
|
|
0f4c8a |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
0f4c8a |
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
0f4c8a |
(cherry picked from commit 3276416904393a06df664c5d849ee805d07688d8)
|
|
|
0f4c8a |
|
|
|
0f4c8a |
Conflicts:
|
|
|
0f4c8a |
src/conf/cpu_conf.h - context, two more new function prototypes
|
|
|
0f4c8a |
in the header file upstream
|
|
|
0f4c8a |
|
|
|
0f4c8a |
https://bugzilla.redhat.com/show_bug.cgi?id=1508549
|
|
|
0f4c8a |
|
|
|
0f4c8a |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
0f4c8a |
---
|
|
|
0f4c8a |
src/conf/cpu_conf.c | 40 +++++++++++++++++++++++++++-------------
|
|
|
0f4c8a |
src/conf/cpu_conf.h | 4 ++++
|
|
|
0f4c8a |
src/libvirt_private.syms | 1 +
|
|
|
0f4c8a |
3 files changed, 32 insertions(+), 13 deletions(-)
|
|
|
0f4c8a |
|
|
|
0f4c8a |
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
|
|
|
0f4c8a |
index da40e9ba97..e570dffcd2 100644
|
|
|
0f4c8a |
--- a/src/conf/cpu_conf.c
|
|
|
0f4c8a |
+++ b/src/conf/cpu_conf.c
|
|
|
0f4c8a |
@@ -773,24 +773,22 @@ virCPUDefUpdateFeatureInternal(virCPUDefPtr def,
|
|
|
0f4c8a |
int policy,
|
|
|
0f4c8a |
bool update)
|
|
|
0f4c8a |
{
|
|
|
0f4c8a |
- size_t i;
|
|
|
0f4c8a |
+ virCPUFeatureDefPtr feat;
|
|
|
0f4c8a |
|
|
|
0f4c8a |
if (def->type == VIR_CPU_TYPE_HOST)
|
|
|
0f4c8a |
policy = -1;
|
|
|
0f4c8a |
|
|
|
0f4c8a |
- for (i = 0; i < def->nfeatures; i++) {
|
|
|
0f4c8a |
- if (STREQ(name, def->features[i].name)) {
|
|
|
0f4c8a |
- if (update) {
|
|
|
0f4c8a |
- def->features[i].policy = policy;
|
|
|
0f4c8a |
- return 0;
|
|
|
0f4c8a |
- }
|
|
|
0f4c8a |
-
|
|
|
0f4c8a |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
0f4c8a |
- _("CPU feature '%s' specified more than once"),
|
|
|
0f4c8a |
- name);
|
|
|
0f4c8a |
-
|
|
|
0f4c8a |
- return -1;
|
|
|
0f4c8a |
+ if ((feat = virCPUDefFindFeature(def, name))) {
|
|
|
0f4c8a |
+ if (update) {
|
|
|
0f4c8a |
+ feat->policy = policy;
|
|
|
0f4c8a |
+ return 0;
|
|
|
0f4c8a |
}
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
0f4c8a |
+ _("CPU feature '%s' specified more than once"),
|
|
|
0f4c8a |
+ name);
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+ return -1;
|
|
|
0f4c8a |
}
|
|
|
0f4c8a |
|
|
|
0f4c8a |
if (VIR_RESIZE_N(def->features, def->nfeatures_max,
|
|
|
0f4c8a |
@@ -822,6 +820,22 @@ virCPUDefAddFeature(virCPUDefPtr def,
|
|
|
0f4c8a |
return virCPUDefUpdateFeatureInternal(def, name, policy, false);
|
|
|
0f4c8a |
}
|
|
|
0f4c8a |
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+virCPUFeatureDefPtr
|
|
|
0f4c8a |
+virCPUDefFindFeature(virCPUDefPtr def,
|
|
|
0f4c8a |
+ const char *name)
|
|
|
0f4c8a |
+{
|
|
|
0f4c8a |
+ size_t i;
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+ for (i = 0; i < def->nfeatures; i++) {
|
|
|
0f4c8a |
+ if (STREQ(name, def->features[i].name))
|
|
|
0f4c8a |
+ return def->features + i;
|
|
|
0f4c8a |
+ }
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+ return NULL;
|
|
|
0f4c8a |
+}
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
bool
|
|
|
0f4c8a |
virCPUDefIsEqual(virCPUDefPtr src,
|
|
|
0f4c8a |
virCPUDefPtr dst,
|
|
|
0f4c8a |
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
|
|
|
0f4c8a |
index b44974f47e..1978814d36 100644
|
|
|
0f4c8a |
--- a/src/conf/cpu_conf.h
|
|
|
0f4c8a |
+++ b/src/conf/cpu_conf.h
|
|
|
0f4c8a |
@@ -218,4 +218,8 @@ virCPUDefUpdateFeature(virCPUDefPtr cpu,
|
|
|
0f4c8a |
const char *name,
|
|
|
0f4c8a |
int policy);
|
|
|
0f4c8a |
|
|
|
0f4c8a |
+virCPUFeatureDefPtr
|
|
|
0f4c8a |
+virCPUDefFindFeature(virCPUDefPtr def,
|
|
|
0f4c8a |
+ const char *name);
|
|
|
0f4c8a |
+
|
|
|
0f4c8a |
#endif /* __VIR_CPU_CONF_H__ */
|
|
|
0f4c8a |
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
|
|
|
0f4c8a |
index 9c596e3f1c..62ebb8180e 100644
|
|
|
0f4c8a |
--- a/src/libvirt_private.syms
|
|
|
0f4c8a |
+++ b/src/libvirt_private.syms
|
|
|
0f4c8a |
@@ -74,6 +74,7 @@ virCPUDefCopy;
|
|
|
0f4c8a |
virCPUDefCopyModel;
|
|
|
0f4c8a |
virCPUDefCopyModelFilter;
|
|
|
0f4c8a |
virCPUDefCopyWithoutModel;
|
|
|
0f4c8a |
+virCPUDefFindFeature;
|
|
|
0f4c8a |
virCPUDefFormat;
|
|
|
0f4c8a |
virCPUDefFormatBuf;
|
|
|
0f4c8a |
virCPUDefFormatBufFull;
|
|
|
0f4c8a |
--
|
|
|
0f4c8a |
2.15.0
|
|
|
0f4c8a |
|