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

[libvirt] [PATCH 01/12] [v7] virNodeGetCPUStats: Expose new API



virNodeGetCPUStats: Expose new API

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

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 8058229..43e59a7 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -194,7 +194,6 @@ typedef struct _virStream virStream;
  */
 typedef virStream *virStreamPtr;
 
-
 /**
  * VIR_SECURITY_LABEL_BUFLEN:
  *
@@ -280,6 +279,66 @@ struct _virNodeInfo {
     unsigned int threads;/* number of threads per core */
 };
 
+/**
+ * VIR_CPU_STATS_FIELD_LENGTH:
+ *
+ * Macro providing the field length of virNodeCPUStats
+ */
+#define VIR_CPU_STATS_FIELD_LENGTH 80
+
+/**
+ * VIR_CPU_STATS_ALL_CPUS:
+ *
+ * Macro for the total CPU time/utilization
+ */
+#define VIR_CPU_STATS_ALL_CPUS -1
+
+/**
+ * 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;
+};
+
 
 /* Common data types shared among interfaces with name/type/value lists.  */
 
@@ -544,6 +603,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
@@ -677,6 +744,12 @@ int                     virNodeGetInfo          (virConnectPtr conn,
                                                  virNodeInfoPtr info);
 char *                  virConnectGetCapabilities (virConnectPtr conn);
 
+int                     virNodeGetCPUStats (virConnectPtr conn,
+                                            int cpuNum,
+                                            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 4d4299a..271b8e3 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -450,4 +450,9 @@ LIBVIRT_0.9.2 {
         virInterfaceChangeRollback;
 } LIBVIRT_0.9.0;
 
+LIBVIRT_0.9.3 {
+    global:
+        virNodeGetCPUStats;
+} LIBVIRT_0.9.2;
+
 # .... define new API here using predicted next version number ....
-- 
1.7.1


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