[Libvirt-cim] [PATCH 2 of 3] Add delete_resource() to pool_parsing.c - this will call libvirt APIs

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Aug 27 22:27:43 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1251232703 25200
# Node ID eb113fed5210d9d31e3b5eae684f27631c0a2ef2
# Parent  1cb1a2dbdb0abb503898a851ab3b4d41ee85cab0
Add delete_resource() to pool_parsing.c - this will call libvirt APIs...

To delete a storage volume within a storage pool.

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

diff -r 1cb1a2dbdb0a -r eb113fed5210 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c	Tue Aug 25 13:38:23 2009 -0700
+++ b/libxkutil/pool_parsing.c	Tue Aug 25 13:38:23 2009 -0700
@@ -358,6 +358,34 @@
 
         return ret;
 }
+
+int delete_resource(virConnectPtr conn,
+                    const char *rname,
+                    int res_type)
+{
+        int ret = 0;
+
+        if (res_type == CIM_RES_TYPE_IMAGE) {
+                virStorageVolPtr ptr = virStorageVolLookupByPath(conn, rname);
+                if (ptr == NULL) {
+                        CU_DEBUG("Storage volume %s is not defined", rname);
+                        goto out;
+                }
+
+                ret = virStorageVolDelete(ptr, 0);
+                if (ret != 0) {
+                        CU_DEBUG("Unable to delete storage volume %s", rname);
+                } else {
+                        ret = 1;
+                }
+
+                virStorageVolFree(ptr);
+        }
+
+ out:
+
+        return ret;
+}
 #else
 int create_resource(virConnectPtr conn,
                     const char *pname,
@@ -367,6 +395,14 @@
           CU_DEBUG("Creating resources within libvirt pools not supported");
           return 0;
 }
+
+int delete_resource(virConnectPtr conn,
+                    const char *rname,
+                    int res_type)
+{
+          CU_DEBUG("Deleting resources within libvirt pools not supported");
+          return 0;
+}
 #endif
 
 /*
diff -r 1cb1a2dbdb0a -r eb113fed5210 libxkutil/pool_parsing.h
--- a/libxkutil/pool_parsing.h	Tue Aug 25 13:38:23 2009 -0700
+++ b/libxkutil/pool_parsing.h	Tue Aug 25 13:38:23 2009 -0700
@@ -92,6 +92,8 @@
 int create_resource(virConnectPtr conn, const char *pname,
                     const char *xml, int res_type);
 
+int delete_resource(virConnectPtr conn, const char *rname, int res_type);
+
 #endif
 
 /*




More information about the Libvirt-cim mailing list