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 | 12 +++++++-
src/remote_protocol-structs | 13 ++++++++
4 files changed, 148 insertions(+), 1 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 060c5a0..c1e30c0 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4006,6 +4006,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) {
+ virNetError(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 ab821d5..179e7af 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2715,6 +2715,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)
@@ -5483,6 +5548,7 @@ static virStorageDriver storage_driver = {
.poolSetAutostart = remoteStoragePoolSetAutostart, /* 0.4.1 */
.poolNumOfVolumes = remoteStoragePoolNumOfVolumes, /* 0.4.1 */
.poolListVolumes = remoteStoragePoolListVolumes, /* 0.4.1 */
+ .poolListAllVolumes = remoteStoragePoolListAllVolumes, /* 0.9.14 */
.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 dfd67bc..d090705 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1655,7 +1655,16 @@ struct remote_storage_pool_list_volumes_ret {
remote_nonnull_string names<REMOTE_STORAGE_VOL_NAME_LIST_MAX>; /* insert@1 */
};
+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;
+};
/* Storage vol calls: */
@@ -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_CONNECT_LIST_ALL_STORAGE_POOLS = 277 /* skipgen skipgen priority:high */
+ REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277, /* skipgen skipgen priority:high
*/
+ REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 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 25cb819..9d81ad0 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -1985,6 +1985,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,
@@ -2263,4 +2275,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_SNAPSHOT_LIST_ALL_CHILDREN = 275,
REMOTE_PROC_DOMAIN_EVENT_BALLOON_CHANGE = 276,
REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 277,
+ REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 278,
};
--
1.7.7.3