The RPC generator doesn't support returning list of object, this patch do
the work manually.
* daemon/remote.c:
Implement the server side handler remoteDispatchConnectListAllStoragePools
* src/remote/remote_driver.c:
Add remote driver handler remoteConnectListAllStoragePools.
* src/remote/remote_protocol.x:
New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS 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 | 12 +++++++-
src/remote_protocol-structs | 12 ++++++++
4 files changed, 141 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 851bcc1..d1e95a9 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3945,6 +3945,60 @@ cleanup:
return rv;
}
+static int
+remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg ATTRIBUTE_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_connect_list_all_storage_pools_args
*args,
+ remote_connect_list_all_storage_pools_ret *ret)
+{
+ virStoragePoolPtr *pools = NULL;
+ int npools = 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 ((npools = virConnectListAllStoragePools(priv->conn,
+ args->need_results ? &pools :
NULL,
+ args->flags)) < 0)
+ goto cleanup;
+
+ if (pools && npools) {
+ if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ ret->pools.pools_len = npools;
+
+ for (i = 0; i < npools; i++)
+ make_nonnull_storage_pool(ret->pools.pools_val + i, pools[i]);
+ } else {
+ ret->pools.pools_len = 0;
+ ret->pools.pools_val = NULL;
+ }
+
+ ret->ret = npools;
+
+ rv = 0;
+
+cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ if (pools) {
+ for (i = 0; i < npools; i++)
+ virStoragePoolFree(pools[i]);
+ VIR_FREE(pools);
+ }
+ 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 c4941c5..fbcde99 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2673,6 +2673,69 @@ done:
return rv;
}
+static int
+remoteConnectListAllStoragePools (virConnectPtr conn,
+ virStoragePoolPtr **pools,
+ unsigned int flags)
+{
+ int rv = -1;
+ int i;
+ virStoragePoolPtr *tmp_pools = NULL;
+ remote_connect_list_all_storage_pools_args args;
+ remote_connect_list_all_storage_pools_ret ret;
+
+ struct private_data *priv = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.need_results = !!pools;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ if (call(conn,
+ priv,
+ 0,
+ REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS,
+ (xdrproc_t) xdr_remote_connect_list_all_storage_pools_args,
+ (char *) &args,
+ (xdrproc_t) xdr_remote_connect_list_all_storage_pools_ret,
+ (char *) &ret) == -1)
+ goto done;
+
+ if (pools) {
+ if (VIR_ALLOC_N(tmp_pools, ret.pools.pools_len + 1) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ for (i = 0; i < ret.pools.pools_len; i++) {
+ tmp_pools[i] = get_nonnull_storage_pool(conn, ret.pools.pools_val[i]);
+ if (!tmp_pools[i]) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+ *pools = tmp_pools;
+ tmp_pools = NULL;
+ }
+
+ rv = ret.ret;
+
+cleanup:
+ if (tmp_pools) {
+ for (i = 0; i < ret.pools.pools_len; i++)
+ if (tmp_pools[i])
+ virStoragePoolFree(tmp_pools[i]);
+ VIR_FREE(tmp_pools);
+ }
+
+ xdr_free((xdrproc_t) xdr_remote_connect_list_all_storage_pools_ret, (char *)
&ret);
+
+done:
+ remoteDriverUnlock(priv);
+ return rv;
+}
+
/*----------------------------------------------------------------------*/
static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -5424,6 +5487,7 @@ static virStorageDriver storage_driver = {
.listPools = remoteListStoragePools, /* 0.4.1 */
.numOfDefinedPools = remoteNumOfDefinedStoragePools, /* 0.4.1 */
.listDefinedPools = remoteListDefinedStoragePools, /* 0.4.1 */
+ .listAllPools = remoteConnectListAllStoragePools, /* 0.10.0 */
.findPoolSources = remoteFindStoragePoolSources, /* 0.4.5 */
.poolLookupByName = remoteStoragePoolLookupByName, /* 0.4.1 */
.poolLookupByUUID = remoteStoragePoolLookupByUUID, /* 0.4.1 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 200fe75..194b01e 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2527,6 +2527,15 @@ struct remote_connect_list_all_domains_ret {
unsigned int ret;
};
+struct remote_connect_list_all_storage_pools_args {
+ int need_results;
+ unsigned int flags;
+};
+
+struct remote_connect_list_all_storage_pools_ret {
+ remote_nonnull_storage_pool pools<>;
+ unsigned int ret;
+};
/*----- Protocol. -----*/
@@ -2854,7 +2863,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274, /* skipgen skipgen priority:high */
REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275, /* skipgen skipgen priority:high
*/
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276, /* autogen autogen */
- REMOTE_PROC_DOMAIN_GET_HOSTNAME = 277 /* autogen autogen */
+ REMOTE_PROC_DOMAIN_GET_HOSTNAME = 277, /* autogen autogen */
+ REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 278 /* 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 8d09138..c47ba15 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1981,6 +1981,17 @@ struct remote_connect_list_all_domains_ret {
} domains;
u_int ret;
};
+struct remote_connect_list_all_storage_pools_args {
+ int need_results;
+ u_int flags;
+};
+struct remote_connect_list_all_storage_pools_ret {
+ struct {
+ u_int pools_len;
+ remote_nonnull_domain * pools_val;
+ } pools;
+ u_int ret;
+};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
@@ -2259,4 +2270,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275,
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276,
REMOTE_PROC_DOMAIN_GET_HOSTNAME = 277,
+ REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 278,
};
--
1.7.7.3