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 9056439..8208c71 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4153,6 +4153,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 c1f9044..8d4420e 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2920,6 +2920,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) @@ -5694,6 +5759,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 9de3404..e540167 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -2568,6 +2568,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. */ @@ -2899,7 +2910,8 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279, /* skipgen skipgen */ REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, /* skipgen skipgen */ - REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281 /* skipgen skipgen priority:high */ + REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, /* skipgen skipgen priority:high */ + REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282 /* 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 560299b..f105a38 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2022,6 +2022,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, @@ -2304,4 +2316,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_PIN_EMULATOR = 279, REMOTE_PROC_DOMAIN_GET_EMULATOR_PIN_INFO = 280, REMOTE_PROC_CONNECT_LIST_ALL_STORAGE_POOLS = 281, + REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282, }; -- 1.7.7.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list