[PATCH 0 of 5] 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.

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204545502 -3600 # Node ID 4748d0422f3891598680b74b3aa1bcb4acdcb9a1 # Parent eefe9c56b43c7ca0cad6f579fd88c5b89134bba0 DevicePool: adopt get_ interface common look and feel Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r eefe9c56b43c -r 4748d0422f38 src/Virt_DevicePool.c --- a/src/Virt_DevicePool.c Mon Mar 03 11:51:00 2008 +0100 +++ b/src/Virt_DevicePool.c Mon Mar 03 12:58:22 2008 +0100 @@ -701,13 +701,13 @@ CMPIStatus get_pool_by_type(const CMPIBr 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; +CMPIStatus get_pool_by_name(const CMPIBroker *broker, + const CMPIObjectPath *reference, + const char *id, + CMPIInstance **_inst) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; char *type = NULL; char *poolid = NULL; int ret; @@ -715,18 +715,34 @@ CMPIInstance *get_pool_by_id(const CMPIB inst_list_init(&list); + 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; + } + ret = sscanf(id, "%a[^/]/%as", &type, &poolid); - if (ret != 2) - goto out; - - s = _get_pool(broker, conn, type, poolid, ns, &list); + if (ret != 2) { + cu_statusf(broker, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s).", + id); + goto out; + } + + s = _get_pool(broker, conn, type, poolid, NAMESPACE(reference), &list); if ((s.rc == CMPI_RC_OK) && (list.cur > 0)) - inst = list.list[0]; + *_inst = list.list[0]; + + free(type); + free(poolid); out: inst_list_free(&list); - return inst; + return s; } CMPIStatus get_all_pools(const CMPIBroker *broker, @@ -763,8 +779,7 @@ static void __return_pool(const CMPIResu static CMPIStatus return_pool(const CMPIObjectPath *ref, const CMPIResult *results, - bool name_only, - bool single_only) + bool name_only) { CMPIStatus s; char *type; @@ -811,13 +826,12 @@ static CMPIStatus return_pool(const CMPI return s; } -CMPIStatus get_pool_inst(const CMPIBroker *broker, - const CMPIObjectPath *reference, - CMPIInstance **instance) -{ - CMPIStatus s; +CMPIStatus get_pool_by_ref(const CMPIBroker *broker, + const CMPIObjectPath *reference, + CMPIInstance **instance) +{ + CMPIStatus s = {CMPI_RC_OK}; CMPIInstance *inst = NULL; - virConnectPtr conn = NULL; const char *id = NULL; if (cu_get_str_path(reference, "InstanceID", &id) != CMPI_RC_OK) { @@ -827,24 +841,17 @@ CMPIStatus get_pool_inst(const CMPIBroke 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); + 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: - virConnectClose(conn); - *instance = inst; - return s; } @@ -853,7 +860,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 +869,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 +878,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 eefe9c56b43c -r 4748d0422f38 src/Virt_DevicePool.h --- a/src/Virt_DevicePool.h Mon Mar 03 11:51:00 2008 +0100 +++ b/src/Virt_DevicePool.h Mon Mar 03 12:58:22 2008 +0100 @@ -33,12 +33,6 @@ CMPIStatus get_pool_by_type(const CMPIBr 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 @@ -82,9 +76,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> +CMPIStatus get_pool_by_name(const CMPIBroker *broker, HE> + const CMPIObjectPath *reference, HE> + const char *id, HE> + CMPIInstance **_inst) HE> +{ HE> + CMPIStatus s = {CMPI_RC_OK, NULL}; HE> + virConnectPtr conn = NULL; You add a conn here... HE> out: HE> inst_list_free(&list); HE> - return inst; HE> + return s; HE> } ...but don't close it here. -- 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 1204546145 -3600 # Node ID 0d2ac636d4463d881b1e200c44f1086411e5c074 # Parent 4748d0422f3891598680b74b3aa1bcb4acdcb9a1 SDC: adopt DevicePool interface change Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 4748d0422f38 -r 0d2ac636d446 src/Virt_SettingsDefineCapabilities.c --- a/src/Virt_SettingsDefineCapabilities.c Mon Mar 03 12:58:22 2008 +0100 +++ b/src/Virt_SettingsDefineCapabilities.c Mon Mar 03 13:09:05 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 1204546228 -3600 # Node ID 4166fe782224243c171c9dc8c08e95a447177736 # Parent 0d2ac636d4463d881b1e200c44f1086411e5c074 HRP: adopt DevicePool interface change Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 0d2ac636d446 -r 4166fe782224 src/Virt_HostedResourcePool.c --- a/src/Virt_HostedResourcePool.c Mon Mar 03 13:09:05 2008 +0100 +++ b/src/Virt_HostedResourcePool.c Mon Mar 03 13:10:28 2008 +0100 @@ -47,8 +47,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);

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1204546778 -3600 # Node ID 0110c5e63a7f4ed7bc556dacb407dba8a0f1380d # Parent 4166fe782224243c171c9dc8c08e95a447177736 RAFP: adopt DevicePool interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 4166fe782224 -r 0110c5e63a7f src/Virt_ResourceAllocationFromPool.c --- a/src/Virt_ResourceAllocationFromPool.c Mon Mar 03 13:10:28 2008 +0100 +++ b/src/Virt_ResourceAllocationFromPool.c Mon Mar 03 13:19: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 1204547111 -3600 # Node ID e8d6ec769854a8b3276de24919e3f5a50382aaaa # Parent 0110c5e63a7f4ed7bc556dacb407dba8a0f1380d EAFP: adopt DevicePool interface changes Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 0110c5e63a7f -r e8d6ec769854 src/Virt_ElementAllocatedFromPool.c --- a/src/Virt_ElementAllocatedFromPool.c Mon Mar 03 13:19:38 2008 +0100 +++ b/src/Virt_ElementAllocatedFromPool.c Mon Mar 03 13:25:11 2008 +0100 @@ -66,7 +66,6 @@ static CMPIStatus vdev_to_pool(const CMP uint16_t type; const char *id = NULL; char *poolid = NULL; - virConnectPtr conn = NULL; CMPIInstance *pool = NULL; if (!match_hypervisor_prefix(ref, info)) @@ -95,25 +94,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; } @@ -199,6 +187,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, @@ -215,10 +207,6 @@ static CMPIStatus pool_to_vdev(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; devs_from_pool(type, ref, poolid, list);
participants (2)
-
Dan Smith
-
Heidi Eckhart