# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1228416687 28800
# Node ID ef2cf614ff223321ea10fe8d17909a55035affee
# Parent ef03ffafe2dd00f3e2a78a2bce1cb9b4836b5d2b
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.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r ef03ffafe2dd -r ef2cf614ff22 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 10:51:27 2008 -0800
@@ -140,21 +140,26 @@
static bool _diskpool_is_member(virConnectPtr conn,
const struct disk_pool *pool,
- const char *file)
+ const char *file,
+ virStorageVolPtr vol)
{
- virStorageVolPtr vol = NULL;
bool result = false;
+ virStoragePoolPtr pool_vol = NULL;
+ const char *pool_name = NULL;
- vol = virStorageVolLookupByPath(conn, file);
- if (vol != NULL)
- result = true;
-
+ pool_vol = virStoragePoolLookupByVolume(vol);
+ if (vol != NULL) {
+ pool_name = virStoragePoolGetName(pool_vol);
+ if ((pool_name != NULL) && (STREQC(pool_name, pool->tag)))
+ result = true;
+ }
+
CU_DEBUG("Image %s in pool %s: %s",
file,
pool->tag,
result ? "YES": "NO");
- virStorageVolFree(vol);
+ virStoragePoolFree(pool_vol);
return result;
}
@@ -270,13 +275,18 @@
int count;
int i;
char *pool = NULL;
+ virStorageVolPtr vol = NULL;
count = get_diskpool_config(conn, &pools);
if (count == 0)
return NULL;
+ vol = virStorageVolLookupByPath(conn, file);
+ if (vol == NULL)
+ goto out;
+
for (i = 0; i < count; i++) {
- if (_diskpool_is_member(conn, &pools[i], file)) {
+ if (_diskpool_is_member(conn, &pools[i], file, vol)) {
int ret;
ret = asprintf(&pool, "DiskPool/%s",
pools[i].tag);
@@ -286,7 +296,9 @@
}
}
+ out:
free_diskpool(pools, count);
+ virStorageVolFree(vol);
return pool;
}