# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1204836870 28800
# Node ID 363b5dd996619f5a84928fad42b88b263690b3b2
# Parent 5419b7f856beb54c2f39a50f989a5faf702d4bef
Add URI support to VSMigrationService.
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 5419b7f856be -r 363b5dd99661 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Thu Mar 06 12:52:39 2008 -0800
+++ b/src/Virt_VSMigrationService.c Thu Mar 06 12:54:30 2008 -0800
@@ -58,33 +58,72 @@ struct migration_job {
char *ref_cn;
char *ref_ns;
uint16_t type;
+ uint16_t transport;
char uuid[33];
};
-static const char *transport_from_class(const char *cn)
-{
+static char *transport_from_class(const char *cn,
+ uint16_t transport)
+{
+ const char *prefix;
+ const char *tport = NULL;
+ char *uri = NULL;
+
if (STARTS_WITH(cn, "Xen"))
- return "xen+ssh";
+ prefix = "xen";
else if (STARTS_WITH(cn, "KVM"))
- return "qemu+ssh";
+ prefix = "qemu";
else
return NULL;
+
+ switch (transport) {
+ case CIM_MIGRATE_URI_SSH:
+ tport = "ssh";
+ break;
+ case CIM_MIGRATE_URI_TLS:
+ case CIM_MIGRATE_URI_TLS_STRICT:
+ tport = "tls";
+ break;
+ case CIM_MIGRATE_URI_UNIX:
+ tport = "unix";
+ break;
+ case CIM_MIGRATE_URI_TCP:
+ tport = "tcp";
+ break;
+ default:
+ goto out;
+ }
+
+ if (asprintf(&uri, "%s+%s", prefix, tport) == -1)
+ uri = NULL;
+
+ out:
+ return uri;
}
static char *dest_uri(const char *cn,
- const char *dest)
+ const char *dest,
+ uint16_t transport)
{
char *uri;
- const char *tport = NULL;
-
- tport = transport_from_class(cn);
+ char *tport = NULL;
+ int rc;
+
+ tport = transport_from_class(cn, transport);
if (tport == NULL) {
CU_DEBUG("Failed to get transport for %s", cn);
return NULL;
}
- if (asprintf(&uri, "%s://%s/system", tport, dest) == -1)
+ if (transport == CIM_MIGRATE_URI_TLS_STRICT)
+ rc = asprintf(&uri, "%s://%s/system/?no_verify=1", tport,
dest);
+ else
+ rc = asprintf(&uri, "%s://%s/system/", tport, dest);
+
+ if (rc == -1)
uri = NULL;
+
+ free(tport);
return uri;
}
@@ -147,7 +186,7 @@ static CMPIStatus vs_migratable(const CM
uint32_t retcode = 1;
CMPIBoolean isMigratable = 0;
- uri = dest_uri(CLASSNAME(ref), destination);
+ uri = dest_uri(CLASSNAME(ref), destination, CIM_MIGRATE_URI_SSH);
if (uri == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -482,7 +521,7 @@ static CMPIStatus migrate_vs(struct migr
char *uri = NULL;
char *xml = NULL;
- uri = dest_uri(job->ref_cn, job->host);
+ uri = dest_uri(job->ref_cn, job->host, job->transport);
if (uri == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
@@ -714,6 +753,23 @@ static CMPIStatus get_migration_type(CMP
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)
@@ -726,6 +782,10 @@ static CMPIStatus get_msd_values(const C
goto out;
s = get_migration_type(msd, &job->type);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = get_migration_uri(msd, &job->transport);
if (s.rc != CMPI_RC_OK)
goto out;