# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1205171774 25200
# Node ID 05cbd18bf3644b6e1b32b37c30310fb1b1e23a44
# Parent 1d2157cd04e4d46b50d9e6115e0927d8b0a33b8c
Make the migration check functions aware of MSD
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r 1d2157cd04e4 -r 05cbd18bf364 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Mon Mar 10 14:40:47 2008 +0100
+++ b/src/Virt_VSMigrationService.c Mon Mar 10 10:56:14 2008 -0700
@@ -68,6 +68,63 @@ struct migration_job {
char uuid[33];
};
+static CMPIStatus get_msd(const CMPIObjectPath *ref,
+ const CMPIArgs *argsin,
+ CMPIInstance **msd)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int ret;
+
+ ret = cu_get_inst_arg(argsin, "MigrationSettingData", msd);
+ if ((ret == CMPI_RC_OK) && (*msd != NULL))
+ goto out;
+
+ s = get_migration_sd(ref, msd, _BROKER, false);
+ if ((s.rc != CMPI_RC_OK) || (*msd == NULL)) {
+ cu_statusf(_BROKER, &s,
+ s.rc,
+ "Unable to get default setting data values");
+ goto out;
+ }
+ CU_DEBUG("Using default values for MigrationSettingData param");
+
+ out:
+ return s;
+}
+
+static CMPIStatus get_migration_type(CMPIInstance *msd,
+ uint16_t *type)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int ret;
+
+ ret = cu_get_u16_prop(msd, "MigrationType", type);
+ if (ret != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ ret,
+ "Invalid MigrationType value");
+ }
+
+ return s;
+}
+
+static CMPIStatus get_migration_uri(CMPIInstance *msd,
+ uint16_t *uri)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int ret;
+
+ ret = cu_get_u16_prop(msd, "TransportType", uri);
+ if (ret == CMPI_RC_OK)
+ goto out;
+
+ CU_DEBUG("Using default TransportType: %d", CIM_MIGRATE_URI_SSH);
+ *uri = CIM_MIGRATE_URI_SSH;
+
+ out:
+ return s;
+}
+
static char *dest_uri(const char *cn,
const char *dest,
uint16_t transport)
@@ -159,39 +216,67 @@ static CMPIStatus check_hver(virConnectP
return s;
}
+static CMPIStatus get_msd_check_values(const CMPIObjectPath *ref,
+ const char *destination,
+ const CMPIArgs *argsin,
+ virConnectPtr *conn)
+{
+ CMPIStatus s;
+ CMPIInstance *msd;
+ uint16_t uri_type;
+ char *uri = NULL;
+
+ s = get_msd(ref, argsin, &msd);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = get_migration_uri(msd, &uri_type);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ uri = dest_uri(CLASSNAME(ref), destination, uri_type);
+ if (uri == NULL) {
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to construct a valid libvirt URI");
+ goto out;
+ }
+
+ *conn = virConnectOpen(uri);
+ if (*conn == NULL) {
+ CU_DEBUG("Failed to connect to remote host (%s)", uri);
+ cu_statusf(_BROKER, &s,
+ CMPI_RC_ERR_FAILED,
+ "Failed to connect to remote host (%s)", uri);
+ goto out;
+ }
+
+ out:
+ free(uri);
+
+ return s;
+}
+
static CMPIStatus vs_migratable(const CMPIObjectPath *ref,
const char *domain,
const char *destination,
const CMPIResult *results,
+ const CMPIArgs *argsin,
CMPIArgs *argsout)
{
CMPIStatus s;
- char *uri = NULL;
virConnectPtr conn = NULL;
virConnectPtr dconn = NULL;
uint32_t retcode = 1;
CMPIBoolean isMigratable = 0;
- uri = dest_uri(CLASSNAME(ref), destination, CIM_MIGRATE_URI_SSH);
- if (uri == NULL) {
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to construct a valid libvirt URI");
- goto out;
- }
+ s = get_msd_check_values(ref, destination, argsin, &dconn);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s);
if (conn == NULL)
goto out;
-
- dconn = virConnectOpen(uri);
- if (dconn == NULL) {
- CU_DEBUG("Failed to connect to remote host (%s)", uri);
- cu_statusf(_BROKER, &s,
- CMPI_RC_ERR_FAILED,
- "Failed to connect to remote host (%s)", uri);
- goto out;
- }
s = check_hver(conn, dconn);
if (s.rc != CMPI_RC_OK)
@@ -212,7 +297,6 @@ static CMPIStatus vs_migratable(const CM
CMAddArg(argsout, "IsMigratable",
(CMPIValue *)&isMigratable, CMPI_boolean);
- free(uri);
virConnectClose(conn);
virConnectClose(dconn);
@@ -250,7 +334,7 @@ static CMPIStatus vs_migratable_host(CMP
return s;
}
- return vs_migratable(ref, name, dhost, results, argsout);
+ return vs_migratable(ref, name, dhost, results, argsin, argsout);
}
static CMPIStatus vs_migratable_system(CMPIMethodMI *self,
@@ -293,7 +377,7 @@ static CMPIStatus vs_migratable_system(C
return s;
}
- return vs_migratable(ref, name, dname, results, argsout);
+ return vs_migratable(ref, name, dname, results, argsin, argsout);
}
static const char *ind_type_to_name(int ind_type)
@@ -771,66 +855,9 @@ static CMPIStatus migrate_create_job_ins
return s;
}
-static CMPIStatus get_msd(const CMPIObjectPath *ref,
- const CMPIArgs *argsin,
- CMPIInstance **msd)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- int ret;
-
- ret = cu_get_inst_arg(argsin, "MigrationSettingData", msd);
- if ((ret == CMPI_RC_OK) && (*msd != NULL))
- goto out;
-
- s = get_migration_sd(ref, msd, _BROKER, false);
- if ((s.rc != CMPI_RC_OK) || (*msd == NULL)) {
- cu_statusf(_BROKER, &s,
- s.rc,
- "Unable to get default setting data values");
- goto out;
- }
- CU_DEBUG("Using default values for MigrationSettingData param");
-
- out:
- return s;
-}
-
-static CMPIStatus get_migration_type(CMPIInstance *msd,
- uint16_t *type)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- int ret;
-
- ret = cu_get_u16_prop(msd, "MigrationType", type);
- if (ret != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- ret,
- "Invalid MigrationType value");
- }
-
- return s;
-}
-
-static CMPIStatus get_migration_uri(CMPIInstance *msd,
- uint16_t *uri)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- int ret;
-
- ret = cu_get_u16_prop(msd, "TransportType", uri);
- if (ret == CMPI_RC_OK)
- goto out;
-
- CU_DEBUG("Using default TransportType: %d", CIM_MIGRATE_URI_SSH);
- *uri = CIM_MIGRATE_URI_SSH;
-
- out:
- return s;
-}
-
-static CMPIStatus get_msd_values(const CMPIObjectPath *ref,
- const CMPIArgs *argsin,
- struct migration_job *job)
+static CMPIStatus get_msd_job_values(const CMPIObjectPath *ref,
+ const CMPIArgs *argsin,
+ struct migration_job *job)
{
CMPIStatus s;
CMPIInstance *msd;
@@ -901,7 +928,7 @@ static CMPIStatus migrate_do(const CMPIO
goto out;
}
- s = get_msd_values(ref, argsin, job);
+ s = get_msd_job_values(ref, argsin, job);
if (s.rc != CMPI_RC_OK)
goto out;