[libvirt] [PATCH 3/6] virNodeGetCpuTime: Implement public API

Minoru Usui usui at mxm.nes.nec.co.jp
Fri Apr 1 01:57:24 UTC 2011


virNodeGetCpuTime: Implement public API

---
 src/libvirt.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 9bdb4c8..f3ef6ed 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4260,6 +4260,44 @@ error:
 }
 
 /**
+ * virNodeGetCpuTime:
+ * @conn: pointer to the hypervisor connection
+ *
+ * provides the cumulative CPU time, when the Node booting up.
+ * Note: The CPU time used in nanoseconds.
+ *
+ * Returns 0 in case of success and -1 in case of failure.
+ */
+int
+virNodeGetCpuTime(virConnectPtr conn ATTRIBUTE_UNUSED,
+                  virNodeCpuTimePtr cpu_time)
+{
+    VIR_DEBUG("conn=%p", conn);
+
+    virResetLastError();
+
+    if (!VIR_IS_CONNECT (conn)) {
+        virLibConnError(VIR_ERR_INVALID_CONN, __FUNCTION__);
+        virDispatchError(NULL);
+        return 0;
+    }
+
+    if (conn->driver->nodeGetCpuTime) {
+        int ret;
+        ret = conn->driver->nodeGetCpuTime(conn, cpu_time);
+        if (ret < 0)
+            goto error;
+        return ret;
+    }
+
+    virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+    virDispatchError(conn);
+    return 0;
+}
+
+/**
  * virNodeGetFreeMemory:
  * @conn: pointer to the hypervisor connection
  *
-- 
1.7.1



-- 
Minoru Usui <usui at mxm.nes.nec.co.jp>




More information about the libvir-list mailing list