diff options
author | Osier Yang <jyang@redhat.com> | 2012-09-14 16:38:49 +0800 |
---|---|---|
committer | Osier Yang <jyang@redhat.com> | 2012-09-17 13:17:14 +0800 |
commit | 867374079d7814750b32541c8f3816960408f450 (patch) | |
tree | be9785b7ff0adcc2bf2b98039991d4e7fc2486dd /daemon | |
parent | list: Define new API virConnectListAllSecrets (diff) | |
download | libvirt-867374079d7814750b32541c8f3816960408f450.tar.gz libvirt-867374079d7814750b32541c8f3816960408f450.tar.bz2 libvirt-867374079d7814750b32541c8f3816960408f450.zip |
list: Implement RPC calls for virConnectListAllSecrets
The RPC generator doesn't support returning list of object yet, this patch
does the work manually.
* daemon/remote.c:
Implement the server side handler remoteDispatchConnectListAllSecrets.
* src/remote/remote_driver.c:
Add remote driver handler remoteConnectListAllSecrets.
* src/remote/remote_protocol.x:
New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_SECRETS and
structs to represent the args and ret for it.
* src/remote_protocol-structs: Likewise.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/remote.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/daemon/remote.c b/daemon/remote.c index abd7edf0f..6f20761d5 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4429,6 +4429,60 @@ cleanup: return rv; } +static int +remoteDispatchConnectListAllSecrets(virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_connect_list_all_secrets_args *args, + remote_connect_list_all_secrets_ret *ret) +{ + virSecretPtr *secrets = NULL; + int nsecrets = 0; + int i; + int rv = -1; + struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + if ((nsecrets = virConnectListAllSecrets(priv->conn, + args->need_results ? &secrets : NULL, + args->flags)) < 0) + goto cleanup; + + if (secrets && nsecrets) { + if (VIR_ALLOC_N(ret->secrets.secrets_val, nsecrets) < 0) { + virReportOOMError(); + goto cleanup; + } + + ret->secrets.secrets_len = nsecrets; + + for (i = 0; i < nsecrets; i++) + make_nonnull_secret(ret->secrets.secrets_val + i, secrets[i]); + } else { + ret->secrets.secrets_len = 0; + ret->secrets.secrets_val = NULL; + } + + ret->ret = nsecrets; + + rv = 0; + +cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + if (secrets) { + for (i = 0; i < nsecrets; i++) + virSecretFree(secrets[i]); + VIR_FREE(secrets); + } + return rv; +} + /*----- Helpers. -----*/ /* get_nonnull_domain and get_nonnull_network turn an on-wire |