# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1203123381 28800
# Node ID 9b93bc85520bc6a9cb486066e83acd8af2432c6a
# Parent db0f626f74052bc78be3d62e9b530f6af6d7ae3b
Add reference validation to get_migration_service().
Adds reference validation to VirtualSystemMigrationService.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r db0f626f7405 -r 9b93bc85520b src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Fri Feb 15 13:50:26 2008 -0800
+++ b/src/Virt_VSMigrationService.c Fri Feb 15 16:56:21 2008 -0800
@@ -755,12 +755,23 @@ STDIM_MethodMIStub(, Virt_VSMigrationSer
CMPIStatus get_migration_service(const CMPIObjectPath *ref,
CMPIInstance **_inst,
- const CMPIBroker *broker)
+ const CMPIBroker *broker,
+ bool is_get_inst)
{
CMPIInstance *inst;
CMPIStatus s = {CMPI_RC_OK, NULL};
+ virConnectPtr conn = NULL;
const char *name = NULL;
const char *ccname = 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;
+ }
inst = get_typed_instance(broker,
CLASSNAME(ref),
@@ -793,6 +804,12 @@ CMPIStatus get_migration_service(const C
CMSetProperty(inst, "SystemCreationClassName",
(CMPIValue *)ccname, CMPI_chars);
+ if (is_get_inst) {
+ s = cu_validate_ref(broker, ref, inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
cu_statusf(broker, &s,
CMPI_RC_OK,
"");
@@ -800,24 +817,28 @@ CMPIStatus get_migration_service(const C
*_inst = inst;
out:
+ virConnectClose(conn);
+
return s;
}
static CMPIStatus return_vsms(const CMPIObjectPath *ref,
const CMPIResult *results,
- bool name_only)
+ bool name_only,
+ bool is_get_inst)
{
CMPIInstance *inst;
CMPIStatus s;
- s = get_migration_service(ref, &inst, _BROKER);
- if (s.rc == CMPI_RC_OK) {
- if (name_only)
- cu_return_instance_name(results, inst);
- else
- CMReturnInstance(results, inst);
- }
-
+ s = get_migration_service(ref, &inst, _BROKER, is_get_inst);
+ if ((s.rc != CMPI_RC_OK) || (inst == NULL))
+ goto out;
+
+ if (name_only)
+ cu_return_instance_name(results, inst);
+ else
+ CMReturnInstance(results, inst);
+ out:
return s;
}
@@ -826,7 +847,7 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *ref)
{
- return return_vsms(ref, results, true);
+ return return_vsms(ref, results, true, false, false);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -836,7 +857,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_vsms(ref, results, false);
+ return return_vsms(ref, results, false, false, false);
}
@@ -846,24 +867,7 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *ref,
const char **properties)
{
- CMPIInstance *inst;
- CMPIStatus s;
- const char *prop;
-
- s = get_migration_service(ref, &inst, _BROKER);
- if (s.rc != CMPI_RC_OK)
- return s;
-
- prop = cu_compare_ref(ref, 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_vsms(ref, results, false, true, true);
}
DEFAULT_CI();
diff -r db0f626f7405 -r 9b93bc85520b src/Virt_VSMigrationService.h
--- a/src/Virt_VSMigrationService.h Fri Feb 15 13:50:26 2008 -0800
+++ b/src/Virt_VSMigrationService.h Fri Feb 15 16:56:21 2008 -0800
@@ -21,7 +21,8 @@
CMPIStatus get_migration_service(const CMPIObjectPath *reference,
CMPIInstance **_inst,
- const CMPIBroker *broker);
+ const CMPIBroker *broker,
+ bool is_get_inst);
/*
* Local Variables: