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

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

 



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

diff --git a/src/libvirt.c b/src/libvirt.c
index f9ff881..0c3271c 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -11090,3 +11090,60 @@ error:
     virDispatchError(conn);
     return VIR_CPU_COMPARE_ERROR;
 }
+
+
+/**
+ * virConnectBaselineCPU:
+ *
+ * @conn: virConnect connection
+ * @xmlCPUs: array of XML descriptions of host CPUs
+ * @ncpus: number of CPUs in xmlCPUs
+ * @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,
+                      const char **xmlCPUs,
+                      unsigned int ncpus,
+                      unsigned int flags)
+{
+    unsigned int i;
+
+    VIR_DEBUG("conn=%p, xmlCPUs=%p, ncpus=%u, flags=%u",
+              conn, xmlCPUs, ncpus, 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, xmlCPUs, ncpus, flags);
+        if (!cpu)
+            goto error;
+        return cpu;
+    }
+
+    virLibConnError(conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return NULL;
+}
-- 
1.6.6.1

--
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]