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

Dan Smith danms at us.ibm.com
Mon Apr 14 16:44:45 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1208191443 25200
# Node ID 2afa2a7d1d5a4e7d026f2f6cf8b5a1a8a266b5a0
# Parent  857848be56f0bdc3480bb9f5a7ae6d0598b4d9a8
Add function to parse out pool name from InstanceID

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

diff -r 857848be56f0 -r 2afa2a7d1d5a src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Mon Apr 14 09:42:32 2008 -0700
+++ b/src/Virt_DevicePool.c	Mon Apr 14 09:44:03 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 857848be56f0 -r 2afa2a7d1d5a src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h	Mon Apr 14 09:42:32 2008 -0700
+++ b/src/Virt_DevicePool.h	Mon Apr 14 09:44:03 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