[Libvirt-cim] [PATCH 1 of 2] Adding a function that returns resource type based on poolid

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Tue Dec 11 18:09:07 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1197394928 28800
# Node ID 23183bc1e0f3c33038cd67b69613fb081fc8c2e3
# Parent  70e9f11ed6d3ea63b342c4c3de68cc948d7c1cfd
Adding a function that returns resource type based on poolid.

The following function takes a string (the resource pool's InstanceID) and parses it to determine the corresponding resource type.

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

diff -r 70e9f11ed6d3 -r 23183bc1e0f3 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Virt_DevicePool.c	Tue Dec 11 09:42:08 2007 -0800
@@ -268,6 +268,20 @@ char *pool_member_of(const CMPIBroker *b
         return poolid;
 }
 
+int device_type_from_poolid(const char *id)
+{
+        if (strstr(id, "NetworkPool"))
+                return VIRT_DEV_NET;
+        else if (strstr(id, "DiskPool"))
+                return VIRT_DEV_DISK;
+        else if (strstr(id, "Memory"))
+                return VIRT_DEV_MEM;
+        else if (strstr(id, "Processor"))
+                return VIRT_DEV_VCPU;
+        else
+                return VIRT_DEV_UNKNOWN;
+}
+
 static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn)
 {
         virNodeInfo info;
diff -r 70e9f11ed6d3 -r 23183bc1e0f3 src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h	Mon Dec 10 08:54:08 2007 -0800
+++ b/src/Virt_DevicePool.h	Tue Dec 11 09:42:08 2007 -0800
@@ -56,6 +56,13 @@ char *pool_member_of(const CMPIBroker *b
                      const char *id);
 
 /**
+ *  * Get the device type of a given pool from the pool's InstanceID
+ *   *
+ *    * @param id The InstanceID of the pool
+ *     */
+int device_type_from_poolid(const char *id);
+
+/**
  * Get all device pools on the system for the given connection
  *
  * @param broker The current Broker




More information about the Libvirt-cim mailing list