提交 9afc115f 编写于 作者: E Erik Skultety

util: Export remoteFreeTypedParameters internally via util

Since the method is static to remote_driver, it can't even be used by our
daemon. Other than that, it would be useful to be able to use it with admin as
well. This patch uses the new virTypedParameterRemote datatype introduced in
one of previous patches.
上级 0472cef6
......@@ -2353,6 +2353,7 @@ virTypedParamsCopy;
virTypedParamsDeserialize;
virTypedParamsFilter;
virTypedParamsGetStringList;
virTypedParamsRemoteFree;
virTypedParamsReplaceString;
virTypedParamsValidate;
......
......@@ -1663,25 +1663,6 @@ remoteConnectListAllDomains(virConnectPtr conn,
return rv;
}
/* Helper to free typed parameters. */
static void
remoteFreeTypedParameters(remote_typed_param *args_params_val,
u_int args_params_len)
{
size_t i;
if (args_params_val == NULL)
return;
for (i = 0; i < args_params_len; i++) {
VIR_FREE(args_params_val[i].field);
if (args_params_val[i].value.type == VIR_TYPED_PARAM_STRING)
VIR_FREE(args_params_val[i].value.remote_typed_param_value_u.s);
}
VIR_FREE(args_params_val);
}
/* Helper to serialize typed parameters. */
static int
remoteSerializeTypedParameters(virTypedParameterPtr params,
......@@ -1738,7 +1719,7 @@ remoteSerializeTypedParameters(virTypedParameterPtr params,
rv = 0;
cleanup:
remoteFreeTypedParameters(val, nparams);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) val, nparams);
return rv;
}
......@@ -6991,7 +6972,8 @@ remoteDomainMigrateBegin3Params(virDomainPtr domain,
rv = ret.xml; /* caller frees */
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
remoteDriverUnlock(priv);
return rv;
......@@ -7069,7 +7051,8 @@ remoteDomainMigratePrepare3Params(virConnectPtr dconn,
rv = 0;
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
VIR_FREE(ret.uri_out);
remoteDriverUnlock(priv);
return rv;
......@@ -7159,7 +7142,8 @@ remoteDomainMigratePrepareTunnel3Params(virConnectPtr dconn,
rv = 0;
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
remoteDriverUnlock(priv);
return rv;
......@@ -7231,7 +7215,8 @@ remoteDomainMigratePerform3Params(virDomainPtr dom,
rv = 0;
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
remoteDriverUnlock(priv);
return rv;
......@@ -7307,7 +7292,8 @@ remoteDomainMigrateFinish3Params(virConnectPtr dconn,
(char *) &ret);
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
remoteDriverUnlock(priv);
return rv;
......@@ -7363,7 +7349,8 @@ remoteDomainMigrateConfirm3Params(virDomainPtr domain,
rv = 0;
cleanup:
remoteFreeTypedParameters(args.params.params_val, args.params.params_len);
virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,
args.params.params_len);
remoteDriverUnlock(priv);
return rv;
}
......
......@@ -1217,7 +1217,8 @@ elsif ($mode eq "client") {
" xdr_free((xdrproc_t)xdr_$call->{args}, (char *)&args);\n" .
" goto done;\n" .
" }");
push(@free_list, " remoteFreeTypedParameters(args.params.params_val, args.params.params_len);\n");
push(@free_list, " virTypedParamsRemoteFree((virTypedParameterRemotePtr) args.params.params_val,\n" .
" args.params.params_len);\n");
} elsif ($args_member =~ m/^((?:unsigned )?int) (\S+);\s*\/\*\s*call-by-reference\s*\*\//) {
my $type_name = "$1 *";
my $arg_name = $2;
......
......@@ -1316,6 +1316,35 @@ virTypedParamsFree(virTypedParameterPtr params,
VIR_FREE(params);
}
/**
* virTypedParamsRemoteFree:
* @remote_params_val: array of typed parameters as specified by
* (remote|admin)_protocol.h
* @remote_params_len: number of parameters in @remote_params_val
*
* Frees memory used by string representations of parameter identificators,
* memory used by string values of parameters and the memory occupied by
* @remote_params_val itself.
*
* Returns nothing.
*/
void
virTypedParamsRemoteFree(virTypedParameterRemotePtr remote_params_val,
unsigned int remote_params_len)
{
size_t i;
if (!remote_params_val)
return;
for (i = 0; i < remote_params_len; i++) {
VIR_FREE(remote_params_val[i].field);
if (remote_params_val[i].value.type == VIR_TYPED_PARAM_STRING)
VIR_FREE(remote_params_val[i].value.remote_typed_param_value.s);
}
VIR_FREE(remote_params_val);
}
/**
* virTypedParamsDeserialize:
......
......@@ -104,6 +104,9 @@ int virTypedParamsCopy(virTypedParameterPtr *dst,
char *virTypedParameterToString(virTypedParameterPtr param);
void virTypedParamsRemoteFree(virTypedParameterRemotePtr remote_params_val,
unsigned int remote_params_len);
int virTypedParamsDeserialize(virTypedParameterRemotePtr remote_params,
unsigned int remote_params_len,
int limit,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册