Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu(a)jp.fujitsu.com>
---
daemon/remote.c | 61 +++++++++++++++++++++++++++++++++++
daemon/remote_dispatch_args.h | 1 +
daemon/remote_dispatch_prototypes.h | 8 ++++
daemon/remote_dispatch_ret.h | 1 +
daemon/remote_dispatch_table.h | 5 +++
src/remote/remote_driver.c | 39 +++++++++++++++++++++-
src/remote/remote_protocol.c | 31 ++++++++++++++++++
src/remote/remote_protocol.h | 27 +++++++++++++++
src/remote/remote_protocol.x | 18 ++++++++++-
9 files changed, 189 insertions(+), 2 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 5de1055..9757f13 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -1138,6 +1138,67 @@ remoteDispatchDomainMemoryStats(struct qemud_server *server
ATTRIBUTE_UNUSED,
}
static int
+remoteDispatchDomainPcpuStats(struct qemud_server *server ATTRIBUTE_UNUSED,
+ struct qemud_client *client ATTRIBUTE_UNUSED,
+ virConnectPtr conn,
+ remote_message_header *hdr ATTRIBUTE_UNUSED,
+ remote_error *rerr,
+ remote_domain_pcpu_stats_args *args,
+ remote_domain_pcpu_stats_ret *ret)
+{
+ virDomainPtr dom;
+ struct _virDomainPcpuStat *stats;
+ unsigned int nr_stats, i;
+
+ if (!conn) {
+ remoteDispatchFormatError(rerr, "%s", _("connection not
open"));
+ return -1;
+ }
+
+ if (args->nr_stats > REMOTE_DOMAIN_PCPU_STATS_MAX) {
+ remoteDispatchFormatError(rerr, "%s",
+ _("nr_stats >
REMOTE_DOMAIN_PCPU_STATS_MAX"));
+ return -1;
+ }
+
+ dom = get_nonnull_domain(conn, args->dom);
+ if (dom == NULL) {
+ remoteDispatchConnError(rerr, conn);
+ return -1;
+ }
+
+ /* Allocate stats array for making dispatch call */
+ if (VIR_ALLOC_N(stats, args->nr_stats) < 0) {
+ virDomainFree(dom);
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ nr_stats = virDomainPcpuStats(dom, stats, args->nr_stats, 0);
+ if (nr_stats == -1) {
+ VIR_FREE(stats);
+ remoteDispatchConnError(rerr, conn);
+ virDomainFree(dom);
+ return -1;
+ }
+ virDomainFree(dom);
+
+ /* Allocate return buffer */
+ if (VIR_ALLOC_N(ret->stats.stats_val, nr_stats) < 0) {
+ VIR_FREE(stats);
+ remoteDispatchOOMError(rerr);
+ return -1;
+ }
+
+ /* Copy the stats into the xdr return structure */
+ for (i = 0; i < nr_stats; i++)
+ ret->stats.stats_val[i].val = stats[i].cpuTime;
+ ret->stats.stats_len = nr_stats;
+ VIR_FREE(stats);
+ return 0;
+}
+
+static int
remoteDispatchDomainBlockPeek(struct qemud_server *server ATTRIBUTE_UNUSED,
struct qemud_client *client ATTRIBUTE_UNUSED,
virConnectPtr conn,
diff --git a/daemon/remote_dispatch_args.h b/daemon/remote_dispatch_args.h
index f9537d7..42fc7b2 100644
--- a/daemon/remote_dispatch_args.h
+++ b/daemon/remote_dispatch_args.h
@@ -178,3 +178,4 @@
remote_domain_migrate_set_max_speed_args
val_remote_domain_migrate_set_max_speed_args;
remote_storage_vol_upload_args val_remote_storage_vol_upload_args;
remote_storage_vol_download_args val_remote_storage_vol_download_args;
+ remote_domain_pcpu_stats_args val_remote_domain_pcpu_stats_args;
diff --git a/daemon/remote_dispatch_prototypes.h b/daemon/remote_dispatch_prototypes.h
index 18bf41d..5dece04 100644
--- a/daemon/remote_dispatch_prototypes.h
+++ b/daemon/remote_dispatch_prototypes.h
@@ -498,6 +498,14 @@ static int remoteDispatchDomainOpenConsole(
remote_error *err,
remote_domain_open_console_args *args,
void *ret);
+static int remoteDispatchDomainPcpuStats(
+ struct qemud_server *server,
+ struct qemud_client *client,
+ virConnectPtr conn,
+ remote_message_header *hdr,
+ remote_error *err,
+ remote_domain_pcpu_stats_args *args,
+ remote_domain_pcpu_stats_ret *ret);
static int remoteDispatchDomainPinVcpu(
struct qemud_server *server,
struct qemud_client *client,
diff --git a/daemon/remote_dispatch_ret.h b/daemon/remote_dispatch_ret.h
index 114e832..4c0b66d 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_domain_pcpu_stats_ret val_remote_domain_pcpu_stats_ret;
diff --git a/daemon/remote_dispatch_table.h b/daemon/remote_dispatch_table.h
index b39f7c2..cb1fa05 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,
},
+{ /* DomainPcpuStats => 210 */
+ .fn = (dispatch_fn) remoteDispatchDomainPcpuStats,
+ .args_filter = (xdrproc_t) xdr_remote_domain_pcpu_stats_args,
+ .ret_filter = (xdrproc_t) xdr_remote_domain_pcpu_stats_ret,
+},
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index d00b9ee..6f7c2e7 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4172,6 +4172,43 @@ done:
return rv;
}
+
+static int
+remoteDomainPcpuStats (virDomainPtr domain,
+ struct _virDomainPcpuStat *stats,
+ unsigned int nr_stats)
+{
+ int rv = -1;
+ remote_domain_pcpu_stats_args args;
+ remote_domain_pcpu_stats_ret ret;
+ struct private_data *priv = domain->conn->privateData;
+ unsigned int i;
+
+ remoteDriverLock(priv);
+
+ make_nonnull_domain (&args.dom, domain);
+ args.nr_stats = nr_stats;
+
+ memset (&ret, 0, sizeof ret);
+
+ if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_PCPU_STATS,
+ (xdrproc_t) xdr_remote_domain_pcpu_stats_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_domain_pcpu_stats_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ for (i = 0; i < ret.stats.stats_len; i++)
+ stats[i].cpuTime = ret.stats.stats_val[i].val;
+ rv = ret.stats.stats_len;
+ xdr_free((xdrproc_t) xdr_remote_domain_pcpu_stats_ret, (char *) &ret);
+
+ done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
+
static int
remoteDomainBlockPeek (virDomainPtr domain,
const char *path,
@@ -11261,7 +11298,7 @@ static virDriver remote_driver = {
remoteDomainBlockStats, /* domainBlockStats */
remoteDomainInterfaceStats, /* domainInterfaceStats */
remoteDomainMemoryStats, /* domainMemoryStats */
- NULL, /* domainPcpuStats */
+ remoteDomainPcpuStats, /* domainPcpuStats */
remoteDomainBlockPeek, /* domainBlockPeek */
remoteDomainMemoryPeek, /* domainMemoryPeek */
remoteDomainGetBlockInfo, /* domainGetBlockInfo */
diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c
index 5604371..53825ea 100644
--- a/src/remote/remote_protocol.c
+++ b/src/remote/remote_protocol.c
@@ -872,6 +872,37 @@ xdr_remote_domain_memory_stats_ret (XDR *xdrs,
remote_domain_memory_stats_ret *o
}
bool_t
+xdr_remote_domain_pcpu_stats_args (XDR *xdrs, remote_domain_pcpu_stats_args *objp)
+{
+
+ if (!xdr_remote_nonnull_domain (xdrs, &objp->dom))
+ return FALSE;
+ if (!xdr_u_int (xdrs, &objp->nr_stats))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_domain_pcpu_stat (XDR *xdrs, remote_domain_pcpu_stat *objp)
+{
+
+ if (!xdr_uint64_t (xdrs, &objp->val))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+xdr_remote_domain_pcpu_stats_ret (XDR *xdrs, remote_domain_pcpu_stats_ret *objp)
+{
+ char **objp_cpp0 = (char **) (void *) &objp->stats.stats_val;
+
+ if (!xdr_array (xdrs, objp_cpp0, (u_int *) &objp->stats.stats_len,
REMOTE_DOMAIN_PCPU_STATS_MAX,
+ sizeof (remote_domain_pcpu_stat), (xdrproc_t)
xdr_remote_domain_pcpu_stat))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
xdr_remote_domain_block_peek_args (XDR *xdrs, remote_domain_block_peek_args *objp)
{
diff --git a/src/remote/remote_protocol.h b/src/remote/remote_protocol.h
index d9bf151..f220de9 100644
--- a/src/remote/remote_protocol.h
+++ b/src/remote/remote_protocol.h
@@ -59,6 +59,7 @@ typedef remote_nonnull_string *remote_string;
#define REMOTE_AUTH_SASL_DATA_MAX 65536
#define REMOTE_AUTH_TYPE_LIST_MAX 20
#define REMOTE_DOMAIN_MEMORY_STATS_MAX 1024
+#define REMOTE_DOMAIN_PCPU_STATS_MAX 1024
#define REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX 1024
#define REMOTE_DOMAIN_BLOCK_PEEK_BUFFER_MAX 65536
#define REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX 65536
@@ -463,6 +464,25 @@ struct remote_domain_memory_stats_ret {
};
typedef struct remote_domain_memory_stats_ret remote_domain_memory_stats_ret;
+struct remote_domain_pcpu_stats_args {
+ remote_nonnull_domain dom;
+ u_int nr_stats;
+};
+typedef struct remote_domain_pcpu_stats_args remote_domain_pcpu_stats_args;
+
+struct remote_domain_pcpu_stat {
+ uint64_t val;
+};
+typedef struct remote_domain_pcpu_stat remote_domain_pcpu_stat;
+
+struct remote_domain_pcpu_stats_ret {
+ struct {
+ u_int stats_len;
+ remote_domain_pcpu_stat *stats_val;
+ } stats;
+};
+typedef struct remote_domain_pcpu_stats_ret remote_domain_pcpu_stats_ret;
+
struct remote_domain_block_peek_args {
remote_nonnull_domain dom;
remote_nonnull_string path;
@@ -2413,6 +2433,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_DOMAIN_PCPU_STATS = 210,
};
typedef enum remote_procedure remote_procedure;
@@ -2507,6 +2528,9 @@ extern bool_t xdr_remote_domain_interface_stats_ret (XDR *,
remote_domain_inter
extern bool_t xdr_remote_domain_memory_stats_args (XDR *,
remote_domain_memory_stats_args*);
extern bool_t xdr_remote_domain_memory_stat (XDR *, remote_domain_memory_stat*);
extern bool_t xdr_remote_domain_memory_stats_ret (XDR *,
remote_domain_memory_stats_ret*);
+extern bool_t xdr_remote_domain_pcpu_stats_args (XDR *,
remote_domain_pcpu_stats_args*);
+extern bool_t xdr_remote_domain_pcpu_stat (XDR *, remote_domain_pcpu_stat*);
+extern bool_t xdr_remote_domain_pcpu_stats_ret (XDR *, remote_domain_pcpu_stats_ret*);
extern bool_t xdr_remote_domain_block_peek_args (XDR *,
remote_domain_block_peek_args*);
extern bool_t xdr_remote_domain_block_peek_ret (XDR *, remote_domain_block_peek_ret*);
extern bool_t xdr_remote_domain_memory_peek_args (XDR *,
remote_domain_memory_peek_args*);
@@ -2864,6 +2888,9 @@ extern bool_t xdr_remote_domain_interface_stats_ret ();
extern bool_t xdr_remote_domain_memory_stats_args ();
extern bool_t xdr_remote_domain_memory_stat ();
extern bool_t xdr_remote_domain_memory_stats_ret ();
+extern bool_t xdr_remote_domain_pcpu_stats_args ();
+extern bool_t xdr_remote_domain_pcpu_stat ();
+extern bool_t xdr_remote_domain_pcpu_stats_ret ();
extern bool_t xdr_remote_domain_block_peek_args ();
extern bool_t xdr_remote_domain_block_peek_ret ();
extern bool_t xdr_remote_domain_memory_peek_args ();
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 675eccd..7ab7704 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -146,6 +146,9 @@ const REMOTE_AUTH_TYPE_LIST_MAX = 20;
/* Upper limit on list of memory stats */
const REMOTE_DOMAIN_MEMORY_STATS_MAX = 1024;
+/* Upper limit on list of pcpu stats */
+const REMOTE_DOMAIN_PCPU_STATS_MAX = 1024;
+
/* Upper limit on lists of domain snapshots. */
const REMOTE_DOMAIN_SNAPSHOT_LIST_NAMES_MAX = 1024;
@@ -554,6 +557,18 @@ struct remote_domain_memory_stats_ret {
remote_domain_memory_stat stats<REMOTE_DOMAIN_MEMORY_STATS_MAX>;
};
+struct remote_domain_pcpu_stats_args {
+ remote_nonnull_domain dom;
+ u_int nr_stats;
+};
+
+struct remote_domain_pcpu_stat {
+ unsigned hyper val;
+};
+struct remote_domain_pcpu_stats_ret {
+ remote_domain_pcpu_stat stats<REMOTE_DOMAIN_PCPU_STATS_MAX>;
+};
+
struct remote_domain_block_peek_args {
remote_nonnull_domain dom;
remote_nonnull_string path;
@@ -2176,7 +2191,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_DOMAIN_PCPU_STATS = 210
/*
* Notice how the entries are grouped in sets of 10 ?
--
1.7.4.1