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 abd7edf..6f20761 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
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index f5bb6ac..ee2cd50 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2970,6 +2970,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)
@@ -6047,6 +6110,7 @@ static virSecretDriver secret_driver = {
.close = remoteSecretClose, /* 0.7.1 */
.numOfSecrets = remoteNumOfSecrets, /* 0.7.1 */
.listSecrets = remoteListSecrets, /* 0.7.1 */
+ .listAllSecrets = remoteConnectListAllSecrets, /* 0.10.2 */
.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 46269c8..1fc7f25 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2619,6 +2619,16 @@ struct remote_connect_list_all_nwfilters_ret {
unsigned int ret;
};
+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;
+};
+
/*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */
@@ -2955,7 +2965,8 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285, /* skipgen skipgen priority:high */
- REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286, /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287 /* 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 a465cf3..86416ad 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2078,6 +2078,17 @@ struct remote_connect_list_all_nwfilters_ret {
} filters;
u_int ret;
};
+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;
+};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
@@ -2365,4 +2376,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284,
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285,
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286,
+ REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287,
};
--
1.7.7.3