[PATCH 0 of 4] #2 Add transport support to VSMigrationService.

libvirt also allows extra parameters for some of these transport types, but this just providers the basic support. Updates from set 1 to set 2: -See patch Extend the VirtualSystemMigrationSettingData to include an attribute for transport method) -See patch Add URI support to VSMigrationService

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204924923 28800 # Node ID 90115cb35a1a59c1aaa0a20caf75603ee3f25984 # Parent 1ca5240e2d3b659e70598f98fbb62191b0e04677 Reorganize VSMigrationService to prepare for URI support. Since both MigrateVirtualSystemToHost() and MigrateVirtualSystemToSystem() both need to get the values from MSD in the same way, might as well put the MSD calls in migrate_do (since both call this function). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1ca5240e2d3b -r 90115cb35a1a src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Fri Mar 07 16:18:08 2008 -0500 +++ b/src/Virt_VSMigrationService.c Fri Mar 07 13:22:03 2008 -0800 @@ -752,11 +752,69 @@ 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_msd_values(const CMPIObjectPath *ref, + const CMPIArgs *argsin, + struct migration_job *job) +{ + CMPIStatus s; + CMPIInstance *msd; + + s = get_msd(ref, argsin, &msd); + if (s.rc != CMPI_RC_OK) + goto out; + + s = get_migration_type(msd, &job->type); + if (s.rc != CMPI_RC_OK) + goto out; + + out: + return s; +} + static struct migration_job *migrate_job_prepare(const CMPIContext *context, const CMPIObjectPath *ref, const char *domain, - const char *host, - uint16_t type) + const char *host) { struct migration_job *job; uuid_t uuid; @@ -769,7 +827,6 @@ static struct migration_job *migrate_job job->host = strdup(host); job->ref_cn = strdup(CLASSNAME(ref)); job->ref_ns = strdup(NAMESPACE(ref)); - job->type = type; uuid_generate(uuid); uuid_unparse(uuid, job->uuid); @@ -783,7 +840,7 @@ static CMPIStatus migrate_do(const CMPIO const CMPIContext *context, const char *domain, const char *host, - uint16_t type, + const CMPIArgs *argsin, const CMPIResult *results, CMPIArgs *argsout) { @@ -796,13 +853,17 @@ static CMPIStatus migrate_do(const CMPIO CMPIInstance *inst = NULL; bool rc; - job = migrate_job_prepare(context, ref, domain, host, type); + job = migrate_job_prepare(context, ref, domain, host); if (job == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unable to prepare migration job"); goto out; } + + s = get_msd_values(ref, argsin, job); + if (s.rc != CMPI_RC_OK) + goto out; CU_DEBUG("Prepared migration job %s", job->uuid); @@ -830,36 +891,6 @@ static CMPIStatus migrate_do(const CMPIO out: CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32); - - return s; -} - -static CMPIStatus get_migration_type(const CMPIObjectPath *ref, - const CMPIArgs *argsin, - uint16_t *type) -{ - CMPIStatus s = {CMPI_RC_OK, NULL}; - CMPIInstance *msd; - int ret; - - ret = cu_get_inst_arg(argsin, "MigrationSettingData", &msd); - if ((ret != CMPI_RC_OK) || (msd == NULL)) { - CU_DEBUG("Using default values for MigrationSettingData param"); - 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"); - return s; - } - } - - ret = cu_get_u16_prop(msd, "MigrationType", type); - if (ret != CMPI_RC_OK) { - cu_statusf(_BROKER, &s, - ret, - "Invalid MigrationType value"); - } return s; } @@ -875,7 +906,6 @@ static CMPIStatus migrate_vs_host(CMPIMe const char *dhost = NULL; CMPIObjectPath *system; const char *name = NULL; - uint16_t type; cu_get_str_arg(argsin, "DestinationHost", &dhost); cu_get_ref_arg(argsin, "ComputerSystem", &system); @@ -896,13 +926,7 @@ static CMPIStatus migrate_vs_host(CMPIMe return s; } - s = get_migration_type(ref, argsin, &type); - if (s.rc != CMPI_RC_OK) { - METHOD_RETURN(results, 1); - return s; - } - - return migrate_do(ref, ctx, name, dhost, type, results, argsout); + return migrate_do(ref, ctx, name, dhost, argsin, results, argsout); } static CMPIStatus migrate_vs_system(CMPIMethodMI *self, @@ -917,7 +941,6 @@ static CMPIStatus migrate_vs_system(CMPI CMPIObjectPath *sys; const char *dname; const char *name; - uint16_t type; cu_get_ref_arg(argsin, "DestinationSystem", &dsys); cu_get_ref_arg(argsin, "ComputerSystem", &sys); @@ -946,13 +969,7 @@ static CMPIStatus migrate_vs_system(CMPI return s; } - s = get_migration_type(ref, argsin, &type); - if (s.rc != CMPI_RC_OK) { - METHOD_RETURN(results, 1); - return s; - } - - return migrate_do(ref, ctx, name, dname, type, results, argsout); + return migrate_do(ref, ctx, name, dname, argsin, results, argsout); } static struct method_handler vsimth = {

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836739 28800 # Node ID f0ec7a80ad470f7232b675c6e0c72adcfb4445f3 # Parent 90115cb35a1a59c1aaa0a20caf75603ee3f25984 Extend the VirtualSystemMigrationSettingData to include an attribute for transport method. Possible transport methods are those supported by libvirt: ssh, tls, unix sockets, and tcp. Updates from set 1 to set 2: -Remove verbose description. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 90115cb35a1a -r f0ec7a80ad47 schema/VSMigrationSettingData.mof --- a/schema/VSMigrationSettingData.mof Fri Mar 07 13:22:03 2008 -0800 +++ b/schema/VSMigrationSettingData.mof Thu Mar 06 12:52:19 2008 -0800 @@ -8,8 +8,16 @@ class CIM_VirtualSystemMigrationSettingD [Provider("cmpi::Virt_VSMigrationSettingData")] class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { + [ Description( + ValueMap {"0","1","2","3","4","5","6"}, + Values { "Unknown", "Other", "SSH", "TLS", "TLS Strict", "TCP", "UNIX" }] + uint16 TransportType; }; [Provider("cmpi::Virt_VSMigrationSettingData")] class KVM_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { + [ Description( + ValueMap {"0","1","2","3","4","5","6"}, + Values { "Unknown", "Other", "SSH", "TLS", "TLS Strict", "TCP", "UNIX" }] + uint16 TransportType; };

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836759 28800 # Node ID d7d6fb7facb7d6ca113cb1a43a225f1f12754713 # Parent f0ec7a80ad470f7232b675c6e0c72adcfb4445f3 Specify default TransportType in VSMigrationSettingData instance. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r f0ec7a80ad47 -r d7d6fb7facb7 src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Thu Mar 06 12:52:19 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Thu Mar 06 12:52:39 2008 -0800 @@ -40,6 +40,7 @@ static CMPIStatus set_properties(const C CMPIStatus s; uint16_t type = CIM_MIGRATE_LIVE; uint16_t priority = 0; /* Use default priority */ + uint16_t transport = CIM_MIGRATE_URI_SSH; CMSetProperty(inst, "MigrationType", (CMPIValue *)&type, CMPI_uint16); @@ -47,6 +48,8 @@ static CMPIStatus set_properties(const C CMSetProperty(inst, "Priority", (CMPIValue *)&priority, CMPI_uint16); + CMSetProperty(inst, "TransportType", + (CMPIValue *)&transport, CMPI_uint16); cu_statusf(broker, &s, CMPI_RC_OK, diff -r f0ec7a80ad47 -r d7d6fb7facb7 src/Virt_VSMigrationSettingData.h --- a/src/Virt_VSMigrationSettingData.h Thu Mar 06 12:52:19 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.h Thu Mar 06 12:52:39 2008 -0800 @@ -25,6 +25,14 @@ enum {CIM_MIGRATE_OTHER = 1, CIM_MIGRATE_RESTART = 4, } migration_type; +enum {CIM_MIGRATE_URI_OTHER = 1, + CIM_MIGRATE_URI_SSH = 2, + CIM_MIGRATE_URI_TLS = 3, + CIM_MIGRATE_URI_TLS_STRICT = 4, + CIM_MIGRATE_URI_TCP = 5, + CIM_MIGRATE_URI_UNIX = 6, +} transport_type; + CMPIStatus get_migration_sd(const CMPIObjectPath *ref, CMPIInstance **_inst, const CMPIBroker *broker,

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836870 28800 # Node ID ad69029c321f91f17469d0ff97e2a39d3806349e # Parent d7d6fb7facb7d6ca113cb1a43a225f1f12754713 Add URI support to VSMigrationService. For the vs_migratable() call, the destination uri is hardcoded to SSH. This will call will be updated in a later patch so that it pulls the proper transport value from teh MSD. Update from set 1 to set 2: -Consolidate dest_uri() and transport_from_class() -Fix missing dereference for the uri variable in get_migration_uri(). Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r d7d6fb7facb7 -r ad69029c321f 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 @@ -64,34 +64,53 @@ 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 *dest_uri(const char *cn, + const char *dest, + uint16_t transport) +{ + const char *prefix; + const char *tport = NULL; + const char *param = ""; + char *uri = NULL; + int rc; + if (STARTS_WITH(cn, "Xen")) - return "xen+ssh"; + prefix = "xen"; else if (STARTS_WITH(cn, "KVM")) - return "qemu+ssh"; + prefix = "qemu"; else return NULL; -} - -static char *dest_uri(const char *cn, - const char *dest) -{ - char *uri; - const char *tport = NULL; - - tport = transport_from_class(cn); - if (tport == NULL) { - CU_DEBUG("Failed to get transport for %s", cn); - return NULL; - } - - if (asprintf(&uri, "%s://%s/system", tport, dest) == -1) + + switch (transport) { + case CIM_MIGRATE_URI_SSH: + tport = "ssh"; + break; + case CIM_MIGRATE_URI_TLS: + tport = "tls"; + param = "?no_verify=1"; + break; + 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; + } + + rc = asprintf(&uri, "%s+%s://%s/system/%s", prefix, tport, dest, param); + if (rc == -1) uri = NULL; + out: return uri; } @@ -153,7 +172,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, @@ -557,7 +576,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, @@ -792,6 +811,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) @@ -804,6 +840,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;
participants (1)
-
Kaitlin Rupert