[PATCH 0 of 7] #2 - Adopt get_() common look and feel to DevicePool and Adopted interface changes to assocs

Adopted the get_() function look and feel to the DevicePool provider. Updated the association providers that uses these functions. Diff to patch set 1: - patch #1 (svpc_types) - add Resource Pool types to svpc_types.h and map existing types to base resource types - patch #2 (DevicePool) - implement configurable enum_pools() function; adopt resource types - patch #6 (EAFP) - adopt resource types; validate client given device ref - patch #7 (AC) - adopt DevicePool interface changes; updated NOT_FOUND error message to be consistent with others

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204709615 -3600 # Node ID 1626d88fa98b890ba251a450fca3d6c330bc27ad # Parent 58da2f9d92e39567b75d8537a833aba0da994f92 Add Resource Pool types to svpc_types.h This patch reorganizes the resource types. It defines common resource types for: - ALL - PROC - MEM - NET - DISK - UNKNOWN and maps the corresponding class specific resource types to these base types. Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 58da2f9d92e3 -r 1626d88fa98b libxkutil/device_parsing.h --- a/libxkutil/device_parsing.h Mon Mar 03 09:58:19 2008 -0800 +++ b/libxkutil/device_parsing.h Wed Mar 05 10:33:35 2008 +0100 @@ -64,11 +64,11 @@ struct graphics_device { struct virt_device { enum { - VIRT_DEV_NET = CIM_RASD_TYPE_NET, - VIRT_DEV_DISK = CIM_RASD_TYPE_DISK, - VIRT_DEV_MEM = CIM_RASD_TYPE_MEM, - VIRT_DEV_VCPU = CIM_RASD_TYPE_PROC, - VIRT_DEV_UNKNOWN = 1000, + VIRT_DEV_NET = CIM_RES_TYPE_NET, + VIRT_DEV_DISK = CIM_RES_TYPE_DISK, + VIRT_DEV_MEM = CIM_RES_TYPE_MEM, + VIRT_DEV_VCPU = CIM_RES_TYPE_PROC, + VIRT_DEV_UNKNOWN = CIM_RES_TYPE_UNKNOWN, VIRT_DEV_EMU, VIRT_DEV_GRAPHICS, } type; diff -r 58da2f9d92e3 -r 1626d88fa98b src/svpc_types.h --- a/src/svpc_types.h Mon Mar 03 09:58:19 2008 -0800 +++ b/src/svpc_types.h Wed Mar 05 10:33:35 2008 +0100 @@ -22,10 +22,24 @@ #ifndef __SVPC_TYPES_H #define __SVPC_TYPES_H -#define CIM_RASD_TYPE_PROC 3 -#define CIM_RASD_TYPE_MEM 4 -#define CIM_RASD_TYPE_NET 10 -#define CIM_RASD_TYPE_DISK 17 +#define CIM_TYPE_ALL 0 +#define CIM_RES_TYPE_PROC 3 +#define CIM_RES_TYPE_MEM 4 +#define CIM_RES_TYPE_NET 10 +#define CIM_RES_TYPE_DISK 17 +#define CIM_RES_TYPE_UNKNOWN 1000 + +#define CIM_RASD_TYPE_PROC CIM_RES_TYPE_PROC +#define CIM_RASD_TYPE_MEM CIM_RES_TYPE_MEM +#define CIM_RASD_TYPE_NET CIM_RES_TYPE_NET +#define CIM_RASD_TYPE_DISK CIM_RES_TYPE_DISK + +#define CIM_POOL_TYPE_ALL CIM_TYPE_ALL +#define CIM_POOL_TYPE_PROC CIM_RES_TYPE_PROC +#define CIM_POOL_TYPE_MEM CIM_RES_TYPE_MEM +#define CIM_POOL_TYPE_NET CIM_RES_TYPE_NET +#define CIM_POOL_TYPE_DISK CIM_RES_TYPE_DISK +#define CIM_POOL_TYPE_UNKNOWN CIM_RES_TYPE_UNKNOWN #define CIM_VSSD_RECOVERY_NONE 2 #define CIM_VSSD_RECOVERY_RESTART 3

