virNodeGetCpuTime: Implement remote protocol
---
daemon/remote.c | 23 +++++++++++++++++++++++
daemon/remote_dispatch_prototypes.h | 8 ++++++++
daemon/remote_dispatch_ret.h | 1 +
daemon/remote_dispatch_table.h | 5 +++++
src/remote/remote_driver.c | 26 ++++++++++++++++++++++++++
src/remote/remote_protocol.c | 15 +++++++++++++++
src/remote/remote_protocol.h | 11 +++++++++++
src/remote/remote_protocol.x | 10 +++++++++-
src/remote_protocol-structs | 6 ++++++
9 files changed, 104 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 1700c2d..64daad8 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -679,6 +679,29 @@ remoteDispatchGetCapabilities (struct qemud_server *server
ATTRIBUTE_UNUSED,
}
static int
+remoteDispatchNodeGetCpuTime (struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ void *args ATTRIBUTE_UNUSED,
+ remote_node_get_cpu_time_ret *ret)
+{
+ virNodeCpuTime cpu_time;
+
+ if (virNodeGetCpuTime(conn, &cpu_time) == -1) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+ ret->user = cpu_time.user;
+ ret->system = cpu_time.system;
+ ret->idle = cpu_time.idle;
+ ret->iowait = cpu_time.iowait;
+
+ return 0;
+}
+
+static int
remoteDispatchNodeGetCellsFreeMemory (struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 18bf41d..6cfe443 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -1138,6 +1138,14 @@ static int remoteDispatchNodeGetCellsFreeMemory(
remote_error *err,
remote_node_get_cells_free_memory_args *args,
remote_node_get_cells_free_memory_ret *ret);
+static int remoteDispatchNodeGetCpuTime(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ void *args,
+ remote_node_get_cpu_time_ret *ret);
static int remoteDispatchNodeGetFreeMemory(
struct qemud_server *server,
struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 114e832..dfed98b 100644
--- a/daemon/remote_dispatch_ret.h
+++ b/daemon/remote_dispatch_ret.h
@@ -140,3 +140,4 @@
remote_domain_is_updated_ret val_remote_domain_is_updated_ret;
remote_get_sysinfo_ret val_remote_get_sysinfo_ret;
remote_domain_get_blkio_parameters_ret val_remote_domain_get_blkio_parameters_ret;
+ remote_node_get_cpu_time_ret val_remote_node_get_cpu_time_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index b39f7c2..3e93d3e 100644
--- a/daemon/remote_dispatch_table.h
+++ b/daemon/remote_dispatch_table.h
@@ -1052,3 +1052,8 @@
.args_filter = (xdrproc_t) xdr_remote_storage_vol_download_args,
.ret_filter = (xdrproc_t) xdr_void,
},
+{ /* NodeGetCpuTime => 210 */
+ .fn = (dispatch_fn) remoteDispatchNodeGetCpuTime,
+ .args_filter = (xdrproc_t) xdr_void,
+ .ret_filter = (xdrproc_t) xdr_remote_node_get_cpu_time_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 2393055..aba68fd 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -1934,6 +1934,32 @@ done:
}
static int
+remoteNodeGetCpuTime (virConnectPtr conn, virNodeCpuTimePtr cpu_time)
+{
+ int rv = -1;
+ remote_node_get_cpu_time_ret ret;
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ memset (&ret, 0, sizeof ret);
+ if (call (conn, priv, 0, REMOTE_PROC_NODE_GET_CPU_TIME,
+ (xdrproc_t) xdr_void, (char *) NULL,
+ (xdrproc_t) xdr_remote_node_get_cpu_time_ret, (char *) &ret) == -1)
+ goto done;
+
+ cpu_time->user = ret.user;
+ cpu_time->system = ret.system;
+ cpu_time->idle = ret.idle;
+ cpu_time->iowait = ret.iowait;
+ rv = 0;
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
+static int
remoteNodeGetCellsFreeMemory(virConnectPtr conn,
unsigned long long *freeMems,
int startCell,
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 5604371..eb9c4b9 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -607,6 +607,21 @@ xdr_remote_get_capabilities_ret (XDR *xdrs,
remote_get_capabilities_ret *objp)
}
bool_t
+xdr_remote_node_get_cpu_time_ret (XDR *xdrs, remote_node_get_cpu_time_ret *objp)
+{
+
+ if (!xdr_uint64_t (xdrs, &objp->user))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->system))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->idle))
+ return FALSE;
+ if (!xdr_uint64_t (xdrs, &objp->iowait))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_remote_node_get_cells_free_memory_args (XDR *xdrs,
remote_node_get_cells_free_memory_args *objp)
{
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index d9bf151..c17a03b 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -304,6 +304,14 @@ struct remote_get_capabilities_ret {
};
typedef struct remote_get_capabilities_ret remote_get_capabilities_ret;
+struct remote_node_get_cpu_time_ret {
+ uint64_t user;
+ uint64_t system;
+ uint64_t idle;
+ uint64_t iowait;
+};
+typedef struct remote_node_get_cpu_time_ret remote_node_get_cpu_time_ret;
+
struct remote_node_get_cells_free_memory_args {
int startCell;
int maxCells;
@@ -2413,6 +2421,7 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
+ REMOTE_PROC_NODE_GET_CPU_TIME = 210,
};
typedef enum remote_procedure remote_procedure;
@@ -2486,6 +2495,7 @@ extern bool_t xdr_remote_get_max_vcpus_args (XDR *,
remote_get_max_vcpus_args*)
extern bool_t xdr_remote_get_max_vcpus_ret (XDR *, remote_get_max_vcpus_ret*);
extern bool_t xdr_remote_node_get_info_ret (XDR *, remote_node_get_info_ret*);
extern bool_t xdr_remote_get_capabilities_ret (XDR *, remote_get_capabilities_ret*);
+extern bool_t xdr_remote_node_get_cpu_time_ret (XDR *, remote_node_get_cpu_time_ret*);
extern bool_t xdr_remote_node_get_cells_free_memory_args (XDR *,
remote_node_get_cells_free_memory_args*);
extern bool_t xdr_remote_node_get_cells_free_memory_ret (XDR *,
remote_node_get_cells_free_memory_ret*);
extern bool_t xdr_remote_node_get_free_memory_ret (XDR *,
remote_node_get_free_memory_ret*);
@@ -2843,6 +2853,7 @@ extern bool_t xdr_remote_get_max_vcpus_args ();
extern bool_t xdr_remote_get_max_vcpus_ret ();
extern bool_t xdr_remote_node_get_info_ret ();
extern bool_t xdr_remote_get_capabilities_ret ();
+extern bool_t xdr_remote_node_get_cpu_time_ret ();
extern bool_t xdr_remote_node_get_cells_free_memory_args ();
extern bool_t xdr_remote_node_get_cells_free_memory_ret ();
extern bool_t xdr_remote_node_get_free_memory_ret ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 675eccd..a16a74a 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -440,6 +440,13 @@ struct remote_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_node_get_cpu_time_ret {
+ unsigned hyper user;
+ unsigned hyper system;
+ unsigned hyper idle;
+ unsigned hyper iowait;
+};
+
struct remote_node_get_cells_free_memory_args {
int startCell;
int maxCells;
@@ -2176,7 +2183,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_GET_BLKIO_PARAMETERS = 206,
REMOTE_PROC_DOMAIN_MIGRATE_SET_MAX_SPEED = 207,
REMOTE_PROC_STORAGE_VOL_UPLOAD = 208,
- REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209
+ REMOTE_PROC_STORAGE_VOL_DOWNLOAD = 209,
+ REMOTE_PROC_NODE_GET_CPU_TIME = 210
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 944553c..415132f 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -151,6 +151,12 @@ struct remote_node_get_info_ret {
struct remote_get_capabilities_ret {
remote_nonnull_string capabilities;
};
+struct remote_node_get_cpu_time_ret {
+ uint64_t user;
+ uint64_t system;
+ uint64_t idle;
+ uint64_t iowait;
+};
struct remote_node_get_cells_free_memory_args {
int startCell;
int maxCells;
--
1.7.1
--
Minoru Usui <usui(a)mxm.nes.nec.co.jp>