latency: Wire up the remote protocol

This commit is contained in:
Osier Yang 2011-09-05 16:20:03 +08:00
parent 1f80c3eb86
commit efa7fc9f75
3 changed files with 151 additions and 1 deletions

View File

@ -932,6 +932,75 @@ cleanup:
return rv;
}
static int
remoteDispatchDomainBlockStatsFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client ATTRIBUTE_UNUSED,
virNetMessageHeaderPtr hdr ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
remote_domain_block_stats_flags_args *args,
remote_domain_block_stats_flags_ret *ret)
{
virTypedParameterPtr params = NULL;
virDomainPtr dom = NULL;
int i;
const char *path = args->path;
int nparams = args->nparams;
unsigned int flags;
int rv = -1;
struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client);
if (!priv->conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
goto cleanup;
flags = args->flags;
if (nparams > REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
goto cleanup;
}
if (VIR_ALLOC_N(params, nparams) < 0) {
virReportOOMError();
goto cleanup;
}
if (virDomainBlockStatsFlags(dom, path, params, &nparams, flags) < 0)
goto cleanup;
/* In this case, we need to send back the number of parameters
* supported
*/
if (args->nparams == 0) {
ret->nparams = nparams;
goto success;
}
/* Serialise the block stats. */
if (remoteSerializeTypedParameters(params, nparams,
&ret->params.params_val,
&ret->params.params_len) < 0)
goto cleanup;
success:
rv = 0;
cleanup:
if (rv < 0) {
virNetMessageSaveError(rerr);
if (ret->params.params_val) {
for (i = 0; i < nparams; i++)
VIR_FREE(ret->params.params_val[i].field);
VIR_FREE(ret->params.params_val);
}
}
VIR_FREE(params);
return rv;
}
static int
remoteDispatchDomainMemoryPeek(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client ATTRIBUTE_UNUSED,

View File

@ -1360,6 +1360,69 @@ cleanup:
return rv;
}
static int
remoteDomainBlockStatsFlags(virDomainPtr domain,
const char *path,
virTypedParameterPtr params,
int *nparams,
unsigned int flags)
{
int rv = -1;
remote_domain_block_stats_flags_args args;
remote_domain_block_stats_flags_ret ret;
struct private_data *priv = domain->conn->privateData;
remoteDriverLock(priv);
make_nonnull_domain (&args.dom, domain);
args.nparams = *nparams;
args.path = (char *) path;
args.flags = flags;
memset (&ret, 0, sizeof ret);
if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_BLOCK_STATS_FLAGS,
(xdrproc_t) xdr_remote_domain_block_stats_flags_args, (char *) &args,
(xdrproc_t) xdr_remote_domain_block_stats_flags_ret, (char *) &ret) == -1)
goto done;
/* Check the length of the returned list carefully. */
if (ret.params.params_len > REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX ||
ret.params.params_len > *nparams) {
remoteError(VIR_ERR_RPC, "%s",
_("remoteDomainBlockStatsFlags: "
"returned number of stats exceeds limit"));
goto cleanup;
}
/* Handle the case when the caller does not know the number of stats
* and is asking for the number of stats supported
*/
if (*nparams == 0) {
*nparams = ret.nparams;
rv = 0;
goto cleanup;
}
*nparams = ret.params.params_len;
/* Deserialise the result. */
if (remoteDeserializeTypedParameters(ret.params.params_val,
ret.params.params_len,
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
params,
nparams) < 0)
goto cleanup;
rv = 0;
cleanup:
xdr_free ((xdrproc_t) xdr_remote_domain_block_stats_flags_ret,
(char *) &ret);
done:
remoteDriverUnlock(priv);
return rv;
}
static int
remoteDomainGetMemoryParameters (virDomainPtr domain,
virTypedParameterPtr params, int *nparams,
@ -4307,6 +4370,7 @@ static virDriver remote_driver = {
.domainMigratePerform = remoteDomainMigratePerform, /* 0.3.2 */
.domainMigrateFinish = remoteDomainMigrateFinish, /* 0.3.2 */
.domainBlockStats = remoteDomainBlockStats, /* 0.3.2 */
.domainBlockStatsFlags = remoteDomainBlockStatsFlags, /* 0.9.5 */
.domainInterfaceStats = remoteDomainInterfaceStats, /* 0.3.2 */
.domainMemoryStats = remoteDomainMemoryStats, /* 0.7.5 */
.domainBlockPeek = remoteDomainBlockPeek, /* 0.4.2 */

View File

@ -131,6 +131,9 @@ const REMOTE_NODE_CPU_STATS_MAX = 16;
/* Upper limit on list of node memory stats. */
const REMOTE_NODE_MEMORY_STATS_MAX = 16;
/* Upper limit on list of block stats. */
const REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX = 16;
/* Upper limit on number of NUMA cells */
const REMOTE_NODE_MAX_CELLS = 1024;
@ -331,6 +334,7 @@ struct remote_node_get_memory_stats {
unsigned hyper value;
};
/*----- Calls. -----*/
/* For each call we may have a 'remote_CALL_args' and 'remote_CALL_ret'
@ -544,6 +548,18 @@ struct remote_domain_block_stats_ret { /* insert@2 */
hyper errs;
};
struct remote_domain_block_stats_flags_args {
remote_nonnull_domain dom;
remote_nonnull_string path;
int nparams;
unsigned int flags;
};
struct remote_domain_block_stats_flags_ret {
remote_typed_param params<REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX>;
int nparams;
};
struct remote_domain_interface_stats_args {
remote_nonnull_domain dom;
remote_nonnull_string path;
@ -2492,7 +2508,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_BLOCK_PULL = 240, /* autogen autogen */
REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB = 241, /* skipgen skipgen */
REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_SPEED = 242 /* autogen autogen */
REMOTE_PROC_DOMAIN_MIGRATE_GET_MAX_SPEED = 242, /* autogen autogen */
REMOTE_PROC_DOMAIN_BLOCK_STATS_FLAGS = 243 /* skipgen skipgen */
/*
* Notice how the entries are grouped in sets of 10 ?