[Libvirt-cim] [PATCH 1 of 3] Cleanup device_type_from_poolid() in DevicePool

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Thu Dec 20 20:48:45 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1198183661 28800
# Node ID 912a37bdd53f3fbf8e13026d8cbc02921aa028c1
# Parent  84eb3549e19956d912684a09d58631211724a720
Cleanup device_type_from_poolid() in DevicePool.

Change device_type_from_poolid() to device_type_from_str() so that this function can be used for DevicePool classnames as well as InstanceIDs.

Change return type to uint16_t to match the device type.

Change "Memory" and "Processor" to "MemoryPool" and "ProcessorPool" so that it's more strict.

Replace strstr with STARTS_WITH() so that the check is more strict.

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

diff -r 84eb3549e199 -r 912a37bdd53f src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Thu Dec 20 10:14:00 2007 -0800
+++ b/src/Virt_DevicePool.c	Thu Dec 20 12:47:41 2007 -0800
@@ -268,15 +268,15 @@ char *pool_member_of(const CMPIBroker *b
         return poolid;
 }
 
-int device_type_from_poolid(const char *id)
-{
-        if (strstr(id, "NetworkPool"))
+uint16_t device_type_from_str(const char *str)
+{
+        if (STARTS_WITH(str, "NetworkPool"))
                 return VIRT_DEV_NET;
-        else if (strstr(id, "DiskPool"))
+        else if (STARTS_WITH(str, "DiskPool"))
                 return VIRT_DEV_DISK;
-        else if (strstr(id, "Memory"))
+        else if (STARTS_WITH(str, "MemoryPool"))
                 return VIRT_DEV_MEM;
-        else if (strstr(id, "Processor"))
+        else if (STARTS_WITH(str, "ProcessorPool"))
                 return VIRT_DEV_VCPU;
         else
                 return VIRT_DEV_UNKNOWN;
diff -r 84eb3549e199 -r 912a37bdd53f src/Virt_DevicePool.h
--- a/src/Virt_DevicePool.h	Thu Dec 20 10:14:00 2007 -0800
+++ b/src/Virt_DevicePool.h	Thu Dec 20 12:47:41 2007 -0800
@@ -56,11 +56,11 @@ 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 the device type of a given pool from the pool's InstanceID
+ *
+ * @param id The InstanceID of the pool
+ */
+uint16_t device_type_from_str(const char *str);
 
 /**
  * Get all device pools on the system for the given connection




More information about the Libvirt-cim mailing list