# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1203104501 28800
# Node ID 485d129ffabd639f7d28f29584065550dba4a267
# Parent 6792d7ab0cc36e99d95b6b8afd50fec887334007
Add reference validation to get_vsm_cap().
Adds reference validation to VirtualSystemManagementCapabilities.
Also change names_only of return_vsm_cap() from an int to a bool.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 6792d7ab0cc3 -r 485d129ffabd src/Virt_VirtualSystemManagementCapabilities.c
--- a/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 09:57:43 2008 -0800
+++ b/src/Virt_VirtualSystemManagementCapabilities.c Fri Feb 15 11:41:41 2008 -0800
@@ -83,11 +83,22 @@ static CMPIStatus set_inst_properties(co
CMPIStatus get_vsm_cap(const CMPIBroker *broker,
const CMPIObjectPath *ref,
- CMPIInstance **inst)
+ CMPIInstance **inst,
+ bool is_get_inst)
{
CMPIStatus s;
CMPIObjectPath *op;
+ virConnectPtr conn = NULL;
char *classname = NULL;
+
+ conn = connect_by_classname(broker, CLASSNAME(ref), &s);
+ if (conn == NULL) {
+ if (is_get_inst)
+ cu_statusf(broker, &s,
+ CMPI_RC_ERR_NOT_FOUND,
+ "No such instance");
+ goto out;
+ }
classname = get_typed_class(CLASSNAME(ref),
"VirtualSystemManagementCapabilities");
@@ -116,26 +127,29 @@ CMPIStatus get_vsm_cap(const CMPIBroker
s = set_inst_properties(broker, *inst, classname);
+ if (is_get_inst) {
+ s = cu_validate_ref(broker, ref, *inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
out:
free(classname);
+ virConnectClose(conn);
return s;
}
static CMPIStatus return_vsm_cap(const CMPIObjectPath *ref,
const CMPIResult *results,
- int names_only)
+ bool names_only,
+ bool is_get_inst)
{
CMPIStatus s = {CMPI_RC_OK, NULL};
CMPIInstance *inst = NULL;
- virConnectPtr conn = NULL;
-
- conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
- if (conn == NULL)
- goto out;
-
- s = get_vsm_cap(_BROKER, ref, &inst);
- if (s.rc != CMPI_RC_OK)
+
+ s = get_vsm_cap(_BROKER, ref, &inst, is_get_inst);
+ if ((s.rc != CMPI_RC_OK) || (inst == NULL))
goto out;
if (names_only)
@@ -143,8 +157,6 @@ static CMPIStatus return_vsm_cap(const C
else
CMReturnInstance(results, inst);
out:
- virConnectClose(conn);
-
return s;
}
@@ -153,7 +165,7 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *reference)
{
- return return_vsm_cap(reference, results, 1);
+ return return_vsm_cap(reference, results, true, false);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -163,7 +175,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_vsm_cap(reference, results, 0);
+ return return_vsm_cap(reference, results, true, false);
}
static CMPIStatus GetInstance(CMPIInstanceMI *self,
@@ -172,24 +184,7 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *reference,
const char **properties)
{
- CMPIInstance *inst;
- CMPIStatus s;
- const char *prop;
-
- s = get_vsm_cap(_BROKER, 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;
+ return return_vsm_cap(reference, results, false, true);
}
DEFAULT_CI();
diff -r 6792d7ab0cc3 -r 485d129ffabd src/Virt_VirtualSystemManagementCapabilities.h
--- a/src/Virt_VirtualSystemManagementCapabilities.h Fri Feb 15 09:57:43 2008 -0800
+++ b/src/Virt_VirtualSystemManagementCapabilities.h Fri Feb 15 11:41:41 2008 -0800
@@ -20,7 +20,8 @@
*/
CMPIStatus get_vsm_cap(const CMPIBroker *broker,
const CMPIObjectPath *ref,
- CMPIInstance **inst);
+ CMPIInstance **inst,
+ bool is_get_inst);
/*
* Local Variables:
* mode: C