diff options
author | Osier Yang <jyang@redhat.com> | 2012-09-04 23:32:54 +0800 |
---|---|---|
committer | Osier Yang <jyang@redhat.com> | 2012-09-10 10:37:43 +0800 |
commit | a8bac1c0f3b9ff8dd3982a7086d45466055ea0d1 (patch) | |
tree | aba58a4bad79811b584ebc8214c7ea7beacc7779 /daemon | |
parent | list: Define new API virStoragePoolListAllVolumes (diff) | |
download | libvirt-a8bac1c0f3b9ff8dd3982a7086d45466055ea0d1.tar.gz libvirt-a8bac1c0f3b9ff8dd3982a7086d45466055ea0d1.tar.bz2 libvirt-a8bac1c0f3b9ff8dd3982a7086d45466055ea0d1.zip |
list: Implement RPC calls for virStoragePoolListAllVolumes
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.
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/remote.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/daemon/remote.c b/daemon/remote.c index 5d2dd441f..f86f7ecea 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -4155,6 +4155,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 |