# HG changeset patch
# User Heidi Eckhart <heidieck(a)linux.vnet.ibm.com>
# Date 1201865505 -3600
# Node ID d4b86a39d55d2208c5f56a6666ccc212ab60a240
# Parent 6b1bf8231d82f51f25ac3d954b63962bfc7484c9
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 6b1bf8231d82 -r d4b86a39d55d src/Virt_ResourcePoolConfigurationCapabilities.c
--- a/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:20:46 2008 +0100
+++ b/src/Virt_ResourcePoolConfigurationCapabilities.c Fri Feb 01 12:31:45 2008 +0100
@@ -51,28 +51,39 @@ static CMPIStatus get_rpc_cap(const CMPI
const CMPIObjectPath *reference,
CMPIInstance **_inst)
{
- CMPIInstance *inst;
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ CMPIInstance *inst = NULL;
+ virConnectPtr conn = NULL;
+
+ conn = connect_by_classname(_BROKER, CLASSNAME(reference), &s);
+ if (conn == NULL)
+ goto out;
inst = get_typed_instance(broker,
- CLASSNAME(reference),
+ 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 */
+ out:
*_inst = inst;
-
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ 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;
@@ -81,11 +92,19 @@ static CMPIStatus return_rpc_cap(const C
if (s.rc != CMPI_RC_OK)
goto out;
+ if (inst == NULL) {
+ if (getInstance)
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
+ goto out;
+ }
+
if (names_only)
cu_return_instance_name(results, inst);
else
CMReturnInstance(results, inst);
-
+
out:
return s;
}
@@ -95,7 +114,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 +124,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 +133,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);
}