[PATCH v2 07/22] conf: Introduce virDomainCapsCPUModelsGet

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This internal API can be used to find a specific CPU model in
virDomainCapsCPUModels list.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---

Notes:
    Version 2:
    - new patch which replaces the original 07/23
      (cpu: Return model from virCPUModelIsAllowed)

 src/conf/domain_capabilities.c | 18 ++++++++++++++++++
 src/conf/domain_capabilities.h |  4 ++++
 src/cpu/cpu.c                  |  8 +-------
 src/libvirt_private.syms       |  1 +
 4 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c
index be34576204..729d905e2d 100644
--- a/src/conf/domain_capabilities.c
+++ b/src/conf/domain_capabilities.c
@@ -259,6 +259,24 @@ virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
 }
 
 
+virDomainCapsCPUModelPtr
+virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
+                          const char *name)
+{
+    size_t i;
+
+    if (!cpuModels)
+        return NULL;
+
+    for (i = 0; i < cpuModels->nmodels; i++) {
+        if (STREQ(cpuModels->models[i].name, name))
+            return cpuModels->models + i;
+    }
+
+    return NULL;
+}
+
+
 int
 virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum,
                      const char *capsEnumName,
diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h
index 8c71dec21e..07640ed67f 100644
--- a/src/conf/domain_capabilities.h
+++ b/src/conf/domain_capabilities.h
@@ -179,6 +179,10 @@ int virDomainCapsCPUModelsAdd(virDomainCapsCPUModelsPtr cpuModels,
                               ssize_t nameLen,
                               virDomainCapsCPUUsable usable,
                               char **blockers);
+virDomainCapsCPUModelPtr
+virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels,
+                          const char *name);
+
 
 # define VIR_DOMAIN_CAPS_ENUM_SET(capsEnum, ...)            \
     do {                                                    \
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index f589666562..047e3b1112 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -829,16 +829,10 @@ bool
 virCPUModelIsAllowed(const char *model,
                      virDomainCapsCPUModelsPtr models)
 {
-    size_t i;
-
     if (!models)
         return true;
 
-    for (i = 0; i < models->nmodels; i++) {
-        if (STREQ(models->models[i].name, model))
-            return true;
-    }
-    return false;
+    return !!virDomainCapsCPUModelsGet(models, model);
 }
 
 
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 26c5ddb405..4c56f17e29 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -174,6 +174,7 @@ virDomainCapsCPUModelsAdd;
 virDomainCapsCPUModelsAddSteal;
 virDomainCapsCPUModelsCopy;
 virDomainCapsCPUModelsFilter;
+virDomainCapsCPUModelsGet;
 virDomainCapsCPUModelsNew;
 virDomainCapsCPUUsableTypeFromString;
 virDomainCapsCPUUsableTypeToString;
-- 
2.14.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux