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 9334221..060c5a0 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3952,6 +3952,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) {
+        virNetError(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 d91ae87..ab821d5 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2652,6 +2652,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)
@@ -5401,6 +5464,7 @@ static virStorageDriver storage_driver = {
     .listPools = remoteListStoragePools, /* 0.4.1 */
     .numOfDefinedPools = remoteNumOfDefinedStoragePools, /* 0.4.1 */
     .listDefinedPools = remoteListDefinedStoragePools, /* 0.4.1 */
+    .listAllPools = remoteConnectListAllStoragePools, /* 0.9.14 */
     .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 8f1d9b5..dfd67bc 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2518,6 +2518,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. -----*/
 
@@ -2844,7 +2853,8 @@ enum remote_procedure {
     REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273, /* skipgen skipgen 
priority:high */
     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_EVENT_BALLOON_CHANGE = 276, /* autogen autogen */
+    REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277 /* 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 511284c..25cb819 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1974,6 +1974,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,
@@ -2251,4 +2262,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_LIST_ALL_SNAPSHOTS = 274,
         REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275,
         REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276,
+        REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277,
 };
-- 
1.7.7.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to