# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1194454371 28800
# Node ID 2626820d78b2d70564096dcacf6a2f1b2bc726e1
# Parent 55d37343f11204b02dde1df910001e8021a5afc5
Make ResourcePoolConfigurationService return errors when appropriate
and fix up some other general error-handling around the needed changes.
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 55d37343f112 -r 2626820d78b2 src/Virt_ResourcePoolConfigurationService.c
--- a/src/Virt_ResourcePoolConfigurationService.c Wed Nov 07 08:41:36 2007 -0800
+++ b/src/Virt_ResourcePoolConfigurationService.c Wed Nov 07 08:52:51 2007 -0800
@@ -89,7 +89,8 @@ DEFAULT_EQ();
DEFAULT_EQ();
DEFAULT_INST_CLEANUP();
-static CMPIInstance *rpcs_instance(const CMPIObjectPath *reference)
+static CMPIStatus rpcs_instance(const CMPIObjectPath *reference,
+ CMPIInstance **_inst)
{
CMPIInstance *inst;
CMPIInstance *host;
@@ -98,28 +99,47 @@ static CMPIInstance *rpcs_instance(const
s = get_host_cs(_BROKER, reference, &host);
if (s.rc != CMPI_RC_OK)
- return NULL;
+ goto out;
inst = get_typed_instance(_BROKER,
"ResourcePoolConfigurationService",
NAMESPACE(reference));
+ if (inst == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get "
+ "ResourcePoolConfigurationService instance");
+ goto out;
+ }
CMSetProperty(inst, "Name",
(CMPIValue *)"RPCS", CMPI_chars);
prop = CMGetProperty(host, "CreationClassName", &s);
- if (s.rc != CMPI_RC_OK)
- return NULL;
+ if (s.rc != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get CreationClassName from HostSystem");
+ goto out;
+ }
+
CMSetProperty(inst, "SystemCreationClassName",
(CMPIValue *)&prop.value.string, CMPI_string);
prop = CMGetProperty(host, "Name", NULL);
- if (s.rc != CMPI_RC_OK)
- return NULL;
+ if (s.rc != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Unable to get Name from HostSystem");
+ goto out;
+ }
+
CMSetProperty(inst, "SystemName",
(CMPIValue *)&prop.value.string, CMPI_string);
- return inst;
+ *_inst = inst;
+ out:
+ return s;
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -129,12 +149,23 @@ static CMPIStatus GetInstance(CMPIInstan
const char **properties)
{
CMPIInstance *inst;
-
- inst = rpcs_instance(reference);
-
- CMReturnInstance(results, inst);
-
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ CMPIStatus s;
+ const char *prop = NULL;
+
+ s = rpcs_instance(reference, &inst);
+ if (s.rc != CMPI_RC_OK)
+ return s;
+
+ prop = cu_compare_ref(reference, inst);
+ if (prop != NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance (%s)", prop);
+ } else {
+ CMReturnInstance(results, inst);
+ }
+
+ return s;
}
static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self,
@@ -143,12 +174,13 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIObjectPath *reference)
{
CMPIInstance *inst;
-
- inst = rpcs_instance(reference);
-
- cu_return_instance_name(results, inst);
-
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst);
+ if (s.rc == CMPI_RC_OK)
+ cu_return_instance_name(results, inst);
+
+ return s;
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -159,12 +191,13 @@ static CMPIStatus EnumInstances(CMPIInst
{
CMPIInstance *inst;
-
- inst = rpcs_instance(reference);
-
- CMReturnInstance(results, inst);
-
- return (CMPIStatus){CMPI_RC_OK, NULL};
+ CMPIStatus s;
+
+ s = rpcs_instance(reference, &inst);
+ if (s.rc == CMPI_RC_OK)
+ CMReturnInstance(results, inst);
+
+ return s;
}