This has gotten a little messy and disjoint, so I'm definitely in favor of cleaning it up. HE> -#define CIM_RASD_TYPE_PROC 3 HE> -#define CIM_RASD_TYPE_MEM 4 HE> -#define CIM_RASD_TYPE_NET 10 HE> -#define CIM_RASD_TYPE_DISK 17 HE> +#define CIM_TYPE_ALL 0 HE> +#define CIM_RES_TYPE_PROC 3 HE> +#define CIM_RES_TYPE_MEM 4 HE> +#define CIM_RES_TYPE_NET 10 HE> +#define CIM_RES_TYPE_DISK 17 HE> +#define CIM_RES_TYPE_UNKNOWN 1000 HE> + HE> +#define CIM_RASD_TYPE_PROC CIM_RES_TYPE_PROC HE> +#define CIM_RASD_TYPE_MEM CIM_RES_TYPE_MEM HE> +#define CIM_RASD_TYPE_NET CIM_RES_TYPE_NET HE> +#define CIM_RASD_TYPE_DISK CIM_RES_TYPE_DISK HE> + HE> +#define CIM_POOL_TYPE_ALL CIM_TYPE_ALL HE> +#define CIM_POOL_TYPE_PROC CIM_RES_TYPE_PROC HE> +#define CIM_POOL_TYPE_MEM CIM_RES_TYPE_MEM HE> +#define CIM_POOL_TYPE_NET CIM_RES_TYPE_NET HE> +#define CIM_POOL_TYPE_DISK CIM_RES_TYPE_DISK HE> +#define CIM_POOL_TYPE_UNKNOWN CIM_RES_TYPE_UNKNOWN I know that in several places, we assume that a device type is the same as the CIM resource type. Above, you define CIM_RASD_TYPE_foo to CIM_RES_TYPE_foo, presumably to avoid having to touch all the places that use the former. I think to reduce ambiguity and to enforce the fact that these must remain the same, it would be better to just change CIM_RASD_TYPE_foo to CIM_RES_TYPE_foo everywhere. Thoughts? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
I know that in several places, we assume that a device type is the same as the CIM resource type. Above, you define CIM_RASD_TYPE_foo to CIM_RES_TYPE_foo, presumably to avoid having to touch all the places that use the former. I think to reduce ambiguity and to enforce the fact that these must remain the same, it would be better to just change CIM_RASD_TYPE_foo to CIM_RES_TYPE_foo everywhere.
Thoughts?
I'm definitely supporting this opinion and will update all providers, if the others are fine with using CIM_RES_TYPE_foo in all cases (Device, DevicePool, RASD ...). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204709616 -3600 # Node ID 196480aa1c1b8358ae896782f831950c27ab232d # Parent 1626d88fa98b890ba251a450fca3d6c330bc27ad DevicePool: reorganize get and enum functions - the common look and feel of the get_..._by_name() and get_..._by_ref() is adopted - get_all_pools() is renamed to enum_pools and rewritten to be configurable dynamically - return either a specific or all resource pools. This also replaces get_pool_by_type(). - the device_pool_names array is removed and types are identified by the CIM_POOL_TYPE_..., as defined in svpc_types.h Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 1626d88fa98b -r 196480aa1c1b src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Wed Mar 05 10:33:35 2008 +0100 +++ b/src/Virt_DevicePool.c Wed Mar 05 10:33:36 2008 +0100 @@ -45,12 +45,6 @@ static const CMPIBroker *_BROKER; -char *device_pool_names[] = {"ProcessorPool", - "MemoryPool", - "DiskPool", - "NetworkPool", - NULL}; - struct disk_pool { char *tag; char *path; @@ -332,18 +326,32 @@ char *pool_member_of(const CMPIBroker *b return poolid; } +uint16_t pool_type_from_classname(const char *classname) +{ + if (strstr(classname, "NetworkPool")) + return CIM_POOL_TYPE_NET; + else if (strstr(classname, "DiskPool")) + return CIM_POOL_TYPE_DISK; + else if (strstr(classname, "MemoryPool")) + return CIM_POOL_TYPE_MEM; + else if (strstr(classname, "ProcessorPool")) + return CIM_POOL_TYPE_PROC; + else + return CIM_POOL_TYPE_UNKNOWN; +} + uint16_t device_type_from_poolid(const char *id) { if (STARTS_WITH(id, "NetworkPool")) - return VIRT_DEV_NET; + return CIM_POOL_TYPE_NET; else if (STARTS_WITH(id, "DiskPool")) - return VIRT_DEV_DISK; + return CIM_POOL_TYPE_DISK; else if (STARTS_WITH(id, "MemoryPool")) - return VIRT_DEV_MEM; + return CIM_POOL_TYPE_MEM; else if (STARTS_WITH(id, "ProcessorPool")) - return VIRT_DEV_VCPU; + return CIM_POOL_TYPE_PROC; else - return VIRT_DEV_UNKNOWN; + return CIM_POOL_TYPE_UNKNOWN; } static bool mempool_set_total(CMPIInstance *inst, virConnectPtr conn) @@ -673,177 +681,190 @@ static CMPIStatus diskpool_instance(virC return s; } -static CMPIStatus _get_pool(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, +static CMPIStatus _get_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + const char *id, + struct inst_list *list) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn; + + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) + goto out; + + if ((type == CIM_POOL_TYPE_PROC) || + (type == CIM_TYPE_ALL)) + s = procpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_POOL_TYPE_MEM) || + (type == CIM_TYPE_ALL)) + s = mempool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_POOL_TYPE_NET) || + (type == CIM_TYPE_ALL)) + s = netpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if ((type == CIM_POOL_TYPE_DISK) || + (type == CIM_TYPE_ALL)) + s = diskpool_instance(conn, list, + NAMESPACE(reference), + id, broker); + + if (type == CIM_POOL_TYPE_UNKNOWN) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance - resource pool type unknow."); + + if (id && list->cur == 0) + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s).", id); + + out: + virConnectClose(conn); + return s; +} + +CMPIStatus get_pool_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, const char *id, - const char *ns, - struct inst_list *list) -{ - if (STARTS_WITH(type, "MemoryPool")) - return mempool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "ProcessorPool")) - return procpool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "NetworkPool")) - return netpool_instance(conn, list, ns, id, broker); - else if (STARTS_WITH(type, "DiskPool")) - return diskpool_instance(conn, list, ns, id, broker); - - return (CMPIStatus){CMPI_RC_ERR_NOT_FOUND, NULL}; -} - -CMPIStatus get_pool_by_type(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, - const char *ns, - struct inst_list *list) -{ - return _get_pool(broker, conn, type, NULL, ns, list); -} - -CMPIInstance *get_pool_by_id(const CMPIBroker *broker, - virConnectPtr conn, - const char *id, - const char *ns) -{ - CMPIInstance *inst = NULL; - CMPIStatus s; - char *type = NULL; + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; + struct inst_list list; char *poolid = NULL; int ret; - struct inst_list list; + uint16_t type; inst_list_init(&list); - ret = sscanf(id, "%a[^/]/%as", &type, &poolid); - if (ret != 2) - goto out; - - s = _get_pool(broker, conn, type, poolid, ns, &list); - if ((s.rc == CMPI_RC_OK) && (list.cur > 0)) - inst = list.list[0]; - - out: + conn = connect_by_classname(broker, CLASSNAME(reference), &s); + if (conn == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance."); + goto out; + } + + type = device_type_from_poolid(id); + + if (type == CIM_POOL_TYPE_UNKNOWN) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s) - resource pool type mismatch.", + id); + goto out; + } + + ret = sscanf(id, "%*[^/]/%as", &poolid); + if (ret != 1) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s).", + id); + goto out; + } + + s = _get_pools(broker, reference, type, poolid, &list); + if (s.rc != CMPI_RC_OK) + goto out; + + *_inst = list.list[0]; + + out: + free(poolid); + virConnectClose(conn); inst_list_free(&list); - return inst; -} - -CMPIStatus get_all_pools(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *list) -{ - int i; + return s; +} + +CMPIStatus get_pool_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **instance) +{ CMPIStatus s = {CMPI_RC_OK}; - - for (i = 0; device_pool_names[i]; i++) { - s = get_pool_by_type(broker, - conn, - device_pool_names[i], - ns, - list); - if (s.rc != CMPI_RC_OK) - goto out; - } - + CMPIInstance *inst = NULL; + const char *id = NULL; + uint16_t type_cls; + uint16_t type_id; + + if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Missing InstanceID"); + goto out; + } + + type_cls = pool_type_from_classname(CLASSNAME(reference)); + type_id = device_type_from_poolid(id); + + if ((type_cls != type_id) || + (type_cls == CIM_POOL_TYPE_UNKNOWN)) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s) - resource pool type mismatch.", + id); + goto out; + } + + s = get_pool_by_name(broker, reference, id, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + s = cu_validate_ref(broker, reference, inst); + if (s.rc != CMPI_RC_OK) + goto out; + + *instance = inst; + out: return s; } -static void __return_pool(const CMPIResult *results, - struct inst_list *list, - bool name_only) -{ - if (name_only) - cu_return_instance_names(results, list); - else - cu_return_instances(results, list); +CMPIStatus enum_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + struct inst_list *list) +{ + return _get_pools(broker, reference, type, NULL, list); } static CMPIStatus return_pool(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only, - bool single_only) -{ - CMPIStatus s; - char *type; - virConnectPtr conn; + bool names_only) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; struct inst_list list; if (!provider_is_responsible(_BROKER, ref, &s)) - return s; - - type = class_base_name(CLASSNAME(ref)); - if (type == NULL) { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Invalid classname `%s'", CLASSNAME(ref)); - return s; - } + goto out; inst_list_init(&list); - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - s = get_pool_by_type(_BROKER, - conn, - type, - NAMESPACE(ref), - &list); - if (s.rc == CMPI_RC_OK) { - __return_pool(results, &list, name_only); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } else { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Pool type %s not found", type); - } - - out: - free(type); + s = enum_pools(_BROKER, + ref, + pool_type_from_classname(CLASSNAME(ref)), + &list); + if (s.rc != CMPI_RC_OK) + goto out; + + if (names_only) + cu_return_instance_names(results, &list); + else + cu_return_instances(results, &list); + + out: inst_list_free(&list); - - return s; -} - -CMPIStatus get_pool_inst(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) -{ - CMPIStatus s; - CMPIInstance *inst = NULL; - virConnectPtr conn = NULL; - const char *id = NULL; - - if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { - cu_statusf(broker, &s, - CMPI_RC_ERR_FAILED, - "Missing InstanceID"); - goto out; - } - - conn = connect_by_classname(broker, CLASSNAME(reference), &s); - if (conn == NULL) { - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance"); - goto out; - } - - inst = get_pool_by_id(broker, conn, id, NAMESPACE(reference)); - if (inst == NULL) - cu_statusf(broker, &s, - CMPI_RC_ERR_NOT_FOUND, - "No such instance (%s)", id); - - out: - virConnectClose(conn); - *instance = inst; return s; } @@ -853,7 +874,7 @@ static CMPIStatus EnumInstanceNames(CMPI const CMPIResult *results, const CMPIObjectPath *reference) { - return return_pool(reference, results, true, false); + return return_pool(reference, results, true); } static CMPIStatus EnumInstances(CMPIInstanceMI *self, @@ -862,7 +883,7 @@ static CMPIStatus EnumInstances(CMPIInst const CMPIObjectPath *reference, const char **properties) { - return return_pool(reference, results, false, false); + return return_pool(reference, results, false); } static CMPIStatus GetInstance(CMPIInstanceMI *self, @@ -871,13 +892,16 @@ static CMPIStatus GetInstance(CMPIInstan const CMPIObjectPath *reference, const char **properties) { - CMPIStatus s; + CMPIStatus s = {CMPI_RC_OK}; CMPIInstance *inst = NULL; - s = get_pool_inst(_BROKER, reference, &inst); - if ((s.rc == CMPI_RC_OK) && (inst != NULL)) - CMReturnInstance(results, inst); - + s = get_pool_by_ref(_BROKER, reference, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + + CMReturnInstance(results, inst); + + out: return s; } diff -r 1626d88fa98b -r 196480aa1c1b src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Wed Mar 05 10:33:35 2008 +0100 +++ b/src/Virt_DevicePool.h Wed Mar 05 10:33:36 2008 +0100 @@ -26,20 +26,6 @@ #include <libcmpiutil/libcmpiutil.h> #include <stdint.h> -extern char *device_pool_names[]; - -CMPIStatus get_pool_by_type(const CMPIBroker *broker, - virConnectPtr conn, - const char *type, - const char *ns, - struct inst_list *list); - -CMPIInstance *get_pool_by_id(const CMPIBroker *broker, - virConnectPtr conn, - const char *id, - const char *ns); - - /** * Get the InstanceID of a pool that a given RASD id (for type) is in * @@ -56,6 +42,13 @@ char *pool_member_of(const CMPIBroker *b const char *id); /** + * Get the device type of a given pool from the pool's classname + * + * @param id The InstanceID of the pool + */ +uint16_t pool_type_from_classname(const char *classname); + +/** * Get the device type of a given pool from the pool's InstanceID * * @param id The InstanceID of the pool @@ -63,17 +56,19 @@ uint16_t device_type_from_poolid(const c uint16_t device_type_from_poolid(const char *id); /** - * Get all device pools on the system for the given connection + * Get all device pools on the system for the given type + * * * @param broker The current Broker - * @param conn The libvirt connection to use - * @param ns Namespace for the pools - * @param list Return instances in this struct + * @param reference Defines the libvirt connection to use + * @param type The device pool type or CIM_POOL_TYPE_ALL + * to get all resource pools + * @param list The list of returned instances */ -CMPIStatus get_all_pools(const CMPIBroker *broker, - virConnectPtr conn, - const char *ns, - struct inst_list *list); +CMPIStatus enum_pools(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const uint16_t type, + struct inst_list *list); /** * Get a device pools instance for the given reference @@ -82,9 +77,23 @@ CMPIStatus get_all_pools(const CMPIBroke * @param reference The reference passed to the CIMOM * @param instance Return corresponding instance */ -CMPIStatus get_pool_inst(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance); +CMPIStatus get_pool_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **instance); + +/** + * Get device pool instance specified by the id + * + * @param broker A pointer to the current broker + * @param ref The object path containing namespace and prefix info + * @param name The device pool id + * @param _inst In case of success the pointer to the instance + * @returns CMPIStatus + */ +CMPIStatus get_pool_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *id, + CMPIInstance **_inst); #endif

HE> @@ -673,177 +681,190 @@ static CMPIStatus diskpool_instance(virC HE> return s; HE> } HE> -static CMPIStatus _get_pool(const CMPIBroker *broker, HE> - virConnectPtr conn, HE> - const char *type, HE> +static CMPIStatus _get_pools(const CMPIBroker *broker, HE> + const CMPIObjectPath *reference, HE> + const uint16_t type, HE> + const char *id, HE> + struct inst_list *list) HE> +{ HE> + CMPIStatus s = {CMPI_RC_OK, NULL}; HE> + virConnectPtr conn; HE> + HE> + conn = connect_by_classname(broker, CLASSNAME(reference), &s); HE> + if (conn == NULL) HE> + goto out; HE> + HE> + if ((type == CIM_POOL_TYPE_PROC) || HE> + (type == CIM_TYPE_ALL)) HE> + s = procpool_instance(conn, list, HE> + NAMESPACE(reference), HE> + id, broker); HE> + HE> + if ((type == CIM_POOL_TYPE_MEM) || HE> + (type == CIM_TYPE_ALL)) HE> + s = mempool_instance(conn, list, HE> + NAMESPACE(reference), HE> + id, broker); HE> + HE> + if ((type == CIM_POOL_TYPE_NET) || HE> + (type == CIM_TYPE_ALL)) HE> + s = netpool_instance(conn, list, HE> + NAMESPACE(reference), HE> + id, broker); HE> + HE> + if ((type == CIM_POOL_TYPE_DISK) || HE> + (type == CIM_TYPE_ALL)) HE> + s = diskpool_instance(conn, list, HE> + NAMESPACE(reference), HE> + id, broker); HE> + HE> + if (type == CIM_POOL_TYPE_UNKNOWN) HE> + cu_statusf(broker, &s, HE> + CMPI_RC_ERR_NOT_FOUND, HE> + "No such instance - resource pool type unknow."); ^^^^^^^ You're missing an 'n' there, and the period should be removed. HE> + if (id && list->cur == 0) HE> + cu_statusf(broker, &s, HE> + CMPI_RC_ERR_NOT_FOUND, HE> + "No such instance (%s).", id); As well as this period. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204709617 -3600 # Node ID 6d0015c66c758a0d80fb6d70e310d2b020798ea6 # Parent 196480aa1c1b8358ae896782f831950c27ab232d SDC: adopt DevicePool interface change - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 196480aa1c1b -r 6d0015c66c75 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Wed Mar 05 10:33:36 2008 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Wed Mar 05 10:33:37 2008 +0100 @@ -529,13 +529,9 @@ static struct sdc_rasd_prop *disk_max(co /* Getting the relevant resource pool directly finds the free space for us. It is in the Capacity field. */ - pool_inst = get_pool_by_id(_BROKER, conn, inst_id, NAMESPACE(ref)); - if (pool_inst == NULL) { - cu_statusf(_BROKER, s, - CMPI_RC_ERR_FAILED, - "Could not get pool instance"); - goto out; - } + *s = get_pool_by_name(_BROKER, ref, inst_id, &pool_inst); + if (s->rc != CMPI_RC_OK) + goto out; prop_ret = cu_get_u64_prop(pool_inst, "Capacity", &free_64); if (prop_ret != CMPI_RC_OK) {

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204709617 -3600 # Node ID ee7aecb09ec486d4d47134fef328ae207b608e1d # Parent 6d0015c66c758a0d80fb6d70e310d2b020798ea6 HRP: adopt DevicePool interface change - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 6d0015c66c75 -r ee7aecb09ec4 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Wed Mar 05 10:33:37 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Wed Mar 05 10:33:37 2008 +0100 @@ -34,6 +34,7 @@ #include "Virt_HostSystem.h" #include "Virt_DevicePool.h" +#include "svpc_types.h" static const CMPIBroker *_BROKER; @@ -47,8 +48,8 @@ static CMPIStatus pool_to_sys(const CMPI if (!match_hypervisor_prefix(ref, info)) goto out; - s = get_pool_inst(_BROKER, ref, &inst); - if ((s.rc != CMPI_RC_OK) || (inst == NULL)) + s = get_pool_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) goto out; s = get_host(_BROKER, ref, &inst, false); @@ -67,26 +68,15 @@ static CMPIStatus sys_to_pool(const CMPI { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *inst = NULL; - int i; - virConnectPtr conn; if (!match_hypervisor_prefix(ref, info)) goto out; - + s = get_host(_BROKER, ref, &inst, true); if (s.rc != CMPI_RC_OK) goto out; - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - for (i = 0; device_pool_names[i]; i++) - get_pool_by_type(_BROKER, - conn, - device_pool_names[i], - NAMESPACE(ref), - list); + s = enum_pools(_BROKER, ref, CIM_POOL_TYPE_ALL, list); out: return s;

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204709618 -3600 # Node ID dfd9e623fef6ec927b06ab546857765b47482f87 # Parent ee7aecb09ec486d4d47134fef328ae207b608e1d RAFP: adopt DevicePool interface changes - adopted changes to DevicePool interface Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r ee7aecb09ec4 -r dfd9e623fef6 src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Wed Mar 05 10:33:37 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Wed Mar 05 10:33:38 2008 +0100 @@ -45,7 +45,6 @@ static CMPIStatus rasd_to_pool(const CMP uint16_t type; const char *id = NULL; char *poolid = NULL; - virConnectPtr conn = NULL; CMPIInstance *pool = NULL; CMPIInstance *inst = NULL; @@ -78,28 +77,17 @@ static CMPIStatus rasd_to_pool(const CMP goto out; } - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - pool = get_pool_by_id(_BROKER, - conn, - poolid, - NAMESPACE(ref)); - if (pool != NULL) { - inst_list_add(list, pool); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } else { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to find pool `%s'", poolid); - } + s = get_pool_by_name(_BROKER, + ref, + poolid, + &pool); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, pool); out: free(poolid); - virConnectClose(conn); return s; } @@ -191,7 +179,11 @@ static CMPIStatus pool_to_rasd(const CMP CMPIInstance *inst; if (!match_hypervisor_prefix(ref, info)) - return s; + goto out; + + s = get_pool_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, @@ -207,10 +199,6 @@ static CMPIStatus pool_to_rasd(const CMP "Invalid InstanceID or unsupported pool type"); goto out; } - - s = get_pool_inst(_BROKER, ref, &inst); - if ((s.rc != CMPI_RC_OK) || (inst == NULL)) - goto out; rasds_from_pool(type, ref, @@ -218,9 +206,6 @@ static CMPIStatus pool_to_rasd(const CMP info->properties, list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204710377 -3600 # Node ID 2e9dc85abc269153ec38d1970b3e706168711f6c # Parent dfd9e623fef6ec927b06ab546857765b47482f87 EAFP: adopt DevicePool interface changes - adopted changes to DevicePool interface - updated resource types Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r dfd9e623fef6 -r 2e9dc85abc26 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Wed Mar 05 10:33:38 2008 +0100 +++ b/src/Virt_ElementAllocatedFromPool.c Wed Mar 05 10:46:17 2008 +0100 @@ -45,15 +45,15 @@ static uint16_t class_to_type(const CMPI uint16_t type; if (CMClassPathIsA(_BROKER, ref, "CIM_LogicalDisk", NULL)) - type = CIM_RASD_TYPE_DISK; + type = CIM_RES_TYPE_DISK; else if (CMClassPathIsA(_BROKER, ref, "CIM_NetworkPort", NULL)) - type = CIM_RASD_TYPE_NET; + type = CIM_RES_TYPE_NET; else if (CMClassPathIsA(_BROKER, ref, "CIM_Memory", NULL)) - type = CIM_RASD_TYPE_MEM; + type = CIM_RES_TYPE_MEM; else if (CMClassPathIsA(_BROKER, ref, "CIM_Processor", NULL)) - type = CIM_RASD_TYPE_PROC; + type = CIM_RES_TYPE_PROC; else - type = 0; + type = CIM_RES_TYPE_UNKNOWN; return type; } @@ -66,12 +66,16 @@ static CMPIStatus vdev_to_pool(const CMP uint16_t type; const char *id = NULL; char *poolid = NULL; - virConnectPtr conn = NULL; CMPIInstance *pool = NULL; + CMPIInstance *inst = NULL; if (!match_hypervisor_prefix(ref, info)) return s; + s = get_device_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + type = class_to_type(ref); if (type == 0) { cu_statusf(_BROKER, &s, @@ -95,25 +99,14 @@ static CMPIStatus vdev_to_pool(const CMP goto out; } - conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); - if (conn == NULL) - goto out; - - pool = get_pool_by_id(_BROKER, conn, poolid, NAMESPACE(ref)); - if (pool != NULL) { - inst_list_add(list, pool); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); - } else { - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Unable to find pool `%s'", poolid); - } + s = get_pool_by_name(_BROKER, ref, poolid, &pool); + if (s.rc != CMPI_RC_OK) + goto out; + + inst_list_add(list, pool); out: free(poolid); - virConnectClose(conn); return s; } @@ -172,7 +165,6 @@ static int devs_from_pool(uint16_t type, name = virDomainGetName(doms[i]); - /* FIXME: Get VIRT_DEV_ type here */ dom_devices(_BROKER, doms[i], ns, type, &tmp); filter_by_pool(list, &tmp, type, poolid); @@ -199,6 +191,10 @@ static CMPIStatus pool_to_vdev(const CMP if (!match_hypervisor_prefix(ref, info)) return s; + s = get_pool_by_ref(_BROKER, ref, &inst); + if (s.rc != CMPI_RC_OK) + goto out; + if (cu_get_str_path(ref, "InstanceID", &poolid) != CMPI_RC_OK) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -206,25 +202,16 @@ static CMPIStatus pool_to_vdev(const CMP goto out; } - CU_DEBUG("Got %s\n", poolid); - type = device_type_from_poolid(poolid); - if (type == VIRT_DEV_UNKNOWN) { + if (type == CIM_RES_TYPE_UNKNOWN) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Invalid InstanceID or unsupported pool type"); goto out; } - s = get_pool_inst(_BROKER, ref, &inst); - if ((s.rc != CMPI_RC_OK) || (inst == NULL)) - goto out; - devs_from_pool(type, ref, poolid, list); - cu_statusf(_BROKER, &s, - CMPI_RC_OK, - ""); out: return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204710379 -3600 # Node ID eeb2c60ee909c70927f230735f8e1fc763d3eed3 # Parent 2e9dc85abc269153ec38d1970b3e706168711f6c AllocationCapabilities: adopt new DevicePool enum interface - adopted new DevicePool enum_pools() interface - updated NOT_FOUND error message to be consistent with others Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 2e9dc85abc26 -r eeb2c60ee909 src/Virt_AllocationCapabilities.c --- a/src/Virt_AllocationCapabilities.c Wed Mar 05 10:46:17 2008 +0100 +++ b/src/Virt_AllocationCapabilities.c Wed Mar 05 10:46:19 2008 +0100 @@ -33,6 +33,7 @@ #include "Virt_AllocationCapabilities.h" #include "Virt_DevicePool.h" +#include "svpc_types.h" const static CMPIBroker *_BROKER; @@ -95,11 +96,11 @@ CMPIStatus enum_alloc_cap_instances(cons if (id) cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "Requested Object could not be found."); - goto out; - } - - s = get_all_pools(broker, conn, NAMESPACE(ref), &device_pool_list); + "Instance not found."); + goto out; + } + + s = enum_pools(broker, ref, CIM_POOL_TYPE_ALL, &device_pool_list); if (s.rc != CMPI_RC_OK) { cu_statusf(broker, &s, CMPI_RC_ERR_FAILED, @@ -135,7 +136,7 @@ CMPIStatus enum_alloc_cap_instances(cons if (id && !inst_id) { cu_statusf(broker, &s, CMPI_RC_ERR_NOT_FOUND, - "Requested Object could not be found."); + "Instance not found."); goto out; }
participants (2)
-
Dan Smith
-
Heidi Eckhart