# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1202131344 -3600
# Node ID 4f877945eeba7e1c6a690150057b0221a882d002
# Parent f3ea51dea6f805fa354d173f38a9c5037e4785a3
RPCC: returns instances of Xen on a KVM only system
This breaks the approach that is used all over libvirt-cim
providers, where only instances of the currently supported
hypervisor type are returned.
Signed-off-by: Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
diff -r f3ea51dea6f8 -r 4f877945eeba src/Virt_ResourcePoolConfigurationCapabilities.c
--- a/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:16 2008 +0100
+++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Mon Feb 04 14:22:24 2008 +0100
@@ -47,45 +47,63 @@ DEFAULT_EQ();
DEFAULT_EQ();
DEFAULT_INST_CLEANUP();
-static CMPIStatus get_rpc_cap(const CMPIBroker *broker,
- const CMPIObjectPath *reference,
- CMPIInstance **_inst)
+static CMPIStatus get_rpc_cap(const CMPIObjectPath *reference,
+ CMPIInstance **_inst,
+ bool getInstance)
{
- CMPIInstance *inst;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ virConnectPtr conn = NULL;
- inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
+
+ inst = get_typed_instance(_BROKER,
+ pfx_from_conn(conn),
"ResourcePoolConfigurationCapabilities",
NAMESPACE(reference));
if (inst == NULL)
- return (CMPIStatus){CMPI_RC_ERR_FAILED, NULL};
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Can't create ResourcePoolConfigurationCapabilities
instance");
CMSetProperty(inst, "InstanceID",
(CMPIValue *)"RPCC", CMPI_chars);
/* No method currently supported */
+ if (getInstance) {
+ s = cu_validate_ref(_BROKER, reference, inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
*_inst = inst;
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ out:
+ virConnectClose(conn);
+
+ return s;
}
static CMPIStatus return_rpc_cap(const CMPIObjectPath *reference,
const CMPIResult *results,
- bool names_only)
+ bool names_only,
+ bool getInstance)
{
CMPIStatus s;
- CMPIInstance *inst;
+ CMPIInstance *inst = NULL;
- s = get_rpc_cap(_BROKER, reference, &inst);
- if (s.rc != CMPI_RC_OK)
+ s = get_rpc_cap(reference, &inst, getInstance);
+ if (s.rc != CMPI_RC_OK || inst == NULL)
goto out;
-
+
if (names_only)
cu_return_instance_name(results, inst);
else
CMReturnInstance(results, inst);
-
+
out:
return s;
}
@@ -95,7 +113,7 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- return return_rpc_cap(reference, results, 1);
+ return return_rpc_cap(reference, results, true, false);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -105,7 +123,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_rpc_cap(reference, results, 0);
+ return return_rpc_cap(reference, results, false, false);
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -114,7 +132,7 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *reference,
const char **properties)
{
- return return_rpc_cap(reference, results, 0);
+ return return_rpc_cap(reference, results, false, true);
}