[Libvirt-cim] [PATCH] Make the new default_device_pool() function tolerate the absence of a pool

Dan Smith danms at us.ibm.com
Wed Apr 16 15:00:22 UTC 2008


# HG changeset patch
# User Dan Smith <danms at us.ibm.com>
# Date 1208357956 25200
# Node ID 19860c6372c818cc8fa44f2d4ca12424e16ab3ac
# Parent  40f221d14476a2817a1e80a34b5c56189500db6c
Make the new default_device_pool() function tolerate the absence of a pool
and set a status message if that situation exists.

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

diff -r 40f221d14476 -r 19860c6372c8 src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Tue Apr 15 14:33:50 2008 -0400
+++ b/src/Virt_DevicePool.c	Wed Apr 16 07:59:16 2008 -0700
@@ -1017,11 +1017,11 @@ CMPIInstance *default_device_pool(const 
                 *s = get_pool_by_name(broker, reference, "ProcessorPool/0", &inst);
         } else if (type == CIM_RES_TYPE_DISK) {
                 *s = enum_pools(broker, reference, type, &list);
-                if (s->rc == CMPI_RC_OK)
+                if ((s->rc == CMPI_RC_OK) && (list.cur > 0))
                         inst = list.list[0];
         } else if (type == CIM_RES_TYPE_NET) {
                 *s = enum_pools(broker, reference, type, &list);
-                if (s->rc == CMPI_RC_OK)
+                if ((s->rc == CMPI_RC_OK) && (list.cur > 0))
                         inst = list.list[0];
         } else {
                 cu_statusf(broker, s,
@@ -1030,6 +1030,12 @@ CMPIInstance *default_device_pool(const 
         }
 
         inst_list_free(&list);
+
+        if (inst == NULL) {
+                cu_statusf(broker, s,
+                           CMPI_RC_ERR_FAILED,
+                           "No default pool found for type %hi", type);
+        }
 
         return inst;
 }




More information about the Libvirt-cim mailing list