[PATCH 15/48] list: Implemente RPC calls for virStoragePoolListAllVolumes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The RPC generator doesn't returning support list of object, this
patch do the work manually.

  * daemon/remote.c:
    Implemente the server side handler remoteDispatchStoragePoolListAllVolumes

  * src/remote/remote_driver.c:
    Add remote driver handler remoteStoragePoolListAllVolumes

  * src/remote/remote_protocol.x:
    New RPC procedure REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES and
    structs to represent the args and ret for it.

  * src/remote_protocol-structs: Likewise.
---
 daemon/remote.c              |   58 ++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   66 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   14 ++++++++-
 src/remote_protocol-structs  |   13 ++++++++
 4 files changed, 150 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index ca3d5ee..f2223ec 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4002,6 +4002,64 @@ cleanup:
     return rv;
 }
 
+static int
+remoteDispatchStoragePoolListAllVolumes(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                        virNetServerClientPtr client,
+                                        virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                        virNetMessageErrorPtr rerr,
+                                        remote_storage_pool_list_all_volumes_args *args,
+                                        remote_storage_pool_list_all_volumes_ret *ret)
+{
+    virStorageVolPtr *vols = NULL;
+    virStoragePoolPtr pool = NULL;
+    int nvols = 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 (!(pool = get_nonnull_storage_pool(priv->conn, args->pool)))
+        goto cleanup;
+
+    if ((nvols = virStoragePoolListAllVolumes(pool,
+                                              args->need_results ? &vols : NULL,
+                                              args->flags)) < 0)
+        goto cleanup;
+
+    if (vols && nvols) {
+        if (VIR_ALLOC_N(ret->vols.vols_val, nvols) < 0) {
+            virReportOOMError();
+            goto cleanup;
+        }
+
+        ret->vols.vols_len = nvols;
+
+        for (i = 0; i < nvols; i++)
+            make_nonnull_storage_vol(ret->vols.vols_val + i, vols[i]);
+    } else {
+        ret->vols.vols_len = 0;
+        ret->vols.vols_val = NULL;
+    }
+
+    ret->ret = nvols;
+
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (vols) {
+        for (i = 0; i < nvols; i++)
+            virStorageVolFree(vols[i]);
+        VIR_FREE(vols);
+    }
+    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 8cf69d9..578d73f 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2734,6 +2734,71 @@ done:
     return rv;
 }
 
+static int
+remoteStoragePoolListAllVolumes(virStoragePoolPtr pool,
+                                virStorageVolPtr **vols,
+                                unsigned int flags)
+{
+    int rv = -1;
+    int i;
+    virStorageVolPtr *tmp_vols = NULL;
+    remote_storage_pool_list_all_volumes_args args;
+    remote_storage_pool_list_all_volumes_ret ret;
+
+    struct private_data *priv = pool->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_storage_pool(&args.pool, pool);
+    args.need_results = !!vols;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+    if (call(pool->conn,
+             priv,
+             0,
+             REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES,
+             (xdrproc_t) xdr_remote_storage_pool_list_all_volumes_args,
+             (char *) &args,
+             (xdrproc_t) xdr_remote_storage_pool_list_all_volumes_ret,
+             (char *) &ret) == -1)
+        goto done;
+
+    if (vols) {
+        if (VIR_ALLOC_N(tmp_vols, ret.vols.vols_len + 1) < 0) {
+            virReportOOMError();
+            goto cleanup;
+        }
+
+        for (i = 0; i < ret.vols.vols_len; i++) {
+            tmp_vols[i] = get_nonnull_storage_vol(pool->conn, ret.vols.vols_val[i]);
+            if (!tmp_vols[i]) {
+                virReportOOMError();
+                goto cleanup;
+            }
+        }
+        *vols = tmp_vols;
+        tmp_vols = NULL;
+    }
+
+    rv = ret.ret;
+
+cleanup:
+    if (tmp_vols) {
+        for (i = 0; i < ret.vols.vols_len; i++)
+            if (tmp_vols[i])
+                virStorageVolFree(tmp_vols[i]);
+        VIR_FREE(tmp_vols);
+    }
+
+    xdr_free((xdrproc_t) xdr_remote_storage_pool_list_all_volumes_ret, (char *) &ret);
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
+
 /*----------------------------------------------------------------------*/
 
 static virDrvOpenStatus ATTRIBUTE_NONNULL (1)
@@ -5503,6 +5568,7 @@ static virStorageDriver storage_driver = {
     .poolSetAutostart = remoteStoragePoolSetAutostart, /* 0.4.1 */
     .poolNumOfVolumes = remoteStoragePoolNumOfVolumes, /* 0.4.1 */
     .poolListVolumes = remoteStoragePoolListVolumes, /* 0.4.1 */
+    .poolListAllVolumes = remoteStoragePoolListAllVolumes, /* 0.10.0 */
 
     .volLookupByName = remoteStorageVolLookupByName, /* 0.4.1 */
     .volLookupByKey = remoteStorageVolLookupByKey, /* 0.4.1 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 194b01e..45a49fb 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -2537,6 +2537,17 @@ struct remote_connect_list_all_storage_pools_ret {
     unsigned int ret;
 };
 
+struct remote_storage_pool_list_all_volumes_args {
+    remote_nonnull_storage_pool pool;
+    int need_results;
+    unsigned int flags;
+};
+
+struct remote_storage_pool_list_all_volumes_ret {
+    remote_nonnull_storage_vol vols<>;
+    unsigned int ret;
+};
+
 /*----- Protocol. -----*/
 
 /* Define the program number, protocol version and procedure numbers here. */
@@ -2864,7 +2875,8 @@ enum remote_procedure {
     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_CONNECT_LIST_ALL_STORAGE_POOLS = 278 /* skipgen skipgen priority:high */
+    REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 278, /* skipgen skipgen priority:high */
+    REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 279 /* 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 c47ba15..d425a8b 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1992,6 +1992,18 @@ struct remote_connect_list_all_storage_pools_ret {
         } pools;
         u_int                      ret;
 };
+struct remote_storage_pool_list_all_volumes_args {
+        remote_nonnull_storage_pool pool;
+        int                        need_results;
+        u_int                      flags;
+};
+struct remote_storage_pool_list_all_volumes_ret {
+        struct {
+                u_int              vols_len;
+                remote_nonnull_storage_vol * vols_val;
+        } vols;
+        u_int                      ret;
+};
 enum remote_procedure {
         REMOTE_PROC_OPEN = 1,
         REMOTE_PROC_CLOSE = 2,
@@ -2271,4 +2283,5 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276,
         REMOTE_PROC_DOMAIN_GET_HOSTNAME = 277,
         REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 278,
+        REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 279,
 };
-- 
1.7.7.3

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]