提交 86737407 编写于 作者: O Osier Yang

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.
上级 7a236982
...@@ -4429,6 +4429,60 @@ cleanup: ...@@ -4429,6 +4429,60 @@ cleanup:
return rv; 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. -----*/ /*----- Helpers. -----*/
/* get_nonnull_domain and get_nonnull_network turn an on-wire /* get_nonnull_domain and get_nonnull_network turn an on-wire
......
...@@ -2970,6 +2970,69 @@ done: ...@@ -2970,6 +2970,69 @@ done:
return rv; 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) static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
...@@ -6047,6 +6110,7 @@ static virSecretDriver secret_driver = { ...@@ -6047,6 +6110,7 @@ static virSecretDriver secret_driver = {
.close = remoteSecretClose, /* 0.7.1 */ .close = remoteSecretClose, /* 0.7.1 */
.numOfSecrets = remoteNumOfSecrets, /* 0.7.1 */ .numOfSecrets = remoteNumOfSecrets, /* 0.7.1 */
.listSecrets = remoteListSecrets, /* 0.7.1 */ .listSecrets = remoteListSecrets, /* 0.7.1 */
.listAllSecrets = remoteConnectListAllSecrets, /* 0.10.2 */
.lookupByUUID = remoteSecretLookupByUUID, /* 0.7.1 */ .lookupByUUID = remoteSecretLookupByUUID, /* 0.7.1 */
.lookupByUsage = remoteSecretLookupByUsage, /* 0.7.1 */ .lookupByUsage = remoteSecretLookupByUsage, /* 0.7.1 */
.defineXML = remoteSecretDefineXML, /* 0.7.1 */ .defineXML = remoteSecretDefineXML, /* 0.7.1 */
......
...@@ -2619,6 +2619,16 @@ struct remote_connect_list_all_nwfilters_ret { ...@@ -2619,6 +2619,16 @@ struct remote_connect_list_all_nwfilters_ret {
unsigned int 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. -----*/ /*----- Protocol. -----*/
/* Define the program number, protocol version and procedure numbers here. */ /* Define the program number, protocol version and procedure numbers here. */
...@@ -2955,7 +2965,8 @@ enum remote_procedure { ...@@ -2955,7 +2965,8 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283, /* skipgen skipgen priority:high */ 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_INTERFACES = 284, /* skipgen skipgen priority:high */
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285, /* 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 ? * Notice how the entries are grouped in sets of 10 ?
......
...@@ -2078,6 +2078,17 @@ struct remote_connect_list_all_nwfilters_ret { ...@@ -2078,6 +2078,17 @@ struct remote_connect_list_all_nwfilters_ret {
} filters; } filters;
u_int ret; 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_secret * secrets_val;
} secrets;
u_int ret;
};
enum remote_procedure { enum remote_procedure {
REMOTE_PROC_OPEN = 1, REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2, REMOTE_PROC_CLOSE = 2,
...@@ -2365,4 +2376,5 @@ enum remote_procedure { ...@@ -2365,4 +2376,5 @@ enum remote_procedure {
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284, REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284,
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285, REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285,
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286, REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286,
REMOTE_PROC_CONNECT_LIST_ALL_SECRETS = 287,
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册