The RPC generator doesn't support returning list of object yet, this patch
do the work manually.
* daemon/remote.c:
Implemente 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.
---
daemon/remote.c | 54 +++++++++++++++++++++++++++++++++++
src/remote/remote_driver.c | 64 ++++++++++++++++++++++++++++++++++++++++++
src/remote/remote_protocol.x | 13 ++++++++-
src/remote_protocol-structs | 12 ++++++++
4 files changed, 142 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 9de0629..d381dd9 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4280,6 +4280,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) {
+ virNetError(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
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 13d711b..06afb35 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3035,6 +3035,69 @@ done:
return rv;
}
+static int
+remoteConnectListAllSecrets(virConnectPtr conn,
+ virSecretPtr **secrets,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virSecretPtr *tmp_secrets = NULL;
+ remote_connect_list_all_secrets_args args;
+ remote_connect_list_all_secrets_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.need_results = !!secrets;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS,
+ (xdrproc_t) xdr_remote_connect_list_all_secrets_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_secrets_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (secrets) {
+ if (VIR_ALLOC_N(tmp_secrets, ret.secrets.secrets_len + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ret.secrets.secrets_len; i++) {
+ tmp_secrets[i] = get_nonnull_secret (conn, ret.secrets.secrets_val[i]);
+ if (!tmp_secrets[i]) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ *secrets = tmp_secrets;
+ tmp_secrets = NULL;
+ }
+
+ rv = ret.ret;
+
+cleanup:
+ if (tmp_secrets) {
+ for (i = 0; i < ret.secrets.secrets_len; i++)
+ if (tmp_secrets[i])
+ virSecretFree(tmp_secrets[i]);
+ VIR_FREE(tmp_secrets);
+ }
+
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_secrets_ret, (char *) &ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
/*----------------------------------------------------------------------*/
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -5831,6 +5894,7 @@ static virSecretDriver secret_driver = {
.close = remoteSecretClose, /* 0.7.1 */
.numOfSecrets = remoteNumOfSecrets, /* 0.7.1 */
.listSecrets = remoteListSecrets, /* 0.7.1 */
+ .listAllSecrets = remoteConnectListAllSecrets, /* 0.9.14 */
.lookupByUUID = remoteSecretLookupByUUID, /* 0.7.1 */
.lookupByUsage = remoteSecretLookupByUsage, /* 0.7.1 */
.defineXML = remoteSecretDefineXML, /* 0.7.1 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4b8b8b1..d884fc5 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1937,6 +1937,16 @@ struct remote_list_secrets_ret {
remote_nonnull_string uuids<REMOTE_SECRET_UUID_LIST_MAX>; /* insert@1 */
};
+struct remote_connect_list_all_secrets_args {
+ int need_results;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_secrets_ret {
+ remote_nonnull_secret secrets<>;
+ unsigned int ret;
+};
+
struct remote_secret_lookup_by_uuid_args {
remote_uuid uuid;
};
@@ -2909,7 +2919,8 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 281, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 282 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 282, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 283 /* skipgen skipgen priority:high */
/*
* Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 56004ab..d65f7eb 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1461,6 +1461,17 @@ struct remote_list_secrets_ret {
remote_nonnull_string * uuids_val;
} uuids;
};
+struct remote_list_all_secrets_args {
+ int need_results;
+ u_int flags;
+};
+struct remote_list_all_secrets_ret {
+ struct {
+ u_int secrets_len;
+ remote_nonnull_network * secrets_val;
+ } secrets;
+ u_int ret;
+};
struct remote_secret_lookup_by_uuid_args {
remote_uuid uuid;
};
@@ -2324,4 +2335,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 280,
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 281,
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 282,
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 283,
};
--
1.7.7.3