[Libvirt-cim] [PATCH 1 of 4] Add disk support to pool_parsing

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Apr 3 16:47:12 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1238773876 25200
# Node ID 9759b13c4f25d20f92bc2d50961e467c1b050acc
# Parent  2f4943568299ef76e285e34412ec5ba5f2badbd7
Add disk support to pool_parsing

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

diff -r 2f4943568299 -r 9759b13c4f25 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c	Thu Apr 02 03:31:14 2009 -0300
+++ b/libxkutil/pool_parsing.c	Fri Apr 03 08:51:16 2009 -0700
@@ -33,6 +33,16 @@
 #include "pool_parsing.h"
 #include "../src/svpc_types.h"
 
+/*
+ *  * Right now, detect support and use it, if available.
+ *   * Later, this can be a configure option if needed
+ *    */
+#if LIBVIR_VERSION_NUMBER > 4000
+# define VIR_USE_LIBVIRT_STORAGE 1
+#else
+# define VIR_USE_LIBVIRT_STORAGE 0
+#endif
+
 static void cleanup_net_pool(struct net_pool pool) {
         free(pool.addr);
         free(pool.netmask);
@@ -78,8 +88,27 @@
                 }
 
                 virNetworkFree(ptr);
+        } else if (res_type == CIM_RES_TYPE_DISK) {
+#if VIR_USE_LIBVIRT_STORAGE
+                virStoragePoolPtr ptr = virStoragePoolDefineXML(conn, xml, 0);
+                if (ptr == NULL) {
+                        CU_DEBUG("Unable to define storage pool");
+                        return 0;
+                }
+
+                if (virStoragePoolCreate(ptr, 0) != 0) {
+                        CU_DEBUG("Unable to start storage pool");
+                        ret = 0;
+
+                        if (virStoragePoolUndefine(ptr) != 0)
+                                CU_DEBUG("Unable to undefine storage pool");
+                }
+
+                virStoragePoolFree(ptr);
+#endif
         }
 
+
         return ret; 
 }
 
diff -r 2f4943568299 -r 9759b13c4f25 libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h	Thu Apr 02 03:31:14 2009 -0300
+++ b/libxkutil/pool_parsing.h	Fri Apr 03 08:51:16 2009 -0700
@@ -36,10 +36,22 @@
         char *forward_dev;
 };
 
+struct disk_pool {
+        enum {DISK_POOL_UNKNOWN, 
+              DISK_POOL_DIR, 
+              DISK_POOL_FS, 
+              DISK_POOL_NETFS, 
+              DISK_POOL_DISK, 
+              DISK_POOL_ISCSI, 
+              DISK_POOL_LOGICAL} pool_type;
+        char *path;
+};
+
 struct virt_pool {
         uint16_t type;
         union {
                 struct net_pool net;
+                struct disk_pool disk;
         } pool_info;
         char *id;
 };




More information about the Libvirt-cim mailing list