# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1196156619 -3600
# Node ID c3f590ec1553352439cbc6a884817ac13dc8eb40
# Parent ce846c470102c9c126b027c68d58f5205cadfb10
Enumeration of RegisteredProfile class is returning wrong instances
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r ce846c470102 -r c3f590ec1553 src/Virt_RegisteredProfile.c
--- a/src/Virt_RegisteredProfile.c Tue Nov 27 10:34:13 2007 +0100
+++ b/src/Virt_RegisteredProfile.c Tue Nov 27 10:43:39 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 HostSystem 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 ce846c470102 -r c3f590ec1553 src/Virt_RegisteredProfile.h
--- a/src/Virt_RegisteredProfile.h Tue Nov 27 10:34:13 2007 +0100
+++ b/src/Virt_RegisteredProfile.h Tue Nov 27 10:43:39 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