[Libvirt-cim] [PATCH 5 of 6] Add function to parse out pool name from InstanceID

Dan Smith danms at us.ibm.com
Wed Apr 9 21:31:45 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1207776548 25200
# Node ID 3d143b851ee9201986ce8d0e6656cc313d361866
# Parent  0314f5ce51d0d8ba4d518c0a7a22c43e03be4dec
Add function to parse out pool name from InstanceID

Signed-off-by: Dan Smith <danms at us.ibm.com>

diff -r 0314f5ce51d0 -r 3d143b851ee9 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Wed Apr 09 14:29:01 2008 -0700
+++ b/src/Virt_DevicePool.c	Wed Apr 09 14:29:08 2008 -0700
@@ -500,6 +500,17 @@ uint16_t res_type_from_pool_id(const cha
                 return CIM_RES_TYPE_UNKNOWN;
 }
 
+char *name_from_pool_id(const char *id)
+{
+        char *s;
+
+        s = strchr(id, '/');
+        if (s == NULL)
+                return NULL;
+
+        return strdup((char *)s+1);
+}
+
 static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn)
 {
         virNodeInfo info;
diff -r 0314f5ce51d0 -r 3d143b851ee9 src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h	Wed Apr 09 14:29:01 2008 -0700
+++ b/src/Virt_DevicePool.h	Wed Apr 09 14:29:08 2008 -0700
@@ -58,6 +58,14 @@ uint16_t res_type_from_pool_id(const cha
 uint16_t res_type_from_pool_id(const char *id);
 
 /**
+ * Get the pool name from a given pool's InstanceID
+ *
+ * @param id The InstanceID of the pool
+ * @returns the name (must be free'd by the caller)
+ */
+char *name_from_pool_id(const char *id);
+
+/**
  * Get all device pools on the system for the given type
  * 
  *




More information about the Libvirt-cim mailing list