[PATCH 0 of 4] #3 - Fixes to RegisteredProfile and ECTP depending on connect_by_classname approach

-ixes duplicates of RegisteredProfile, adopt changes to RegisteredProfile to association ECTP - fix hypervisor prefix for ECTP; remove error label and let label out do all the free() stuff

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196240875 -3600 # Node ID 82a65502cfb3814efe409879675f486d6f282c7d # Parent dca4cb9c22da97bfef6c2771bf082efbd6d32bc4 Enumeration of RegisteredProfile class is returning wrong instances Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r dca4cb9c22da -r 82a65502cfb3 src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Tue Nov 27 10:34:13 2007 +0100 +++ b/src/Virt_RegisteredProfile.c Wed Nov 28 10:07:55 2007 +0100 @@ -43,25 +43,23 @@ CMPIInstance *reg_prof_instance(const CM CMPIInstance *reg_prof_instance(const CMPIBroker *broker, const char *namespace, const char **properties, + virConnectPtr conn, struct reg_prof *profile) { CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIObjectPath *op; CMPIInstance *instance = NULL; - char *classname; - - classname = get_typed_class("Xen", "RegisteredProfile"); - if (classname == NULL) { + + instance = get_typed_instance(broker, + pfx_from_conn(conn), + "RegisteredProfile", + namespace); + + if (instance == NULL) { + CMSetStatusWithChars(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create RegisteredProfile instance."); goto out; } - - op = CMNewObjectPath(broker, namespace, classname, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) - goto out; - - instance = CMNewInstance(broker, op, &s); - if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) - goto out; if (properties) { s = CMSetPropertyFilter(instance, properties, NULL); @@ -83,8 +81,6 @@ CMPIInstance *reg_prof_instance(const CM (CMPIValue *)profile->reg_version, CMPI_chars); out: - free(classname); - return instance; } @@ -95,12 +91,18 @@ static CMPIStatus enum_profs(const CMPIO { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance; + virConnectPtr conn = NULL; int i; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; for (i = 0; profiles[i] != NULL; i++) { instance = reg_prof_instance(_BROKER, NAMESPACE(ref), - properties, + properties, + conn, profiles[i]); if (instance == NULL) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -115,6 +117,8 @@ static CMPIStatus enum_profs(const CMPIO } out: + virConnectClose(conn); + return s; } @@ -124,15 +128,20 @@ static CMPIStatus get_prof(const CMPIObj { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance = NULL; + virConnectPtr conn = NULL; char* id; int i; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; id = cu_get_str_path(ref, "InstanceID"); if (id == NULL) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "No InstanceID specified"); - return s; + goto out; } for (i = 0; profiles[i] != NULL; i++) { @@ -140,6 +149,7 @@ static CMPIStatus get_prof(const CMPIObj instance = reg_prof_instance(_BROKER, NAMESPACE(ref), properties, + conn, profiles[i]); break; } @@ -150,8 +160,10 @@ static CMPIStatus get_prof(const CMPIObj else CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); - free(id); + + out: + virConnectClose(conn); return s; } diff -r dca4cb9c22da -r 82a65502cfb3 src/Virt_RegisteredProfile.h --- a/src/Virt_RegisteredProfile.h Tue Nov 27 10:34:13 2007 +0100 +++ b/src/Virt_RegisteredProfile.h Wed Nov 28 10:07:55 2007 +0100 @@ -24,6 +24,7 @@ CMPIInstance *reg_prof_instance(const CM CMPIInstance *reg_prof_instance(const CMPIBroker *broker, const char *namespace, const char **properties, + virConnectPtr conn, struct reg_prof *profile); #endif

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196242330 -3600 # Node ID 99b7a3180bca444d3670a9f6295e47a920b1da11 # Parent 82a65502cfb3814efe409879675f486d6f282c7d Adoption of changes to RegisteredProfile Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 82a65502cfb3 -r 99b7a3180bca src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:07:55 2007 +0100 +++ b/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:32:10 2007 +0100 @@ -133,9 +133,14 @@ static CMPIStatus elem_to_prof(const CMP { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIInstance *instance; + virConnectPtr conn = NULL; char *classname; struct reg_prof *candidate; int i; + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; classname = class_base_name(CLASSNAME(ref)); if (classname == NULL) { @@ -151,10 +156,12 @@ static CMPIStatus elem_to_prof(const CMP instance = reg_prof_instance(_BROKER, "/root/interop", - NULL, + NULL, + conn, candidate); if (instance == NULL) { - CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, + CMSetStatusWithChars(_BROKER, &s, + CMPI_RC_ERR_FAILED, "Can't create profile instance."); goto error; } @@ -165,6 +172,8 @@ static CMPIStatus elem_to_prof(const CMP error: free(classname); out: + virConnectClose(conn); + return s; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196242413 -3600 # Node ID d86ff33c049964d91fe8b800e5562f178b3cf4a0 # Parent 99b7a3180bca444d3670a9f6295e47a920b1da11 Fix class prefix to depend on established hypervisor connection Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 99b7a3180bca -r d86ff33c0499 src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:32:10 2007 +0100 +++ b/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:33:33 2007 +0100 @@ -50,7 +50,8 @@ static CMPIStatus elem_instances(const C static CMPIStatus elem_instances(const CMPIObjectPath *ref, struct std_assoc_info *info, struct inst_list *list, - struct reg_prof *profile) + struct reg_prof *profile, + virConnectPtr conn) { CMPIStatus s = {CMPI_RC_OK, NULL}; CMPIObjectPath *op; @@ -58,7 +59,8 @@ static CMPIStatus elem_instances(const C CMPIData data ; char *classname; - classname = get_typed_class("Xen", profile->provider_name); + classname = get_typed_class(pfx_from_conn(conn), + profile->provider_name); if (classname == NULL) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -101,9 +103,14 @@ static CMPIStatus prof_to_elem(const CMP struct inst_list *list) { CMPIStatus s = {CMPI_RC_OK, NULL}; + virConnectPtr conn = NULL; char *id; int i; + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + return s; + id = cu_get_str_path(ref, "InstanceID"); if (id == NULL) { CMSetStatusWithChars(_BROKER, &s, @@ -114,7 +121,8 @@ static CMPIStatus prof_to_elem(const CMP for (i = 0; profiles[i] != NULL; i++) { if (STREQ(id, profiles[i]->reg_id)) { - s = elem_instances(ref, info, list, profiles[i]); + s = elem_instances(ref, info, list, + profiles[i], conn); if ((s.rc != CMPI_RC_OK)) goto error; break; @@ -124,6 +132,8 @@ static CMPIStatus prof_to_elem(const CMP error: free(id); out: + virConnectClose(conn); + return s; } @@ -182,10 +192,16 @@ static CMPIInstance *make_ref(const CMPI struct std_assoc_info *info, struct std_assoc *assoc) { - CMPIInstance *assoc_inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + CMPIInstance *assoc_inst = NULL; + virConnectPtr conn = NULL; + + conn = connect_by_classname(_BROKER, CLASSNAME(source_op), &s); + if (conn == NULL) + return NULL; assoc_inst = get_typed_instance(_BROKER, - "Xen", + pfx_from_conn(conn), "ElementConformsToProfile", NAMESPACE(source_op)); @@ -198,6 +214,8 @@ static CMPIInstance *make_ref(const CMPI CMSetProperty(assoc_inst, assoc->target_prop, (CMPIValue *)&(target_op), CMPI_ref); } + + virConnectClose(conn); return assoc_inst; }

# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1196242630 -3600 # Node ID ebb86619d5ca80ad7815f9d70d2c8a87698a5f0f # Parent d86ff33c049964d91fe8b800e5562f178b3cf4a0 Housekeeping of label error to ECTP Removed labels error and let label out do all the free() stuff Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r d86ff33c0499 -r ebb86619d5ca src/Virt_ElementConformsToProfile.c --- a/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:33:33 2007 +0100 +++ b/src/Virt_ElementConformsToProfile.c Wed Nov 28 10:37:10 2007 +0100 @@ -70,14 +70,14 @@ static CMPIStatus elem_instances(const C op = CMNewObjectPath(_BROKER, CIM_VIRT_NS, classname, &s); if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op)) - goto error; + goto out; en = CBEnumInstances(_BROKER, info->context , op, NULL, &s); if (en == NULL) { CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Upcall enumInstances to target class failed."); - goto error; + goto out; } while (CMHasNext(en, &s)) { @@ -86,15 +86,15 @@ static CMPIStatus elem_instances(const C CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Failed to retrieve enumeration entry."); - goto error; + goto out; } inst_list_add(list, data.value.inst); } - error: + out: free(classname); - out: + return s; } @@ -124,14 +124,13 @@ static CMPIStatus prof_to_elem(const CMP s = elem_instances(ref, info, list, profiles[i], conn); if ((s.rc != CMPI_RC_OK)) - goto error; + goto out; break; } } - error: + out: free(id); - out: virConnectClose(conn); return s; @@ -173,15 +172,14 @@ static CMPIStatus elem_to_prof(const CMP CMSetStatusWithChars(_BROKER, &s, CMPI_RC_ERR_FAILED, "Can't create profile instance."); - goto error; + goto out; } inst_list_add(list, instance); } - - error: + + out: free(classname); - out: virConnectClose(conn); return s;

Heidi Eckhart wrote:
-ixes duplicates of RegisteredProfile, adopt changes to RegisteredProfile to association ECTP - fix hypervisor prefix for ECTP; remove error label and let label out do all the free() stuff
This set looks good to me. +1 -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com
participants (2)
-
Heidi Eckhart
-
Kaitlin Rupert