[Libvirt-cim] [PATCH 1 of 2] Create parent diskpool

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Mon Apr 27 23:41:09 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1240874036 25200
# Node ID 1bce4b17fe0bef5d70dc5dd14a02cdfb56d173c8
# Parent  e5000891e231e6b9896786e48442ef98bfe9f9fd
Create parent diskpool

DSP1041 states that all pool allocations will occur from a parent, primordial
pool.  This patch adds the parent pool for disk pools.

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

diff -r e5000891e231 -r 1bce4b17fe0b src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Mon Apr 20 11:02:52 2009 -0700
+++ b/src/Virt_DevicePool.c	Mon Apr 27 16:13:56 2009 -0700
@@ -48,6 +48,7 @@
 struct disk_pool {
         char *tag;
         char *path;
+        bool primordial;
 };
 
 /*
@@ -60,6 +61,36 @@
 # define VIR_USE_LIBVIRT_STORAGE 0
 #endif
 
+static bool get_disk_parent(struct disk_pool **_pools,
+                            int *_count)
+{
+        struct disk_pool *pools = NULL;
+        int ret = false;
+        int count;
+
+        count = *_count;
+        pools = *_pools;
+
+        pools = realloc(pools, (count + 1) * (sizeof(*pools)));
+        if (pools == NULL) {
+                CU_DEBUG("Failed to alloc new pool");
+                goto out;
+        }
+
+        pools[count].tag = strdup("Parent");
+        pools[count].path = NULL;
+        pools[count].primordial = true;
+        count++;
+
+        *_count = count;
+        *_pools = pools;
+        ret = true;
+
+ out:
+        return ret;
+}
+
+
 #if VIR_USE_LIBVIRT_STORAGE
 static int get_diskpool_config(virConnectPtr conn,
                                struct disk_pool **_pools)
@@ -67,7 +98,7 @@
         int count = 0;
         int i;
         char ** names = NULL;
-        struct disk_pool *pools;
+        struct disk_pool *pools = NULL;
 
         count = virConnectNumOfStoragePools(conn);
         if (count <= 0)
@@ -91,11 +122,16 @@
                 goto out;
         }
 
-        for (i = 0; i < count; i++)
+        for (i = 0; i < count; i++) {
                 pools[i].tag = names[i];
+                pools[i].primordial = false;
+        }
+
+ out:
+        get_disk_parent(&pools, &count);
 
         *_pools = pools;
- out:
+
         free(names);
 
         return count;
@@ -180,6 +216,7 @@
                 free(pool->tag);
                 free(pool->path);
         }
+        pools->primordial = false;
 
         return (ret == 2);
 }
@@ -212,6 +249,8 @@
                         count++;
         }
 
+
+        get_disk_parent(&pools, &count);
  out:
         free(line);
         *_pools = pools;
@@ -831,6 +870,9 @@
 
         set_params(inst, CIM_RES_TYPE_DISK, poolid, "Megabytes", pool->tag);
 
+        CMSetProperty(inst, "Primordial",
+                      (CMPIValue *)&pool->primordial, CMPI_boolean);
+
         if (!diskpool_set_capacity(conn, inst, pool))
                 CU_DEBUG("Failed to set capacity for disk pool: %s",
                          pool->tag);




More information about the Libvirt-cim mailing list