[libvirt] [rust PATCH] Add list_all_volumes method for storage_pool::StoragePool
by Sage Imel
From: Sage Imel <sage(a)sagenite.net>
Always returns the full list of volumes,
can't just ask it how many volumes are in the pool
Signed-off-by: Sage Imel <sage(a)cat.pdx.edu>
---
src/storage_pool.rs | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/storage_pool.rs b/src/storage_pool.rs
index 38676c2..e8ed21c 100644
--- a/src/storage_pool.rs
+++ b/src/storage_pool.rs
@@ -18,7 +18,7 @@
extern crate libc;
-use std::str;
+use std::{str, ptr};
use connect::sys::virConnectPtr;
use storage_vol::sys::virStorageVolPtr;
@@ -57,6 +57,10 @@ extern "C" {
xml: *const libc::c_char,
flags: libc::c_uint)
-> sys::virStoragePoolPtr;
+ fn virStoragePoolListAllVolumes(ptr: sys::virStoragePoolPtr,
+ vols: *mut *mut virStorageVolPtr,
+ flags:libc::c_uint)
+ -> libc::c_int;
fn virStoragePoolLookupByID(c: virConnectPtr, id: libc::c_int) -> sys::virStoragePoolPtr;
fn virStoragePoolLookupByName(c: virConnectPtr,
id: *const libc::c_char)
@@ -103,6 +107,8 @@ pub const STORAGE_POOL_CREATE_WITH_BUILD: StoragePoolCreateFlags = 1 << 0;
pub const STORAGE_POOL_CREATE_WITH_BUILD_OVERWRITE: StoragePoolCreateFlags = 1 << 1;
pub const STORAGE_POOL_CREATE_WITH_BUILD_NO_OVERWRITE: StoragePoolCreateFlags = 1 << 2;
+pub type VirStoragePoolListAllVolumesFlags = self::libc::c_uint;
+
pub type StoragePoolState = self::libc::c_uint;
pub const VIR_STORAGE_POOL_INACTIVE: StoragePoolState = 0;
pub const VIR_STORAGE_POOL_BUILDING: StoragePoolState = 1;
@@ -201,6 +207,27 @@ impl StoragePool {
}
}
+ pub fn list_all_volumes(&self,
+ flags: VirStoragePoolListAllVolumesFlags)
+ -> Result<Vec<StorageVol>, Error> {
+ unsafe {
+ let mut volumes: *mut virStorageVolPtr = ptr::null_mut();
+ let size =
+ virStoragePoolListAllVolumes(self.as_ptr(), &mut volumes, flags as libc::c_uint);
+ if size == -1 {
+ return Err(Error::new());
+ }
+
+ let mut array: Vec<StorageVol> = Vec::new();
+ for x in 0..size as isize {
+ array.push(StorageVol::new(*volumes.offset(x)));
+ }
+ libc::free(volumes as *mut libc::c_void);
+
+ return Ok(array);
+ }
+ }
+
pub fn lookup_by_id(conn: &Connect, id: u32) -> Result<StoragePool, Error> {
unsafe {
let ptr = virStoragePoolLookupByID(conn.as_ptr(), id as libc::c_int);
--
2.17.1
5 years, 2 months
[libvirt] [glib PATCH 0/2] Add gvir_config_domain_os_get_firmware() + _domain_os_get_machine() test
by Fabiano Fidêncio
This series adds a way to retrive the DomainOs' Firmware set (with
tests) and, while touching that code, also adds one more check for
gvir_config_domain_os_get_machine().
Fabiano Fidêncio (2):
gconfig: Add _domain_os_get_firmware()
tests,test-gconfig: Check _domain_os_get_machine()
libvirt-gconfig/libvirt-gconfig-domain-os.c | 12 ++++++++++++
libvirt-gconfig/libvirt-gconfig-domain-os.h | 1 +
libvirt-gconfig/libvirt-gconfig.sym | 1 +
tests/test-gconfig.c | 3 +++
4 files changed, 17 insertions(+)
--
2.21.0
5 years, 2 months