mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
remote: consolidate typed parameter handling
* src/remote/remote_protocol.x (remote_typed_param_value) (remote_typed_param): New types. (remote_sched_param_value, remote_sched_param) (remote_blkio_param_value, remote_blkio_param) (remote_memory_param_value, remote_memory_param): Delete. (remote_domain_get_scheduler_parameters_ret) (remote_domain_set_scheduler_parameters_args) (remote_domain_set_scheduler_parameters_flags_args) (remote_domain_set_blkio_parameters_args) (remote_domain_get_blkio_parameters_ret) (remote_domain_set_memory_parameters_args) (remote_domain_get_memory_parameters_ret): Update clients. * src/remote_protocol-structs: Likewise. * src/remote/remote_driver.c (remoteSerializeTypedParameters) (remoteDeserializeTypedParameters): New functions. (remoteDomainSetMemoryParameters) (remoteDomainGetMemoryParameters, remoteDomainSetBlkioParameters) (remoteDomainGetBlkioParameters) (remoteDomainGetSchedulerParameters) (remoteDomainSetSchedulerParameters) (remoteDomainSetSchedulerParametersFlags): Update clients. * daemon/remote.c (remoteSerializeTypedParameters) (remoteDeserializeTypedParameters): New functions. (remoteDispatchDomainGetSchedulerParameters) (remoteDispatchDomainSetSchedulerParameters) (remoteDispatchDomainSetSchedulerParametersFlags) (remoteDispatchDomainSetMemoryParameters) (remoteDispatchDomainGetMemoryParameters) (remoteDispatchDomainSetBlkioParameters) (remoteDispatchDomainGetBlkioParameters): Update clients.
This commit is contained in:
parent
163e5f04ef
commit
8a47ed2981
502
daemon/remote.c
502
daemon/remote.c
@ -495,6 +495,143 @@ cleanup:
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Helper to serialize typed parameters. */
|
||||
static int
|
||||
remoteSerializeTypedParameters(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
u_int *ret_params_len,
|
||||
remote_typed_param **ret_params_val)
|
||||
{
|
||||
int i;
|
||||
int rv = -1;
|
||||
remote_typed_param *val;
|
||||
|
||||
*ret_params_len = nparams;
|
||||
if (VIR_ALLOC_N(val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* remoteDispatchClientRequest will free this: */
|
||||
val[i].field = strdup (params[i].field);
|
||||
if (val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
val[i].value.remote_typed_param_value_u.i = params[i].value.i;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
val[i].value.remote_typed_param_value_u.ui = params[i].value.ui;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
val[i].value.remote_typed_param_value_u.l = params[i].value.l;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
val[i].value.remote_typed_param_value_u.ul = params[i].value.ul;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
val[i].value.remote_typed_param_value_u.d = params[i].value.d;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
val[i].value.remote_typed_param_value_u.b = params[i].value.b;
|
||||
break;
|
||||
default:
|
||||
virNetError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
||||
params[i].type);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
*ret_params_val = val;
|
||||
val = NULL;
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (val) {
|
||||
for (i = 0; i < nparams; i++)
|
||||
VIR_FREE(val[i].field);
|
||||
VIR_FREE(val);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Helper to deserialize typed parameters. */
|
||||
static virTypedParameterPtr
|
||||
remoteDeserializeTypedParameters(u_int args_params_len,
|
||||
remote_typed_param *args_params_val,
|
||||
int limit,
|
||||
int *nparams)
|
||||
{
|
||||
int i;
|
||||
int rv = -1;
|
||||
virTypedParameterPtr params = NULL;
|
||||
|
||||
/* Check the length of the returned list carefully. */
|
||||
if (args_params_len > limit) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
||||
goto cleanup;
|
||||
}
|
||||
if (VIR_ALLOC_N(params, args_params_len) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*nparams = args_params_len;
|
||||
|
||||
/* Deserialise the result. */
|
||||
for (i = 0; i < args_params_len; ++i) {
|
||||
if (virStrcpyStatic(params[i].field,
|
||||
args_params_val[i].field) == NULL) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Parameter %s too big for destination"),
|
||||
args_params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = args_params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
params[i].value.i =
|
||||
args_params_val[i].value.remote_typed_param_value_u.i;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
args_params_val[i].value.remote_typed_param_value_u.ui;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
args_params_val[i].value.remote_typed_param_value_u.l;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
args_params_val[i].value.remote_typed_param_value_u.ul;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
args_params_val[i].value.remote_typed_param_value_u.d;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
args_params_val[i].value.remote_typed_param_value_u.b;
|
||||
break;
|
||||
default:
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, _("unknown parameter type: %d"),
|
||||
params[i].type);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0)
|
||||
VIR_FREE(params);
|
||||
return params;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE_UNUSED,
|
||||
struct qemud_client *client ATTRIBUTE_UNUSED,
|
||||
@ -506,7 +643,6 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i;
|
||||
int nparams = args->nparams;
|
||||
int rv = -1;
|
||||
|
||||
@ -528,48 +664,16 @@ remoteDispatchDomainGetSchedulerParameters(struct qemud_server *server ATTRIBUTE
|
||||
if (virDomainGetSchedulerParameters(dom, params, &nparams) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Serialise the scheduler parameters. */
|
||||
ret->params.params_len = nparams;
|
||||
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
||||
goto no_memory;
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* remoteDispatchClientRequest will free this: */
|
||||
ret->params.params_val[i].field = strdup(params[i].field);
|
||||
if (ret->params.params_val[i].field == NULL)
|
||||
goto no_memory;
|
||||
|
||||
ret->params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.i = params[i].value.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.ui = params[i].value.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.l = params[i].value.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.ul = params[i].value.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.d = params[i].value.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
ret->params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
|
||||
default:
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&ret->params.params_len,
|
||||
&ret->params.params_val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0) {
|
||||
if (rv < 0)
|
||||
remoteDispatchError(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);
|
||||
}
|
||||
}
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
VIR_FREE(params);
|
||||
@ -591,7 +695,7 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i, nparams;
|
||||
int nparams;
|
||||
int rv = -1;
|
||||
|
||||
if (!conn) {
|
||||
@ -601,38 +705,11 @@ remoteDispatchDomainSetSchedulerParameters(struct qemud_server *server ATTRIBUTE
|
||||
|
||||
nparams = args->params.params_len;
|
||||
|
||||
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
||||
if ((params = remoteDeserializeTypedParameters(args->params.params_len,
|
||||
args->params.params_val,
|
||||
REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX,
|
||||
&nparams)) == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
if (VIR_ALLOC_N(params, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Deserialise parameters. */
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
|
||||
args->params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = args->params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
params[i].value.i = args->params.params_val[i].value.remote_sched_param_value_u.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
params[i].value.ui = args->params.params_val[i].value.remote_sched_param_value_u.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
params[i].value.l = args->params.params_val[i].value.remote_sched_param_value_u.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
params[i].value.ul = args->params.params_val[i].value.remote_sched_param_value_u.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
params[i].value.d = args->params.params_val[i].value.remote_sched_param_value_u.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
params[i].value.b = args->params.params_val[i].value.remote_sched_param_value_u.b; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
||||
goto cleanup;
|
||||
@ -662,7 +739,7 @@ remoteDispatchDomainSetSchedulerParametersFlags(struct qemud_server *server ATTR
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i, nparams;
|
||||
int nparams;
|
||||
int rv = -1;
|
||||
|
||||
if (!conn) {
|
||||
@ -670,40 +747,11 @@ remoteDispatchDomainSetSchedulerParametersFlags(struct qemud_server *server ATTR
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nparams = args->params.params_len;
|
||||
|
||||
if (nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
||||
if ((params = remoteDeserializeTypedParameters(args->params.params_len,
|
||||
args->params.params_val,
|
||||
REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX,
|
||||
&nparams)) == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
if (VIR_ALLOC_N(params, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Deserialise parameters. */
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
if (virStrcpyStatic(params[i].field, args->params.params_val[i].field) == NULL) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, _("Field %s too big for destination"),
|
||||
args->params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = args->params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
params[i].value.i = args->params.params_val[i].value.remote_sched_param_value_u.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
params[i].value.ui = args->params.params_val[i].value.remote_sched_param_value_u.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
params[i].value.l = args->params.params_val[i].value.remote_sched_param_value_u.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
params[i].value.ul = args->params.params_val[i].value.remote_sched_param_value_u.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
params[i].value.d = args->params.params_val[i].value.remote_sched_param_value_u.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
params[i].value.b = args->params.params_val[i].value.remote_sched_param_value_u.b; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
||||
goto cleanup;
|
||||
@ -1228,7 +1276,7 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i, nparams;
|
||||
int nparams;
|
||||
unsigned int flags;
|
||||
int rv = -1;
|
||||
|
||||
@ -1237,61 +1285,13 @@ remoteDispatchDomainSetMemoryParameters(struct qemud_server *server
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nparams = args->params.params_len;
|
||||
flags = args->flags;
|
||||
|
||||
if (nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
||||
if ((params = remoteDeserializeTypedParameters(args->params.params_len,
|
||||
args->params.params_val,
|
||||
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
|
||||
&nparams)) == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
if (VIR_ALLOC_N(params, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Deserialise parameters. */
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
if (virStrcpyStatic
|
||||
(params[i].field, args->params.params_val[i].field) == NULL) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Field %s too big for destination"),
|
||||
args->params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = args->params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_MEMORY_PARAM_INT:
|
||||
params[i].value.i =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.i;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.l;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.d;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
args->params.params_val[i].value.
|
||||
remote_memory_param_value_u.b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
||||
goto cleanup;
|
||||
@ -1326,7 +1326,6 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i;
|
||||
int nparams = args->nparams;
|
||||
unsigned int flags;
|
||||
int rv = -1;
|
||||
@ -1361,75 +1360,21 @@ remoteDispatchDomainGetMemoryParameters(struct qemud_server *server
|
||||
goto success;
|
||||
}
|
||||
|
||||
/* Serialise the memory parameters. */
|
||||
ret->params.params_len = nparams;
|
||||
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
||||
goto no_memory;
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* remoteDispatchClientRequest will free this: */
|
||||
ret->params.params_val[i].field = strdup(params[i].field);
|
||||
if (ret->params.params_val[i].field == NULL)
|
||||
goto no_memory;
|
||||
|
||||
ret->params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_MEMORY_PARAM_INT:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.i =
|
||||
params[i].value.i;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_UINT:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.ui =
|
||||
params[i].value.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_LLONG:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.l =
|
||||
params[i].value.l;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.ul =
|
||||
params[i].value.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.d =
|
||||
params[i].value.d;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
|
||||
ret->params.params_val[i].
|
||||
value.remote_memory_param_value_u.b =
|
||||
params[i].value.b;
|
||||
break;
|
||||
default:
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&ret->params.params_len,
|
||||
&ret->params.params_val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
success:
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0) {
|
||||
if (rv < 0)
|
||||
remoteDispatchError(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);
|
||||
}
|
||||
}
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
VIR_FREE(params);
|
||||
return rv;
|
||||
|
||||
no_memory:
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
static int
|
||||
@ -1446,7 +1391,7 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i, nparams;
|
||||
int nparams;
|
||||
unsigned int flags;
|
||||
int rv = -1;
|
||||
|
||||
@ -1455,61 +1400,13 @@ remoteDispatchDomainSetBlkioParameters(struct qemud_server *server
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
nparams = args->params.params_len;
|
||||
flags = args->flags;
|
||||
|
||||
if (nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
|
||||
if ((params = remoteDeserializeTypedParameters(args->params.params_len,
|
||||
args->params.params_val,
|
||||
REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX,
|
||||
&nparams)) == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
if (VIR_ALLOC_N(params, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Deserialise parameters. */
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
if (virStrcpyStatic
|
||||
(params[i].field, args->params.params_val[i].field) == NULL) {
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Field %s too big for destination"),
|
||||
args->params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = args->params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_BLKIO_PARAM_INT:
|
||||
params[i].value.i =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.i;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.l;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.d;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
args->params.params_val[i].value.
|
||||
remote_blkio_param_value_u.b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(dom = get_nonnull_domain(conn, args->dom)))
|
||||
goto cleanup;
|
||||
@ -1544,7 +1441,6 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
|
||||
{
|
||||
virDomainPtr dom = NULL;
|
||||
virTypedParameterPtr params = NULL;
|
||||
int i;
|
||||
int nparams = args->nparams;
|
||||
unsigned int flags;
|
||||
int rv = -1;
|
||||
@ -1579,75 +1475,21 @@ remoteDispatchDomainGetBlkioParameters(struct qemud_server *server
|
||||
goto success;
|
||||
}
|
||||
|
||||
/* Serialise the blkio parameters. */
|
||||
ret->params.params_len = nparams;
|
||||
if (VIR_ALLOC_N(ret->params.params_val, nparams) < 0)
|
||||
goto no_memory;
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
// remoteDispatchClientRequest will free this:
|
||||
ret->params.params_val[i].field = strdup(params[i].field);
|
||||
if (ret->params.params_val[i].field == NULL)
|
||||
goto no_memory;
|
||||
|
||||
ret->params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_BLKIO_PARAM_INT:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.i =
|
||||
params[i].value.i;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_UINT:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.ui =
|
||||
params[i].value.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_LLONG:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.l =
|
||||
params[i].value.l;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.ul =
|
||||
params[i].value.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.d =
|
||||
params[i].value.d;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
|
||||
ret->params.params_val[i].
|
||||
value.remote_blkio_param_value_u.b =
|
||||
params[i].value.b;
|
||||
break;
|
||||
default:
|
||||
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("unknown type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&ret->params.params_len,
|
||||
&ret->params.params_val) < 0)
|
||||
goto cleanup;
|
||||
|
||||
success:
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0) {
|
||||
if (rv < 0)
|
||||
remoteDispatchError(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);
|
||||
if (dom)
|
||||
virDomainFree(dom);
|
||||
return rv;
|
||||
|
||||
no_memory:
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1779,6 +1779,138 @@ done:
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Helper to serialize typed parameters. */
|
||||
static int
|
||||
remoteSerializeTypedParameters(virTypedParameterPtr params,
|
||||
int nparams,
|
||||
u_int *args_params_len,
|
||||
remote_typed_param **args_params_val)
|
||||
{
|
||||
int i;
|
||||
int rv = -1;
|
||||
remote_typed_param *val;
|
||||
|
||||
*args_params_len = nparams;
|
||||
if (VIR_ALLOC_N(val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* call() will free this: */
|
||||
val[i].field = strdup (params[i].field);
|
||||
if (val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
val[i].value.remote_typed_param_value_u.i = params[i].value.i;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
val[i].value.remote_typed_param_value_u.ui = params[i].value.ui;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
val[i].value.remote_typed_param_value_u.l = params[i].value.l;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
val[i].value.remote_typed_param_value_u.ul = params[i].value.ul;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
val[i].value.remote_typed_param_value_u.d = params[i].value.d;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
val[i].value.remote_typed_param_value_u.b = params[i].value.b;
|
||||
break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
||||
params[i].type);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
*args_params_val = val;
|
||||
val = NULL;
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (val) {
|
||||
for (i = 0; i < nparams; i++)
|
||||
VIR_FREE(val[i].field);
|
||||
VIR_FREE(val);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Helper to deserialize typed parameters. */
|
||||
static int
|
||||
remoteDeserializeTypedParameters(u_int ret_params_len,
|
||||
remote_typed_param *ret_params_val,
|
||||
int limit,
|
||||
virTypedParameterPtr params,
|
||||
int *nparams)
|
||||
{
|
||||
int i;
|
||||
int rv = -1;
|
||||
|
||||
/* Check the length of the returned list carefully. */
|
||||
if (ret_params_len > limit || ret_params_len > *nparams) {
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("returned number of parameters exceeds limit"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*nparams = ret_params_len;
|
||||
|
||||
/* Deserialise the result. */
|
||||
for (i = 0; i < ret_params_len; ++i) {
|
||||
if (virStrcpyStatic(params[i].field,
|
||||
ret_params_val[i].field) == NULL) {
|
||||
remoteError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Parameter %s too big for destination"),
|
||||
ret_params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = ret_params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
params[i].value.i =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.i;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.ui;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.l;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.ul;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.d;
|
||||
break;
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
ret_params_val[i].value.remote_typed_param_value_u.b;
|
||||
break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, _("unknown parameter type: %d"),
|
||||
params[i].type);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDomainSetMemoryParameters (virDomainPtr domain,
|
||||
virTypedParameterPtr params,
|
||||
@ -1787,56 +1919,17 @@ remoteDomainSetMemoryParameters (virDomainPtr domain,
|
||||
{
|
||||
int rv = -1;
|
||||
remote_domain_set_memory_parameters_args args;
|
||||
int i, do_error;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
make_nonnull_domain (&args.dom, domain);
|
||||
|
||||
/* Serialise the memory parameters. */
|
||||
args.params.params_len = nparams;
|
||||
args.flags = flags;
|
||||
if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto done;
|
||||
}
|
||||
|
||||
do_error = 0;
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* call() will free this: */
|
||||
args.params.params_val[i].field = strdup (params[i].field);
|
||||
if (args.params.params_val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
do_error = 1;
|
||||
}
|
||||
args.params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_MEMORY_PARAM_INT:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.i =
|
||||
params[i].value.i; break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_UINT:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.ui =
|
||||
params[i].value.ui; break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_LLONG:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.l =
|
||||
params[i].value.l; break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.ul =
|
||||
params[i].value.ul; break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.d =
|
||||
params[i].value.d; break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
|
||||
args.params.params_val[i].value.remote_memory_param_value_u.b =
|
||||
params[i].value.b; break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s", _("unknown parameter type"));
|
||||
do_error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_error) {
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&args.params.params_len,
|
||||
&args.params.params_val) < 0) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_memory_parameters_args,
|
||||
(char *) &args);
|
||||
goto done;
|
||||
@ -1862,7 +1955,6 @@ remoteDomainGetMemoryParameters (virDomainPtr domain,
|
||||
int rv = -1;
|
||||
remote_domain_get_memory_parameters_args args;
|
||||
remote_domain_get_memory_parameters_ret ret;
|
||||
int i = -1;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
@ -1877,14 +1969,6 @@ remoteDomainGetMemoryParameters (virDomainPtr domain,
|
||||
(xdrproc_t) xdr_remote_domain_get_memory_parameters_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
/* Check the length of the returned list carefully. */
|
||||
if (ret.params.params_len > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX ||
|
||||
ret.params.params_len > *nparams) {
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetMemoryParameters: "
|
||||
"returned number of parameters exceeds limit"));
|
||||
goto cleanup;
|
||||
}
|
||||
/* Handle the case when the caller does not know the number of parameters
|
||||
* and is asking for the number of parameters supported
|
||||
*/
|
||||
@ -1894,49 +1978,12 @@ remoteDomainGetMemoryParameters (virDomainPtr domain,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*nparams = ret.params.params_len;
|
||||
|
||||
/* Deserialise the result. */
|
||||
for (i = 0; i < *nparams; ++i) {
|
||||
if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
|
||||
remoteError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Parameter %s too big for destination"),
|
||||
ret.params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = ret.params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_MEMORY_PARAM_INT:
|
||||
params[i].value.i =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.i;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.l;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.d;
|
||||
break;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
ret.params.params_val[i].value.remote_memory_param_value_u.b;
|
||||
break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetMemoryParameters: "
|
||||
"unknown parameter type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (remoteDeserializeTypedParameters(ret.params.params_len,
|
||||
ret.params.params_val,
|
||||
REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX,
|
||||
params,
|
||||
nparams) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rv = 0;
|
||||
|
||||
@ -1956,56 +2003,17 @@ remoteDomainSetBlkioParameters (virDomainPtr domain,
|
||||
{
|
||||
int rv = -1;
|
||||
remote_domain_set_blkio_parameters_args args;
|
||||
int i, do_error;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
make_nonnull_domain (&args.dom, domain);
|
||||
|
||||
/* Serialise the blkio parameters. */
|
||||
args.params.params_len = nparams;
|
||||
args.flags = flags;
|
||||
if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto done;
|
||||
}
|
||||
|
||||
do_error = 0;
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
// call() will free this:
|
||||
args.params.params_val[i].field = strdup (params[i].field);
|
||||
if (args.params.params_val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
do_error = 1;
|
||||
}
|
||||
args.params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_BLKIO_PARAM_INT:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.i =
|
||||
params[i].value.i; break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_UINT:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.ui =
|
||||
params[i].value.ui; break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_LLONG:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.l =
|
||||
params[i].value.l; break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.ul =
|
||||
params[i].value.ul; break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.d =
|
||||
params[i].value.d; break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
|
||||
args.params.params_val[i].value.remote_blkio_param_value_u.b =
|
||||
params[i].value.b; break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s", _("unknown parameter type"));
|
||||
do_error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_error) {
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&args.params.params_len,
|
||||
&args.params.params_val) < 0) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_blkio_parameters_args,
|
||||
(char *) &args);
|
||||
goto done;
|
||||
@ -2031,7 +2039,6 @@ remoteDomainGetBlkioParameters (virDomainPtr domain,
|
||||
int rv = -1;
|
||||
remote_domain_get_blkio_parameters_args args;
|
||||
remote_domain_get_blkio_parameters_ret ret;
|
||||
int i = -1;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
@ -2046,14 +2053,6 @@ remoteDomainGetBlkioParameters (virDomainPtr domain,
|
||||
(xdrproc_t) xdr_remote_domain_get_blkio_parameters_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
/* Check the length of the returned list carefully. */
|
||||
if (ret.params.params_len > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX ||
|
||||
ret.params.params_len > *nparams) {
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetBlkioParameters: "
|
||||
"returned number of parameters exceeds limit"));
|
||||
goto cleanup;
|
||||
}
|
||||
/* Handle the case when the caller does not know the number of parameters
|
||||
* and is asking for the number of parameters supported
|
||||
*/
|
||||
@ -2063,49 +2062,12 @@ remoteDomainGetBlkioParameters (virDomainPtr domain,
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*nparams = ret.params.params_len;
|
||||
|
||||
/* Deserialise the result. */
|
||||
for (i = 0; i < *nparams; ++i) {
|
||||
if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
|
||||
remoteError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Parameter %s too big for destination"),
|
||||
ret.params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = ret.params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_BLKIO_PARAM_INT:
|
||||
params[i].value.i =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.i;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_UINT:
|
||||
params[i].value.ui =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.ui;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_LLONG:
|
||||
params[i].value.l =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.l;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
|
||||
params[i].value.ul =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.ul;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
|
||||
params[i].value.d =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.d;
|
||||
break;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
|
||||
params[i].value.b =
|
||||
ret.params.params_val[i].value.remote_blkio_param_value_u.b;
|
||||
break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetBlkioParameters: "
|
||||
"unknown parameter type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (remoteDeserializeTypedParameters(ret.params.params_len,
|
||||
ret.params.params_val,
|
||||
REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX,
|
||||
params,
|
||||
nparams) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rv = 0;
|
||||
|
||||
@ -2475,7 +2437,6 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
|
||||
int rv = -1;
|
||||
remote_domain_get_scheduler_parameters_args args;
|
||||
remote_domain_get_scheduler_parameters_ret ret;
|
||||
int i = -1;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
@ -2489,45 +2450,12 @@ remoteDomainGetSchedulerParameters (virDomainPtr domain,
|
||||
(xdrproc_t) xdr_remote_domain_get_scheduler_parameters_ret, (char *) &ret) == -1)
|
||||
goto done;
|
||||
|
||||
/* Check the length of the returned list carefully. */
|
||||
if (ret.params.params_len > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX ||
|
||||
ret.params.params_len > *nparams) {
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetSchedulerParameters: "
|
||||
"returned number of parameters exceeds limit"));
|
||||
if (remoteDeserializeTypedParameters(ret.params.params_len,
|
||||
ret.params.params_val,
|
||||
REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX,
|
||||
params,
|
||||
nparams) < 0)
|
||||
goto cleanup;
|
||||
}
|
||||
*nparams = ret.params.params_len;
|
||||
|
||||
/* Deserialise the result. */
|
||||
for (i = 0; i < *nparams; ++i) {
|
||||
if (virStrcpyStatic(params[i].field, ret.params.params_val[i].field) == NULL) {
|
||||
remoteError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Parameter %s too big for destination"),
|
||||
ret.params.params_val[i].field);
|
||||
goto cleanup;
|
||||
}
|
||||
params[i].type = ret.params.params_val[i].value.type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
params[i].value.i = ret.params.params_val[i].value.remote_sched_param_value_u.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
params[i].value.ui = ret.params.params_val[i].value.remote_sched_param_value_u.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
params[i].value.l = ret.params.params_val[i].value.remote_sched_param_value_u.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
params[i].value.ul = ret.params.params_val[i].value.remote_sched_param_value_u.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
params[i].value.d = ret.params.params_val[i].value.remote_sched_param_value_u.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
params[i].value.b = ret.params.params_val[i].value.remote_sched_param_value_u.b; break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s",
|
||||
_("remoteDomainGetSchedulerParameters: "
|
||||
"unknown parameter type"));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
@ -2544,50 +2472,17 @@ remoteDomainSetSchedulerParameters (virDomainPtr domain,
|
||||
{
|
||||
int rv = -1;
|
||||
remote_domain_set_scheduler_parameters_args args;
|
||||
int i, do_error;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
make_nonnull_domain (&args.dom, domain);
|
||||
|
||||
/* Serialise the scheduler parameters. */
|
||||
args.params.params_len = nparams;
|
||||
if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto done;
|
||||
}
|
||||
|
||||
do_error = 0;
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* call() will free this: */
|
||||
args.params.params_val[i].field = strdup (params[i].field);
|
||||
if (args.params.params_val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
do_error = 1;
|
||||
}
|
||||
args.params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.i = params[i].value.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.ui = params[i].value.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.l = params[i].value.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.ul = params[i].value.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.d = params[i].value.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s", _("unknown parameter type"));
|
||||
do_error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_error) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_args, (char *) &args);
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&args.params.params_len,
|
||||
&args.params.params_val) < 0) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_args,
|
||||
(char *) &args);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -2611,51 +2506,19 @@ remoteDomainSetSchedulerParametersFlags(virDomainPtr domain,
|
||||
{
|
||||
int rv = -1;
|
||||
remote_domain_set_scheduler_parameters_flags_args args;
|
||||
int i, do_error;
|
||||
struct private_data *priv = domain->conn->privateData;
|
||||
|
||||
remoteDriverLock(priv);
|
||||
|
||||
make_nonnull_domain (&args.dom, domain);
|
||||
|
||||
/* Serialise the scheduler parameters. */
|
||||
args.params.params_len = nparams;
|
||||
args.flags = flags;
|
||||
if (VIR_ALLOC_N(args.params.params_val, nparams) < 0) {
|
||||
virReportOOMError();
|
||||
goto done;
|
||||
}
|
||||
|
||||
do_error = 0;
|
||||
for (i = 0; i < nparams; ++i) {
|
||||
/* call() will free this: */
|
||||
args.params.params_val[i].field = strdup (params[i].field);
|
||||
if (args.params.params_val[i].field == NULL) {
|
||||
virReportOOMError();
|
||||
do_error = 1;
|
||||
}
|
||||
args.params.params_val[i].value.type = params[i].type;
|
||||
switch (params[i].type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.i = params[i].value.i; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.ui = params[i].value.ui; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.l = params[i].value.l; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.ul = params[i].value.ul; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.d = params[i].value.d; break;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
args.params.params_val[i].value.remote_sched_param_value_u.b = params[i].value.b; break;
|
||||
default:
|
||||
remoteError(VIR_ERR_RPC, "%s", _("unknown parameter type"));
|
||||
do_error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_error) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_flags_args, (char *) &args);
|
||||
if (remoteSerializeTypedParameters(params, nparams,
|
||||
&args.params.params_len,
|
||||
&args.params.params_val) < 0) {
|
||||
xdr_free ((xdrproc_t) xdr_remote_domain_set_scheduler_parameters_flags_args,
|
||||
(char *) &args);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -296,67 +296,27 @@ struct remote_vcpu_info {
|
||||
int cpu;
|
||||
};
|
||||
|
||||
/* Wire encoding of virDomainSchedParameter.
|
||||
/* Wire encoding of virTypedParameter.
|
||||
* Note the enum (type) which must remain binary compatible.
|
||||
*/
|
||||
union remote_sched_param_value switch (int type) {
|
||||
case VIR_DOMAIN_SCHED_FIELD_INT:
|
||||
union remote_typed_param_value switch (int type) {
|
||||
case VIR_TYPED_PARAM_INT:
|
||||
int i;
|
||||
case VIR_DOMAIN_SCHED_FIELD_UINT:
|
||||
case VIR_TYPED_PARAM_UINT:
|
||||
unsigned int ui;
|
||||
case VIR_DOMAIN_SCHED_FIELD_LLONG:
|
||||
case VIR_TYPED_PARAM_LLONG:
|
||||
hyper l;
|
||||
case VIR_DOMAIN_SCHED_FIELD_ULLONG:
|
||||
case VIR_TYPED_PARAM_ULLONG:
|
||||
unsigned hyper ul;
|
||||
case VIR_DOMAIN_SCHED_FIELD_DOUBLE:
|
||||
case VIR_TYPED_PARAM_DOUBLE:
|
||||
double d;
|
||||
case VIR_DOMAIN_SCHED_FIELD_BOOLEAN:
|
||||
case VIR_TYPED_PARAM_BOOLEAN:
|
||||
int b;
|
||||
};
|
||||
|
||||
struct remote_sched_param {
|
||||
struct remote_typed_param {
|
||||
remote_nonnull_string field;
|
||||
remote_sched_param_value value;
|
||||
};
|
||||
|
||||
union remote_blkio_param_value switch (int type) {
|
||||
case VIR_DOMAIN_BLKIO_PARAM_INT:
|
||||
int i;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_UINT:
|
||||
unsigned int ui;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_LLONG:
|
||||
hyper l;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_ULLONG:
|
||||
unsigned hyper ul;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_DOUBLE:
|
||||
double d;
|
||||
case VIR_DOMAIN_BLKIO_PARAM_BOOLEAN:
|
||||
int b;
|
||||
};
|
||||
|
||||
struct remote_blkio_param {
|
||||
remote_nonnull_string field;
|
||||
remote_blkio_param_value value;
|
||||
};
|
||||
|
||||
union remote_memory_param_value switch (int type) {
|
||||
case VIR_DOMAIN_MEMORY_PARAM_INT:
|
||||
int i;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_UINT:
|
||||
unsigned int ui;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_LLONG:
|
||||
hyper l;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_ULLONG:
|
||||
unsigned hyper ul;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_DOUBLE:
|
||||
double d;
|
||||
case VIR_DOMAIN_MEMORY_PARAM_BOOLEAN:
|
||||
int b;
|
||||
};
|
||||
|
||||
struct remote_memory_param {
|
||||
remote_nonnull_string field;
|
||||
remote_memory_param_value value;
|
||||
remote_typed_param_value value;
|
||||
};
|
||||
|
||||
/*----- Calls. -----*/
|
||||
@ -471,23 +431,23 @@ struct remote_domain_get_scheduler_parameters_args {
|
||||
};
|
||||
|
||||
struct remote_domain_get_scheduler_parameters_ret {
|
||||
remote_sched_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
};
|
||||
|
||||
struct remote_domain_set_scheduler_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
remote_sched_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
};
|
||||
|
||||
struct remote_domain_set_scheduler_parameters_flags_args {
|
||||
remote_nonnull_domain dom;
|
||||
remote_sched_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX>;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct remote_domain_set_blkio_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
remote_blkio_param params<REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX>;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
@ -498,13 +458,13 @@ struct remote_domain_get_blkio_parameters_args {
|
||||
};
|
||||
|
||||
struct remote_domain_get_blkio_parameters_ret {
|
||||
remote_blkio_param params<REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX>;
|
||||
int nparams;
|
||||
};
|
||||
|
||||
struct remote_domain_set_memory_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
remote_memory_param params<REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX>;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
@ -515,7 +475,7 @@ struct remote_domain_get_memory_parameters_args {
|
||||
};
|
||||
|
||||
struct remote_domain_get_memory_parameters_ret {
|
||||
remote_memory_param params<REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX>;
|
||||
remote_typed_param params<REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX>;
|
||||
int nparams;
|
||||
};
|
||||
|
||||
|
@ -56,7 +56,7 @@ struct remote_vcpu_info {
|
||||
uint64_t cpu_time;
|
||||
int cpu;
|
||||
};
|
||||
struct remote_sched_param_value {
|
||||
struct remote_typed_param_value {
|
||||
int type;
|
||||
union {
|
||||
int i;
|
||||
@ -65,41 +65,11 @@ struct remote_sched_param_value {
|
||||
uint64_t ul;
|
||||
double d;
|
||||
int b;
|
||||
} remote_sched_param_value_u;
|
||||
} remote_typed_param_value_u;
|
||||
};
|
||||
struct remote_sched_param {
|
||||
struct remote_typed_param {
|
||||
remote_nonnull_string field;
|
||||
remote_sched_param_value value;
|
||||
};
|
||||
struct remote_blkio_param_value {
|
||||
int type;
|
||||
union {
|
||||
int i;
|
||||
u_int ui;
|
||||
int64_t l;
|
||||
uint64_t ul;
|
||||
double d;
|
||||
int b;
|
||||
} remote_blkio_param_value_u;
|
||||
};
|
||||
struct remote_blkio_param {
|
||||
remote_nonnull_string field;
|
||||
remote_blkio_param_value value;
|
||||
};
|
||||
struct remote_memory_param_value {
|
||||
int type;
|
||||
union {
|
||||
int i;
|
||||
u_int ui;
|
||||
int64_t l;
|
||||
uint64_t ul;
|
||||
double d;
|
||||
int b;
|
||||
} remote_memory_param_value_u;
|
||||
};
|
||||
struct remote_memory_param {
|
||||
remote_nonnull_string field;
|
||||
remote_memory_param_value value;
|
||||
remote_typed_param_value value;
|
||||
};
|
||||
struct remote_open_args {
|
||||
remote_string name;
|
||||
@ -178,21 +148,21 @@ struct remote_domain_get_scheduler_parameters_args {
|
||||
struct remote_domain_get_scheduler_parameters_ret {
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_sched_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
};
|
||||
struct remote_domain_set_scheduler_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_sched_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
};
|
||||
struct remote_domain_set_scheduler_parameters_flags_args {
|
||||
remote_nonnull_domain dom;
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_sched_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
u_int flags;
|
||||
};
|
||||
@ -200,7 +170,7 @@ struct remote_domain_set_blkio_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_blkio_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
u_int flags;
|
||||
};
|
||||
@ -212,7 +182,7 @@ struct remote_domain_get_blkio_parameters_args {
|
||||
struct remote_domain_get_blkio_parameters_ret {
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_blkio_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
int nparams;
|
||||
};
|
||||
@ -220,7 +190,7 @@ struct remote_domain_set_memory_parameters_args {
|
||||
remote_nonnull_domain dom;
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_memory_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
u_int flags;
|
||||
};
|
||||
@ -232,7 +202,7 @@ struct remote_domain_get_memory_parameters_args {
|
||||
struct remote_domain_get_memory_parameters_ret {
|
||||
struct {
|
||||
u_int params_len;
|
||||
remote_memory_param * params_val;
|
||||
remote_typed_param * params_val;
|
||||
} params;
|
||||
int nparams;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user