From 115a2a3fbbd09689767c40fc1521d2079ba7ba91 Mon Sep 17 00:00:00 2001 From: Lei Li Date: Tue, 15 Nov 2011 17:02:44 +0800 Subject: [PATCH] Add virDomain{Set, Get}BlockIoTune support to the remote driver Support Block I/O Throttle setting and query to remote driver. Signed-off-by: Lei Li Signed-off-by: Zhi Yong Wu Signed-off-by: Eric Blake --- daemon/remote.c | 64 ++++++++++++++++++++++++++++++++++++ src/remote/remote_driver.c | 57 ++++++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 26 ++++++++++++++- src/remote_protocol-structs | 24 ++++++++++++++ 4 files changed, 170 insertions(+), 1 deletion(-) diff --git a/daemon/remote.c b/daemon/remote.c index 429979754a..e1d208c591 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -1891,6 +1891,70 @@ cleanup: return rv; } +static int +remoteDispatchDomainGetBlockIoTune(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client ATTRIBUTE_UNUSED, + virNetMessagePtr hdr ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_get_block_io_tune_args *args, + remote_domain_get_block_io_tune_ret *ret) +{ + virDomainPtr dom = NULL; + int rv = -1; + virTypedParameterPtr params = NULL; + int nparams = args->nparams; + struct daemonClientPrivate *priv = + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if (nparams > REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX) { + virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); + goto cleanup; + } + + if (VIR_ALLOC_N(params, nparams) < 0) { + virReportOOMError(); + goto cleanup; + } + + if (!(dom = get_nonnull_domain(priv->conn, args->dom))) + goto cleanup; + + if (virDomainGetBlockIoTune(dom, args->disk ? *args->disk : NULL, + params, &nparams, args->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 I/O tuning parameters. */ + if (remoteSerializeTypedParameters(params, nparams, + &ret->params.params_val, + &ret->params.params_len, + args->flags) < 0) + goto cleanup; + +success: + rv = 0; + +cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + virTypedParameterArrayClear(params, nparams); + VIR_FREE(params); + if (dom) + virDomainFree(dom); + return rv; +} /*-------------------------------------------------------------*/ diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index e5880fa4dc..556c90c438 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2200,6 +2200,61 @@ done: return rv; } +static int remoteDomainGetBlockIoTune(virDomainPtr domain, + const char *disk, + virTypedParameterPtr params, + int *nparams, + unsigned int flags) +{ + int rv = -1; + remote_domain_get_block_io_tune_args args; + remote_domain_get_block_io_tune_ret ret; + struct private_data *priv = domain->conn->privateData; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, domain); + args.disk = disk ? (char **)&disk : NULL; + args.nparams = *nparams; + args.flags = flags; + + memset(&ret, 0, sizeof(ret)); + + + if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE, + (xdrproc_t) xdr_remote_domain_get_block_io_tune_args, + (char *) &args, + (xdrproc_t) xdr_remote_domain_get_block_io_tune_ret, + (char *) &ret) == -1) { + goto done; + } + + /* Handle the case when the caller does not know the number of parameters + * and is asking for the number of parameters supported + */ + if (*nparams == 0) { + *nparams = ret.nparams; + rv = 0; + goto cleanup; + } + + 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_get_block_io_tune_ret, + (char *) &ret); +done: + remoteDriverUnlock(priv); + return rv; +} + /*----------------------------------------------------------------------*/ static virDrvOpenStatus ATTRIBUTE_NONNULL (1) @@ -4620,6 +4675,8 @@ static virDriver remote_driver = { .setKeepAlive = remoteSetKeepAlive, /* 0.9.8 */ .isAlive = remoteIsAlive, /* 0.9.8 */ .nodeSuspendForDuration = remoteNodeSuspendForDuration, /* 0.9.8 */ + .domainSetBlockIoTune = remoteDomainSetBlockIoTune, /* 0.9.8 */ + .domainGetBlockIoTune = remoteDomainGetBlockIoTune, /* 0.9.8 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index ffcf98e132..509a20bcc2 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -125,6 +125,9 @@ const REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX = 16; /* Upper limit on list of memory parameters. */ const REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX = 16; +/* Upper limit on list of blockio tuning parameters. */ +const REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX = 16; + /* Upper limit on list of node cpu stats. */ const REMOTE_NODE_CPU_STATS_MAX = 16; @@ -1082,6 +1085,25 @@ struct remote_domain_block_pull_args { unsigned int flags; }; +struct remote_domain_set_block_io_tune_args { + remote_nonnull_domain dom; + remote_nonnull_string disk; + remote_typed_param params; + unsigned int flags; +}; + +struct remote_domain_get_block_io_tune_args { + remote_nonnull_domain dom; + remote_string disk; + int nparams; + unsigned int flags; +}; + +struct remote_domain_get_block_io_tune_ret { + remote_typed_param params; + int nparams; +}; + /* Network calls: */ struct remote_num_of_networks_ret { @@ -2581,7 +2603,9 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_OPEN_GRAPHICS = 249, /* skipgen skipgen */ REMOTE_PROC_NODE_SUSPEND_FOR_DURATION = 250, /* autogen autogen */ - REMOTE_PROC_DOMAIN_BLOCK_RESIZE = 251 /* autogen autogen */ + REMOTE_PROC_DOMAIN_BLOCK_RESIZE = 251, /* autogen autogen */ + REMOTE_PROC_DOMAIN_SET_BLOCK_IO_TUNE = 252, /* autogen autogen */ + REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE = 253 /* skipgen skipgen */ /* * Notice how the entries are grouped in sets of 10 ? diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 927b6c67cd..a9d4296b79 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -765,6 +765,28 @@ struct remote_domain_block_pull_args { uint64_t bandwidth; u_int flags; }; +struct remote_domain_set_block_io_tune_args { + remote_nonnull_domain dom; + remote_nonnull_string disk; + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + u_int flags; +}; +struct remote_domain_get_block_io_tune_args { + remote_nonnull_domain dom; + remote_string disk; + int nparams; + u_int flags; +}; +struct remote_domain_get_block_io_tune_ret { + struct { + u_int params_len; + remote_typed_param * params_val; + } params; + int nparams; +}; struct remote_num_of_networks_ret { int num; }; @@ -2020,4 +2042,6 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_OPEN_GRAPHICS = 249, REMOTE_PROC_NODE_SUSPEND_FOR_DURATION = 250, REMOTE_PROC_DOMAIN_BLOCK_RESIZE = 251, + REMOTE_PROC_DOMAIN_SET_BLOCK_IO_TUNE = 252, + REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE = 253, }; -- GitLab