# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1203123517 28800
# Node ID f074335959a5eebb4b1a6300f421fbc2a94e3f2a
# Parent fe50fd4e9cfa5b858c9c5c6ce312031ca9af7dee
Add support for ref checking to VSMigrationCapabilities.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r fe50fd4e9cfa -r f074335959a5 src/Virt_VSMigrationCapabilities.c
--- a/src/Virt_VSMigrationCapabilities.c Fri Feb 15 16:57:58 2008 -0800
+++ b/src/Virt_VSMigrationCapabilities.c Fri Feb 15 16:58:37 2008 -0800
@@ -81,10 +81,21 @@ static CMPIStatus set_method_properties(
CMPIStatus get_migration_caps(const CMPIObjectPath *ref,
CMPIInstance **_inst,
- const CMPIBroker *broker)
+ const CMPIBroker *broker,
+ bool is_get_inst)
{
CMPIInstance *inst;
CMPIStatus s;
+ virConnectPtr conn = 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),
@@ -102,28 +113,42 @@ CMPIStatus get_migration_caps(const CMPI
s = set_method_properties(broker, inst);
- if (s.rc == CMPI_RC_OK)
- *_inst = inst;
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ if (is_get_inst) {
+ s = cu_validate_ref(broker, ref, inst);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+ }
+
+ *_inst = inst;
+
+ out:
+
+ virConnectClose(conn);
return s;
}
static CMPIStatus return_vsmc(const CMPIObjectPath *ref,
const CMPIResult *results,
- bool name_only)
+ bool name_only,
+ bool is_get_inst)
{
CMPIInstance *inst;
CMPIStatus s;
- s = get_migration_caps(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_caps(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;
}
@@ -132,7 +157,7 @@ static CMPIStatus EnumInstanceNames(CMPI
const CMPIResult *results,
const CMPIObjectPath *ref)
{
- return return_vsmc(ref, results, true);
+ return return_vsmc(ref, results, true, false);
}
static CMPIStatus EnumInstances(CMPIInstanceMI *self,
@@ -142,7 +167,7 @@ static CMPIStatus EnumInstances(CMPIInst
const char **properties)
{
- return return_vsmc(ref, results, false);
+ return return_vsmc(ref, results, false, false);
}
@@ -152,24 +177,7 @@ static CMPIStatus GetInstance(CMPIInstan
const CMPIObjectPath *ref,
const char **properties)
{
- CMPIInstance *inst;
- CMPIStatus s;
- const char *prop;
-
- s = get_migration_caps(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_vsmc(ref, results, false, true);
}
DEFAULT_CI();
diff -r fe50fd4e9cfa -r f074335959a5 src/Virt_VSMigrationCapabilities.h
--- a/src/Virt_VSMigrationCapabilities.h Fri Feb 15 16:57:58 2008 -0800
+++ b/src/Virt_VSMigrationCapabilities.h Fri Feb 15 16:58:37 2008 -0800
@@ -21,7 +21,8 @@
CMPIStatus get_migration_caps(const CMPIObjectPath *reference,
CMPIInstance **_inst,
- const CMPIBroker *broker);
+ const CMPIBroker *broker,
+ bool is_get_inst);
/*
* Local Variables: