[Libvirt-cim] [PATCH] Add logic to delete storage pools

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Apr 9 17:28:57 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1239296847 25200
# Node ID cdf4fa212c15f1b22b0b4b1d1535e1716e1e52d2
# Parent  3b7ba02cd34a4b91903e4d412fc7d5dd75779598
Add logic to delete storage pools.

Older versions of libvirt don't support storage pool creation / deletion. So
the pool deletion logic needs to return a different error message in the case
of older versions.

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

diff -r 3b7ba02cd34a -r cdf4fa212c15 libxkutil/pool_parsing.c
--- a/libxkutil/pool_parsing.c	Tue Apr 07 21:54:43 2009 -0300
+++ b/libxkutil/pool_parsing.c	Thu Apr 09 10:07:27 2009 -0700
@@ -138,9 +138,32 @@
 
  err1:
                 virNetworkFree(ptr);
+
+        } else if (res_type == CIM_RES_TYPE_DISK) {
+#if VIR_USE_LIBVIRT_STORAGE
+                virStoragePoolPtr ptr = virStoragePoolLookupByName(conn, name);
+                if (ptr == NULL) {
+                        CU_DEBUG("Storage pool %s is not defined", name);
+                        return 0;
+                }
+
+                if (virStoragePoolDestroy(ptr) != 0) {
+                        CU_DEBUG("Unable to destroy storage pool");
+                        goto err2;
+                }
+
+                if (virStoragePoolUndefine(ptr) != 0) {
+                        CU_DEBUG("Unable to undefine storage pool");
+                        goto err2;
+                }
+
+                ret = 1;
+
+ err2:
+                virStoragePoolFree(ptr);
+#endif
         }
 
-
         return ret;
 }
 
diff -r 3b7ba02cd34a -r cdf4fa212c15 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c	Tue Apr 07 21:54:43 2009 -0300
+++ b/src/Virt_ResourcePoolConfigurationService.c	Thu Apr 09 10:07:27 2009 -0700
@@ -139,6 +139,18 @@
         return msg;
 
 }
+
+static const char *_delete_pool(virConnectPtr conn,
+                                const char *pool_name,
+                                uint16_t type)
+{
+        const char *msg = NULL;
+
+        if (destroy_pool(conn, pool_name, type) == 0)
+                msg = "Unable to destroy resource pool";
+
+        return msg;
+}
 #else
 static const char *disk_rasd_to_pool(CMPIInstance *inst,
                                     struct virt_pool *pool,
@@ -146,6 +158,13 @@
 {
         return "Storage pool creation not supported in this version of libvirt";
 }
+
+static const char *_delete_pool(virConnectPtr conn,
+                                const char *pool_name,
+                                uint16_t type)
+{
+        return "Storage pool deletion not supported in this version of libvirt";
+}
 #endif
 
 static const char *rasd_to_vpool(CMPIInstance *inst,
@@ -379,6 +398,7 @@
         CMPIObjectPath *pool = NULL;
         virConnectPtr conn = NULL;
         const char *poolid = NULL;
+        const char *msg = NULL;
         char *pool_name = NULL;
         uint16_t type;
 
@@ -432,10 +452,12 @@
                 goto out;
         }
 
-        if (destroy_pool(conn, pool_name, type) == 0) {
+        msg = _delete_pool(conn, pool_name, type);
+        if (msg != NULL) {
                 cu_statusf(_BROKER, &s,
                            CMPI_RC_ERR_FAILED,
-                           "Unable to destroy resource pool");
+                           "Storage pool deletion error: %s", msg);
+
                 goto out;
         }
 




More information about the Libvirt-cim mailing list