# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1201864846 -3600
# Node ID 6b1bf8231d82f51f25ac3d954b63962bfc7484c9
# Parent cb0e8b858f4243a7086f627d65a07075b9f31ebc
RPCS: enumerateInstance(Name)s and getInstance with wrong hypervisor segfaults
wbemein
http://localhost/root/virt:CIM_ResourcePoolConfigurationService
on a KVM system with no Xen segfaults.
The same happens to
wbemgi
'http://localhost:5988/root/virt:Xen_ResourcePoolConfigurationService.SystemCreationClassName="Xen_HostSystem",SystemName="localhost.localdomain",CreationClassName="Xen_ResourcePoolConfigurationService",Name="RPCS"'
This patch also makes RPCS aware of the supported hypervisor type. Now only
instances of the machine's supported hypervisor are returned. This approach
is used all over the libvirt-cim providers, but was broken here.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r cb0e8b858f42 -r 6b1bf8231d82 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 11:17:15 2008 +0100
+++ b/src/Virt_ResourcePoolConfigurationService.c Fri Feb 01 12:20:46 2008 +0100
@@ -100,15 +100,20 @@ CMPIStatus rpcs_instance(const CMPIObjec
{
CMPIInstance *inst;
CMPIInstance *host;
- CMPIStatus s;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIData prop;
+ 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;
inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ pfx_from_conn(conn),
"ResourcePoolConfigurationService",
NAMESPACE(reference));
if (inst == NULL) {
@@ -145,7 +150,10 @@ CMPIStatus rpcs_instance(const CMPIObjec
(CMPIValue *)&prop.value.string, CMPI_string);
*_inst = inst;
+
out:
+ virConnectClose(conn);
+
return s;
}
@@ -155,13 +163,17 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *reference,
const char **properties)
{
- CMPIInstance *inst;
+ CMPIInstance *inst = NULL;
CMPIStatus s;
const char *prop = NULL;
s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc != CMPI_RC_OK)
+ if (s.rc != CMPI_RC_OK || inst == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
return s;
+ }
prop = cu_compare_ref(reference, inst);
if (prop != NULL) {
@@ -180,11 +192,11 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- CMPIInstance *inst;
- CMPIStatus s;
-
- s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc == CMPI_RC_OK)
+ CMPIInstance *inst = NULL;
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst, _BROKER);
+ if (s.rc == CMPI_RC_OK && inst != NULL)
cu_return_instance_name(results, inst);
return s;
@@ -197,11 +209,11 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- CMPIInstance *inst;
- CMPIStatus s;
-
- s = rpcs_instance(reference, &inst, _BROKER);
- if (s.rc == CMPI_RC_OK)
+ CMPIInstance *inst = NULL;
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst, _BROKER);
+ if (s.rc == CMPI_RC_OK && inst != NULL)
CMReturnInstance(results, inst);
return s;