[Libvirt-cim] [PATCH 1 of 3] Add call to libvirt virStorageVolCreateXML()

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Aug 13 05:08:42 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1245187550 25200
# Node ID 3fbc29cee5f7391a16a2d68d31eda3d732f4a70e
# Parent  d47e71adaa6285b43f19d2c6eef184c50d8439d7
Add call to libvirt virStorageVolCreateXML()

This call creates the storage volume / image that can be used by future guests.

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

diff -r d47e71adaa62 -r 3fbc29cee5f7 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c	Tue Aug 11 16:54:03 2009 -0700
+++ b/libxkutil/pool_parsing.c	Tue Jun 16 14:25:50 2009 -0700
@@ -329,6 +329,46 @@
         return ret;
 }
 
+#if VIR_USE_LIBVIRT_STORAGE
+int create_resource(virConnectPtr conn,
+                    const char *pname,
+                    const char *xml,
+                    int res_type)
+{
+        int ret = 0;
+
+        if (res_type == CIM_RES_TYPE_IMAGE) {
+                virStoragePoolPtr ptr = virStoragePoolLookupByName(conn, pname);
+                if (ptr == NULL) {
+                        CU_DEBUG("Storage pool %s is not defined", pname);
+                        goto out;
+                }
+
+                virStorageVolPtr vptr = virStorageVolCreateXML(ptr, xml, 0);
+                if (vptr == NULL)
+                        goto out;
+
+                virStorageVolFree(vptr);
+                virStoragePoolFree(ptr);
+
+                ret = 1;
+        }
+
+ out:
+
+        return ret;
+}
+#else
+int create_resource(virConnectPtr conn,
+                    const char *pname,
+                    const char *xml,
+                    int res_type)
+{
+          CU_DEBUG("Creating resources within libvirt pools not supported");
+          return 0;
+}
+#endif
+
 /*
  * Local Variables:
  * mode: C
diff -r d47e71adaa62 -r 3fbc29cee5f7 libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h	Tue Aug 11 16:54:03 2009 -0700
+++ b/libxkutil/pool_parsing.h	Tue Jun 16 14:25:50 2009 -0700
@@ -89,6 +89,8 @@
 int define_pool(virConnectPtr conn, const char *xml, int res_type);
 int destroy_pool(virConnectPtr conn, const char *name, int res_type);
 
+int create_resource(virConnectPtr conn, const char *pname,
+                    const char *xml, int res_type);
 
 #endif
 




More information about the Libvirt-cim mailing list