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

[libvirt] [PATCH 6/9] virConnectBaselineCPU public API implementation



Signed-off-by: Jiri Denemark <jdenemar redhat com>
---
 src/libvirt.c |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 8a9ee20..47ce54e 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10980,3 +10980,60 @@ error:
     virDispatchError(conn);
     return VIR_CPU_COMPARE_ERROR;
 }
+
+
+/**
+ * virConnectBaselineCPU:
+ *
+ * @conn: virConnect connection
+ * @ncpus: number of CPUs in xmlCPUs
+ * @xmlCPUs: array of XML descriptions of host CPUs
+ * @flags: fine-tuning flags, currently unused, pass 0.
+ *
+ * Computes the most feature-rich CPU which is compatible with all given
+ * host CPUs.
+ *
+ * Returns XML description of the computed CPU or NULL on error.
+ */
+char *
+virConnectBaselineCPU(virConnectPtr conn,
+                      unsigned int ncpus,
+                      const char **xmlCPUs,
+                      unsigned int flags)
+{
+    unsigned int i;
+
+    VIR_DEBUG("conn=%p, ncpus=%u, xmlCPUs=%p, flags=%u",
+              conn, ncpus, xmlCPUs, flags);
+    if (xmlCPUs) {
+        for (i = 0; i < ncpus; i++)
+            VIR_DEBUG("xmlCPUs[%u]=%s", i, xmlCPUs[i]);
+    }
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECT(conn)) {
+        virLibConnError(NULL, VIR_ERR_INVALID_CONN, __FUNCTION__);
+        virDispatchError(NULL);
+        return NULL;
+    }
+    if (xmlCPUs == NULL) {
+        virLibConnError(conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
+        goto error;
+    }
+
+    if (conn->driver->cpuBaseline) {
+        char *cpu;
+
+        cpu = conn->driver->cpuBaseline(conn, ncpus, xmlCPUs, flags);
+        if (!cpu)
+            goto error;
+        return cpu;
+    }
+
+    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return NULL;
+}
-- 
1.6.6.1


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