+1. I like the approach. I wonder if this sort of thing goes on under
the covers in libvirt, or if not, if there might be an advantage to
moving this lower? Something to think about.
On 03/03/2011 02:25 PM, Sharad Mishra wrote:
# HG changeset patch
# User Sharad Mishra<snmishra(a)us.ibm.com>
# Date 1299089374 28800
# Node ID 1a894e2ab420ffb16d21d8ffa8c9850bea58b31c
# Parent 7a2ce3106321ac1729aeff2b9e42fb2e75da9295
Auto refresh StoragePools
This patch refreshes storage pool after volumes have been created or deleted from this
pool. This patch also refreshes the pool before enumerating them.
Signed-off-by: Sharad Mishra<snmishra(a)us.ibm.com>
diff -r 7a2ce3106321 -r 1a894e2ab420 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c Mon Feb 28 05:57:22 2011 -0800
+++ b/libxkutil/pool_parsing.c Wed Mar 02 10:09:34 2011 -0800
@@ -400,6 +400,9 @@
goto out;
}
+ if ((virStoragePoolRefresh(ptr, 0)) == -1)
+ CU_DEBUG("Unable to refresh storage pool");
+
path = virStorageVolGetPath(vptr);
if (path == NULL) {
CU_DEBUG("Unable to get storage volume path");
@@ -420,9 +423,11 @@
int res_type)
{
int ret = 0;
+ virStorageVolPtr ptr;
+ virStoragePoolPtr pool_ptr;
if (res_type == CIM_RES_TYPE_IMAGE) {
- virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname);
+ ptr = virStorageVolLookupByPath(conn, rname);
if (ptr == NULL) {
CU_DEBUG("Storage volume %s is not defined", rname);
goto out;
@@ -432,6 +437,16 @@
if (ret != 0) {
CU_DEBUG("Unable to delete storage volume %s",
rname);
} else {
+ pool_ptr = virStoragePoolLookupByVolume(ptr);
+ if (pool_ptr == NULL) {
+ CU_DEBUG("Unable to get storage pool "
+ "from volume");
+ } else {
+ ret = virStoragePoolRefresh(pool_ptr, 0);
+ if (ret != 0)
+ CU_DEBUG("Unable to refresh storage "
+ "pool");
+ }
ret = 1;
}
diff -r 7a2ce3106321 -r 1a894e2ab420 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c Mon Feb 28 05:57:22 2011 -0800
+++ b/src/Virt_DevicePool.c Wed Mar 02 10:09:34 2011 -0800
@@ -182,6 +182,10 @@
goto out;
}
+ if ((virStoragePoolRefresh(pool, 0)) == -1)
+ CU_DEBUG("Unable to refresh storage pool");
+
+
if (virStoragePoolGetInfo(pool,&info) == -1) {
CU_DEBUG("Failed to get info for pool `%s'",
_pool->tag);
goto out;
_______________________________________________
Libvirt-cim mailing list
Libvirt-cim(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Chip Vincent
Open Virtualization
IBM Linux Technology Center
cvincent(a)linux.vnet.ibm.com