[libvirt] [PATCHv6 1/6] virNodeGetCPUStats: Expose new API

Minoru Usui usui at mxm.nes.nec.co.jp
Wed May 25 06:03:12 UTC 2011


virNodeGetCPUStats: Expose new API

Signed-off-by: Minoru Usui <usui at mxm.nes.nec.co.jp>
---
 include/libvirt/libvirt.h.in |   65 ++++++++++++++++++++++++++++++++++++++++++
 src/libvirt_public.syms      |    1 +
 2 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 7cd6e13..431071b 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -194,6 +194,58 @@ typedef struct _virStream virStream;
  */
 typedef virStream *virStreamPtr;
 
+/**
+ * VIR_CPU_STATS_FIELD_LENGTH:
+ *
+ * Macro providing the field length of virNodeCPUStats
+ */
+#define VIR_CPU_STATS_FIELD_LENGTH 80
+
+/**
+ * VIR_CPU_STATS_KERNEL:
+ *
+ * Macro for the cumulative CPU time which spends by kernel,
+ * when the node booting up.(in nanoseconds).
+ */
+#define VIR_CPU_STATS_KERNEL "kernel"
+
+/**
+ * The cumulative CPU time which spends by user processes,
+ * when the node booting up.(in nanoseconds).
+ */
+#define VIR_CPU_STATS_USER "user"
+
+/**
+ * The cumulative idle CPU time,
+ * when the node booting up.(in nanoseconds).
+ */
+#define VIR_CPU_STATS_IDLE "idle"
+
+/**
+ * The cumulative I/O wait CPU time,
+ * when the node booting up.(in nanoseconds).
+ */
+#define VIR_CPU_STATS_IOWAIT "iowait"
+
+/**
+ * The CPU utilization.
+ * The usage value is in percent and 100% represents all CPUs on
+ * the server.
+ */
+#define VIR_CPU_STATS_UTILIZATION "utilization"
+
+/**
+ * virCPUStats:
+ *
+ * a virNodeCPUStats is a structure filled by virNodeGetCPUStats()
+ * and providing the information for the cpu stats of the node.
+ */
+typedef struct _virCPUStats virCPUStats;
+
+struct _virCPUStats {
+    char field[VIR_CPU_STATS_FIELD_LENGTH];
+    unsigned long long value;
+};
 
 /**
  * VIR_SECURITY_LABEL_BUFLEN:
@@ -565,6 +617,14 @@ int virDomainMigrateSetMaxSpeed(virDomainPtr domain,
 typedef virNodeInfo *virNodeInfoPtr;
 
 /**
+ * virCPUStatsPtr:
+ *
+ * a virCPUStatsPtr is a pointer to a virCPUStats structure.
+ */
+
+typedef virCPUStats *virCPUStatsPtr;
+
+/**
  * virConnectFlags
  *
  * Flags when opening a connection to a hypervisor
@@ -698,6 +758,11 @@ int                     virNodeGetInfo          (virConnectPtr conn,
                                                  virNodeInfoPtr info);
 char *                  virConnectGetCapabilities (virConnectPtr conn);
 
+int                     virNodeGetCPUStats (virConnectPtr conn,
+                                            virCPUStatsPtr params,
+                                            int *nparams,
+                                            unsigned int flags);
+
 unsigned long long      virNodeGetFreeMemory    (virConnectPtr conn);
 
 int                     virNodeGetSecurityModel (virConnectPtr conn,
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 0590535..2e34b89 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -442,6 +442,7 @@ LIBVIRT_0.9.2 {
         virDomainInjectNMI;
         virDomainScreenshot;
         virDomainSetSchedulerParametersFlags;
+        virNodeGetCPUStats;
 } LIBVIRT_0.9.0;
 
 # .... define new API here using predicted next version number ....
-- 
1.7.1




More information about the libvir-list mailing list