# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1195735052 -3600
# Node ID fb84303afda80d4d180e9951b114f2769a5d6baa
# Parent 710a381591c1a67e5a79ad3b04aaa8bc7adbb108
Enumeration on VirtualSystemManagementService class is returning dups
On systems where only one hypervisor is existing, the provider
returned instance for all known subclasses (Xen, KVM).
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r 710a381591c1 -r fb84303afda8 src/Virt_VirtualSystemManagementService.c
--- a/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:13:00 2007 +0100
+++ b/src/Virt_VirtualSystemManagementService.c Thu Nov 22 13:37:32 2007 +0100
@@ -1048,26 +1048,32 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMPIStatus get_vsms(const CMPIObjectPath *reference,
CMPIInstance **_inst,
const CMPIBroker *broker)
-{
- CMPIStatus s;
- CMPIInstance *inst;
- CMPIInstance *host;
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ CMPIInstance *host = NULL;
char *val = NULL;
+ virConnectPtr conn = NULL;
+
+ conn = connect_by_classname(broker, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
s = get_host_cs(broker, reference, &host);
if (s.rc != CMPI_RC_OK)
- goto out;
+ goto err;
inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ pfx_from_conn(conn),
"VirtualSystemManagementService",
NAMESPACE(reference));
+
if (inst == NULL) {
CU_DEBUG("Failed to get typed instance");
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
"Failed to create instance");
- goto out;
+ goto err;
}
CMSetProperty(inst, "Name",
@@ -1076,8 +1082,8 @@ CMPIStatus get_vsms(const CMPIObjectPath
if (cu_get_str_prop(host, "Name", &val) != CMPI_RC_OK) {
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get name of System");
- goto out;
+ "Unable to get name of HostSystem");
+ goto err;
}
CMSetProperty(inst, "SystemName",
@@ -1087,8 +1093,8 @@ CMPIStatus get_vsms(const CMPIObjectPath
if (cu_get_str_prop(host, "CreationClassName", &val) != CMPI_RC_OK)
{
cu_statusf(broker, &s,
CMPI_RC_ERR_FAILED,
- "Unable to get creation class of system");
- goto out;
+ "Unable to get creation class of HostSystem");
+ goto err;
}
CMSetProperty(inst, "SystemCreationClassName",
@@ -1097,8 +1103,11 @@ CMPIStatus get_vsms(const CMPIObjectPath
CMSetStatus(&s, CMPI_RC_OK);
+ err:
+ virConnectClose(conn);
+
+ out:
*_inst = inst;
- out:
return s;
}
@@ -1106,19 +1115,17 @@ static CMPIStatus return_vsms(const CMPI
const CMPIResult *results,
int name_only)
{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst;
- CMPIStatus s;
s = get_vsms(reference, &inst, _BROKER);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK || inst == NULL)
goto out;
if (name_only)
cu_return_instance_name(results, inst);
else
CMReturnInstance(results, inst);
-
- CMSetStatus(&s, CMPI_RC_OK);
out:
return s;
}