
# HG changeset patch # User Heidi Eckhart <heidieck@linux.vnet.ibm.com> # Date 1195812344 -3600 # Node ID a479cec9721a58c537929206bc5190b22f709fc1 # Parent 4cce597d4e48b5e3efc6e4307be3234bd3051c9b Enumeration of RegisteredProfile class is returning wrong instances Signed-off-by: Heidi Eckhart <heidieck@linux.vnet.ibm.com> diff -r 4cce597d4e48 -r a479cec9721a src/Virt_RegisteredProfile.c --- a/src/Virt_RegisteredProfile.c Fri Nov 23 10:57:30 2007 +0100 +++ b/src/Virt_RegisteredProfile.c Fri Nov 23 11:05:44 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) { - 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; + + instance = get_typed_instance(broker, + pfx_from_conn(conn), + "RegisteredProfile", + namespace); + + if (instance == NULL) { + CMSetStatusWithChars(broker, &s, + CMPI_RC_ERR_FAILED, + "Can't create HostSystem instance."); + 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,17 +91,23 @@ 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) + goto out; 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, "Can't create profile instance."); - goto out; + goto err; } if (names_only) @@ -114,6 +116,8 @@ static CMPIStatus enum_profs(const CMPIO CMReturnInstance(results, instance); } + err: + virConnectClose(conn); out: 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) + goto out; 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,18 +149,19 @@ static CMPIStatus get_prof(const CMPIObj instance = reg_prof_instance(_BROKER, NAMESPACE(ref), properties, + conn, profiles[i]); break; } } + free(id); + out: if(instance) CMReturnInstance(results, instance); else CMSetStatus(&s, CMPI_RC_ERR_NOT_FOUND); - - free(id); return s; } diff -r 4cce597d4e48 -r a479cec9721a src/Virt_RegisteredProfile.h --- a/src/Virt_RegisteredProfile.h Fri Nov 23 10:57:30 2007 +0100 +++ b/src/Virt_RegisteredProfile.h Fri Nov 23 11:05:44 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