[Libvirt-cim] [PATCH] (#2) Fix _diskpool_is_member() to return correct pool

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Dec 4 21:02:31 UTC 2008


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1228424277 28800
# Node ID 328c706a5b9ec825d054097fc412342abbb2a2dc
# Parent  ef03ffafe2dd00f3e2a78a2bce1cb9b4836b5d2b
(#2) Fix _diskpool_is_member() to return correct pool.

Verifying the volume exists isn't enough to prove the disk_pool struct is the
proper pool.  We need to verify the volume is in the pool of a given pool
struct.

Updates from 1 to 2:
  -Move the virStorageVolLookupByPath() call back to _diskpool_is_member() so
   that this fix is compatible with systems running libvirtd < 0.4.0.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r ef03ffafe2dd -r 328c706a5b9e src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Thu Dec 04 09:41:51 2008 -0700
+++ b/src/Virt_DevicePool.c	Thu Dec 04 12:57:57 2008 -0800
@@ -144,17 +144,28 @@
 {
         virStorageVolPtr vol = NULL;
         bool result = false;
+        virStoragePoolPtr pool_vol = NULL;
+        const char *pool_name = NULL;
 
         vol = virStorageVolLookupByPath(conn, file);
-        if (vol != NULL)
-                result = true;
+        if (vol == NULL)
+                goto out;
 
+        pool_vol = virStoragePoolLookupByVolume(vol);
+        if (vol != NULL) {
+                pool_name = virStoragePoolGetName(pool_vol);                
+                if ((pool_name != NULL) && (STREQC(pool_name, pool->tag)))
+                        result = true;
+        }
+        
+ out:
         CU_DEBUG("Image %s in pool %s: %s",
                  file,
                  pool->tag,
                  result ? "YES": "NO");
 
         virStorageVolFree(vol);
+        virStoragePoolFree(pool_vol);
 
         return result;
 }




More information about the Libvirt-cim mailing list