This patch is boiler-plate code to enable domainMemStats pass-through in the remote driver. Signed-off-by: Adam Litke <agl@xxxxxxxxxx> To: libvirt list <libvir-list@xxxxxxxxxx> --- daemon/remote.c | 35 +++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 36 +++++++++++++++++++++++++++++++++++- src/remote/remote_protocol.c | 26 ++++++++++++++++++++++++++ src/remote/remote_protocol.h | 20 ++++++++++++++++++++ src/remote/remote_protocol.x | 15 +++++++++++++++ 5 files changed, 131 insertions(+), 1 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index 4296fc3..fb11205 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -688,6 +688,41 @@ remoteDispatchDomainInterfaceStats (struct qemud_server *server ATTRIBUTE_UNUSED } static int +remoteDispatchDomainMemStats (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_mem_stats_args *args, + remote_domain_mem_stats_ret *ret) +{ + virDomainPtr dom; + struct _virDomainMemStats stats; + + dom = get_nonnull_domain (conn, args->dom); + if (dom == NULL) { + remoteDispatchConnError(rerr, conn); + return -1; + } + + if (virDomainMemStats (dom, &stats, sizeof stats) == -1) { + virDomainFree (dom); + remoteDispatchConnError(rerr, conn); + return -1; + } + virDomainFree (dom); + + ret->swap_in = stats.swap_in; + ret->swap_out = stats.swap_out; + ret->major_fault = stats.major_fault; + ret->minor_fault = stats.minor_fault; + ret->mem_free = stats.mem_free; + ret->mem_tot = stats.mem_tot; + + return 0; +} + +static int remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED, struct qemud_client *client ATTRIBUTE_UNUSED, virConnectPtr conn, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 0bfe730..be661bd 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -3208,6 +3208,40 @@ done: } static int +remoteDomainMemStats (virDomainPtr domain, struct _virDomainMemStats *stats) +{ + int rv = -1; + remote_domain_mem_stats_args args; + remote_domain_mem_stats_ret ret; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain (&args.dom, domain); + memset (&ret, 0, sizeof ret); + + if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_MEM_STATS, + (xdrproc_t) xdr_remote_domain_mem_stats_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_mem_stats_ret, + (char *) &ret) == -1) + goto done; + + stats->swap_in = ret.swap_in; + stats->swap_out = ret.swap_out; + stats->major_fault = ret.major_fault; + stats->minor_fault = ret.minor_fault; + stats->mem_free = ret.mem_free; + stats->mem_tot = ret.mem_tot; + + rv = 0; + +done: + remoteDriverUnlock(priv); + return rv; +} + +static int remoteDomainBlockPeek (virDomainPtr domain, const char *path, unsigned long long offset, @@ -8437,7 +8471,7 @@ static virDriver remote_driver = { remoteDomainMigrateFinish, /* domainMigrateFinish */ remoteDomainBlockStats, /* domainBlockStats */ remoteDomainInterfaceStats, /* domainInterfaceStats */ - NULL, /* domainMemStats */ + remoteDomainMemStats, /* domainMemStats */ remoteDomainBlockPeek, /* domainBlockPeek */ remoteDomainMemoryPeek, /* domainMemoryPeek */ remoteNodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */ diff --git a/src/remote/remote_protocol.c b/src/remote/remote_protocol.c index 1449ed4..5ed5712 100644 --- a/src/remote/remote_protocol.c +++ b/src/remote/remote_protocol.c @@ -588,6 +588,32 @@ xdr_remote_domain_interface_stats_ret (XDR *xdrs, remote_domain_interface_stats_ } bool_t +xdr_remote_domain_mem_stats_args (XDR *xdrs, remote_domain_mem_stats_args *objp) +{ + if (!xdr_remote_nonnull_domain (xdrs, &objp->dom)) + return FALSE; + return TRUE; +} + +bool_t +xdr_remote_domain_mem_stats_ret (XDR *xdrs, remote_domain_mem_stats_ret *objp) +{ + if (!xdr_uint64_t (xdrs, &objp->swap_in)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->swap_out)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->major_fault)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->minor_fault)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->mem_free)) + return FALSE; + if (!xdr_uint64_t (xdrs, &objp->mem_tot)) + 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 d87e8bc..5b274bc 100644 --- a/src/remote/remote_protocol.h +++ b/src/remote/remote_protocol.h @@ -302,6 +302,21 @@ struct remote_domain_interface_stats_ret { }; typedef struct remote_domain_interface_stats_ret remote_domain_interface_stats_ret; +struct remote_domain_mem_stats_args { + remote_nonnull_domain dom; +}; +typedef struct remote_domain_mem_stats_args remote_domain_mem_stats_args; + +struct remote_domain_mem_stats_ret { + uint64_t swap_in; + uint64_t swap_out; + uint64_t major_fault; + uint64_t minor_fault; + uint64_t mem_free; + uint64_t mem_tot; +}; +typedef struct remote_domain_mem_stats_ret remote_domain_mem_stats_ret; + struct remote_domain_block_peek_args { remote_nonnull_domain dom; remote_nonnull_string path; @@ -1689,6 +1704,7 @@ enum remote_procedure { REMOTE_PROC_SECRET_UNDEFINE = 146, REMOTE_PROC_SECRET_LOOKUP_BY_USAGE = 147, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL = 148, + REMOTE_PROC_DOMAIN_MEM_STATS = 149, }; typedef enum remote_procedure remote_procedure; @@ -1764,6 +1780,8 @@ extern bool_t xdr_remote_domain_block_stats_args (XDR *, remote_domain_block_st extern bool_t xdr_remote_domain_block_stats_ret (XDR *, remote_domain_block_stats_ret*); extern bool_t xdr_remote_domain_interface_stats_args (XDR *, remote_domain_interface_stats_args*); extern bool_t xdr_remote_domain_interface_stats_ret (XDR *, remote_domain_interface_stats_ret*); +extern bool_t xdr_remote_domain_mem_stats_args (XDR *, remote_domain_mem_stats_args*); +extern bool_t xdr_remote_domain_mem_stats_ret (XDR *, remote_domain_mem_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*); @@ -2019,6 +2037,8 @@ extern bool_t xdr_remote_domain_block_stats_args (); extern bool_t xdr_remote_domain_block_stats_ret (); extern bool_t xdr_remote_domain_interface_stats_args (); extern bool_t xdr_remote_domain_interface_stats_ret (); +extern bool_t xdr_remote_domain_mem_stats_args (); +extern bool_t xdr_remote_domain_mem_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 2b3c03b..ce4a511 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -401,6 +401,19 @@ struct remote_domain_interface_stats_ret { hyper tx_drop; }; +struct remote_domain_mem_stats_args { + remote_nonnull_domain dom; +}; + +struct remote_domain_mem_stats_ret { + unsigned hyper swap_in; + unsigned hyper swap_out; + unsigned hyper major_fault; + unsigned hyper minor_fault; + unsigned hyper mem_free; + unsigned hyper mem_tot; +}; + struct remote_domain_block_peek_args { remote_nonnull_domain dom; remote_nonnull_string path; @@ -1533,6 +1546,8 @@ enum remote_procedure { REMOTE_PROC_SECRET_LOOKUP_BY_USAGE = 147, REMOTE_PROC_DOMAIN_MIGRATE_PREPARE_TUNNEL = 148 + + REMOTE_PROC_DOMAIN_MEM_STATS = 149, }; -- 1.6.5 -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list