Simply returns the storage volume objects. No supported filter
flags.
include/libvirt/libvirt.h.in: Declare the API
python/generator.py: Skip the function for generating. virStoragePool.py
will be added in later patch.
src/driver.h: virDrvStoragePoolListVolumesFlags
src/libvirt.c: Implementation for the API.
src/libvirt_public.syms: Export the symbol to public
---
include/libvirt/libvirt.h.in | 3 ++
python/generator.py | 1 +
src/driver.h | 6 ++++-
src/libvirt.c | 50 ++++++++++++++++++++++++++++++++++++++++++
src/libvirt_public.syms | 1 +
5 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index c7e810e..c5b16bf 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -2570,6 +2570,9 @@ int virStoragePoolNumOfVolumes
(virStoragePoolPtr pool)
int virStoragePoolListVolumes (virStoragePoolPtr pool,
char **const names,
int maxnames);
+int virStoragePoolListAllVolumes (virStoragePoolPtr pool,
+ virStorageVolPtr **vols,
+ unsigned int flags);
virConnectPtr virStorageVolGetConnect (virStorageVolPtr vol);
diff --git a/python/generator.py b/python/generator.py
index 5934040..4b3f7e6 100755
--- a/python/generator.py
+++ b/python/generator.py
@@ -457,6 +457,7 @@ skip_function = (
'virDomainListAllSnapshots', # overridden in virDomain.py
'virDomainSnapshotListAllChildren', # overridden in virDomainSnapshot.py
'virConnectListAllStoragePools', # overridden in virConnect.py
+ 'virStoragePoolListAllVolumes', # overridden in virStoragePool.py
'virStreamRecvAll', # Pure python libvirt-override-virStream.py
'virStreamSendAll', # Pure python libvirt-override-virStream.py
diff --git a/src/driver.h b/src/driver.h
index 7e3e8a1..ee1341f 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -1284,7 +1284,10 @@ typedef int
(*virDrvStoragePoolListVolumes) (virStoragePoolPtr pool,
char **const names,
int maxnames);
-
+typedef int
+ (*virDrvStoragePoolListAllVolumes) (virStoragePoolPtr pool,
+ virStorageVolPtr **vols,
+ unsigned int flags);
typedef virStorageVolPtr
(*virDrvStorageVolLookupByName) (virStoragePoolPtr pool,
@@ -1392,6 +1395,7 @@ struct _virStorageDriver {
virDrvStoragePoolSetAutostart poolSetAutostart;
virDrvStoragePoolNumOfVolumes poolNumOfVolumes;
virDrvStoragePoolListVolumes poolListVolumes;
+ virDrvStoragePoolListAllVolumes poolListAllVolumes;
virDrvStorageVolLookupByName volLookupByName;
virDrvStorageVolLookupByKey volLookupByKey;
diff --git a/src/libvirt.c b/src/libvirt.c
index 541b1c3..7780534 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -12385,6 +12385,54 @@ error:
return -1;
}
+/**
+ * virStoragePoolListAllVolumes:
+ * @pool: Pointer to storage pool
+ * @vols: Pointer to a variable to store the array containing storage volume
+ * objects or NULL if the list is not required (just returns number
+ * of volumes).
+ * @flags: extra flags; not used yet, so callers should always pass 0
+ *
+ * Collect the list of storage volumes, and allocate an array to store those
+ * objects.
+ *
+ * Returns the number of storage volumes found or -1 and sets @vols to
+ * NULL in case of error. On success, the array stored into @vols is
+ * guaranteed to have an extra allocated element set to NULL but not included
+ * in the return count, to make iteration easier. The caller is responsible
+ * for calling virStorageVolFree() on each array element, then calling
+ * free() on @vols.
+ */
+int
+virStoragePoolListAllVolumes(virStoragePoolPtr pool,
+ virStorageVolPtr **vols,
+ unsigned int flags)
+{
+ VIR_DEBUG("pool=%p, vols=%p, flags=%x", pool, vols, flags);
+
+ virResetLastError();
+
+ if (!VIR_IS_STORAGE_POOL(pool)) {
+ virLibConnError(VIR_ERR_INVALID_STORAGE_POOL, __FUNCTION__);
+ virDispatchError(NULL);
+ return -1;
+ }
+
+ if (pool->conn->storageDriver &&
+ pool->conn->storageDriver->poolListAllVolumes) {
+ int ret;
+ ret = pool->conn->storageDriver->poolListAllVolumes(pool, vols, flags);
+ if (ret < 0)
+ goto error;
+ return ret;
+ }
+
+ virLibConnError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
+
+error:
+ virDispatchError(pool->conn);
+ return -1;
+}
/**
* virStoragePoolNumOfVolumes:
@@ -12432,6 +12480,8 @@ error:
* Fetch list of storage volume names, limiting to
* at most maxnames.
*
+ * To list the volume objects directly, see virStoragePoolListAllVolumes().
+ *
* Returns the number of names fetched, or -1 on error
*/
int
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index 693a390..ea052ed 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -547,6 +547,7 @@ LIBVIRT_0.9.13 {
LIBVIRT_0.9.14 {
global:
virConnectListAllStoragePools;
+ virStoragePoolListAllVolumes;
} LIBVIRT_0.9.13;
# .... define new API here using predicted next version number ....
--
1.7.7.3