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.
---
src/libvirt_private.syms | 1 +
src/remote/remote_driver.c | 39 +++++++++++++--------------------------
src/rpc/gendispatch.pl | 3 ++-
src/util/virtypedparam.c | 29 +++++++++++++++++++++++++++++
src/util/virtypedparam.h | 3 +++
5 files changed, 48 insertions(+), 27 deletions(-)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f25c6fa..690e957 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2353,6 +2353,7 @@ virTypedParamsCopy;
virTypedParamsDeserialize;
virTypedParamsFilter;
virTypedParamsGetStringList;
+virTypedParamsRemoteFree;
virTypedParamsReplaceString;
virTypedParamsValidate;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b4c58e2..4d569c9 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -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;
}
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index d7f42b1..9d64e63 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -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;
diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c
index f1e7cf2..1bc7865 100644
--- a/src/util/virtypedparam.c
+++ b/src/util/virtypedparam.c
@@ -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:
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index 98bf3aa..df3547f 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -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,
--
2.4.3