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

libvirt also allows extra parameters for some of these transport types, but this just providers the basic support.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836824 28800 # Node ID 1e01f52781b5499949f498553b453f23af8feec2 # Parent 0a71dab025defa9d32488753ead9c47a582134df 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 0a71dab025de -r 1e01f52781b5 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Thu Mar 06 09:59:23 2008 +0800 +++ b/src/Virt_VSMigrationService.c Thu Mar 06 12:53:44 2008 -0800 @@ -674,11 +674,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; @@ -691,7 +749,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); @@ -705,7 +762,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) { @@ -715,13 +772,17 @@ static CMPIStatus migrate_do(const CMPIO CMPI_THREAD_TYPE thread; uint32_t retcode = 1; - 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); @@ -737,36 +798,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; } @@ -782,7 +813,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); @@ -803,13 +833,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, @@ -824,7 +848,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); @@ -853,13 +876,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 eb68bdbdf6ea6b596ceefd72a5547dfa65b27225 # Parent 1e01f52781b5499949f498553b453f23af8feec2 Extend the VirtualSystemMigrationSettingData to include an attribute for transport method. Possible transport methods are those supported by libvirt: ssh, tls, unix sockets, and tcp. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1e01f52781b5 -r eb68bdbdf6ea schema/VSMigrationSettingData.mof --- a/schema/VSMigrationSettingData.mof Thu Mar 06 12:53:44 2008 -0800 +++ b/schema/VSMigrationSettingData.mof Thu Mar 06 12:52:19 2008 -0800 @@ -8,8 +8,34 @@ class CIM_VirtualSystemMigrationSettingD [Provider("cmpi::Virt_VSMigrationSettingData")] class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { + [ Description( + "TransportType describes a type of transport used during the migration " + "operation.\n" + "A value of 2 - Virtual System is to be migrated using SSH.\n" + "A value of 3 - Virtual System is to be migrated using TLS.\n" + "A value of 4 - Virtual System is to be migrated using TLS with strict" + "verifcation of the remote certificates.\n" + "A value of 5 - Virtual System is to be migrated using TCP.\n" + "A value of 6 - Virtual System is to be migrated using UNIX sockets" + "(localhost only).\n"), + 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( + "TransportType describes a type of transport used during the migration " + "operation.\n" + "A value of 2 - Virtual System is to be migrated using SSH.\n" + "A value of 3 - Virtual System is to be migrated using TLS.\n" + "A value of 4 - Virtual System is to be migrated using TLS with strict" + "verifcation of the remote certificates.\n" + "A value of 5 - Virtual System is to be migrated using TCP.\n" + "A value of 6 - Virtual System is to be migrated using UNIX sockets" + "(localhost only).\n"), + ValueMap {"0","1","2","3","4","5","6"}, + Values { "Unknown", "Other", "SSH", "TLS", "TLS Strict", "TCP", "UNIX" }] + uint16 TransportType; };

Kaitlin Rupert wrote:
# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836739 28800 # Node ID eb68bdbdf6ea6b596ceefd72a5547dfa65b27225 # Parent 1e01f52781b5499949f498553b453f23af8feec2 Extend the VirtualSystemMigrationSettingData to include an attribute for transport method.
Possible transport methods are those supported by libvirt: ssh, tls, unix sockets, and tcp.
Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com>
diff -r 1e01f52781b5 -r eb68bdbdf6ea schema/VSMigrationSettingData.mof --- a/schema/VSMigrationSettingData.mof Thu Mar 06 12:53:44 2008 -0800 +++ b/schema/VSMigrationSettingData.mof Thu Mar 06 12:52:19 2008 -0800 @@ -8,8 +8,34 @@ class CIM_VirtualSystemMigrationSettingD
[Provider("cmpi::Virt_VSMigrationSettingData")] class Xen_VirtualSystemMigrationSettingData : CIM_VirtualSystemMigrationSettingData { + [ Description( + "TransportType describes a type of transport used during the migration " + "operation.\n" + "A value of 2 - Virtual System is to be migrated using SSH.\n" + "A value of 3 - Virtual System is to be migrated using TLS.\n" + "A value of 4 - Virtual System is to be migrated using TLS with strict" + "verifcation of the remote certificates.\n" + "A value of 5 - Virtual System is to be migrated using TCP.\n" + "A value of 6 - Virtual System is to be migrated using UNIX sockets" + "(localhost only).\n"), + 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( + "TransportType describes a type of transport used during the migration " + "operation.\n" + "A value of 2 - Virtual System is to be migrated using SSH.\n" + "A value of 3 - Virtual System is to be migrated using TLS.\n" + "A value of 4 - Virtual System is to be migrated using TLS with strict" + "verifcation of the remote certificates.\n" + "A value of 5 - Virtual System is to be migrated using TCP.\n" + "A value of 6 - Virtual System is to be migrated using UNIX sockets" + "(localhost only).\n"), + ValueMap {"0","1","2","3","4","5","6"}, + Values { "Unknown", "Other", "SSH", "TLS", "TLS Strict", "TCP", "UNIX" }] + uint16 TransportType; };
I guess it speaks well for the quality of the set that I have to resort to picking on string literals in a mof file, but IMHO the description is a bit on the verbose side. I'm all for people actually giving descriptions, but really it doesn't seem like the per-value description offers any information that's not already pretty explicit in ValueMap/Values pair. Thoughts, anybody? -- -Jay

JG> I guess it speaks well for the quality of the set that I have to JG> resort to picking on string literals in a mof file, but IMHO the JG> description is a bit on the verbose side. I'm all for people JG> actually giving descriptions, but really it doesn't seem like the JG> per-value description offers any information that's not already JG> pretty explicit in ValueMap/Values pair. Thoughts, anybody? Agreed. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204836759 28800 # Node ID 5419b7f856beb54c2f39a50f989a5faf702d4bef # Parent eb68bdbdf6ea6b596ceefd72a5547dfa65b27225 Specify default TransportType in VSMigrationSettingData instance. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r eb68bdbdf6ea -r 5419b7f856be 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 eb68bdbdf6ea -r 5419b7f856be 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_UNIX = 5, + CIM_MIGRATE_URI_TCP = 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 363b5dd996619f5a84928fad42b88b263690b3b2 # Parent 5419b7f856beb54c2f39a50f989a5faf702d4bef Add URI support to VSMigrationService. Signed-off-by: Kaitlin Rupert <karupert@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;

KR> + if (transport == CIM_MIGRATE_URI_TLS_STRICT) KR> + rc = asprintf(&uri, "%s://%s/system/?no_verify=1", tport, dest); KR> + else KR> + rc = asprintf(&uri, "%s://%s/system/", tport, dest); KR> + KR> + if (rc == -1) KR> uri = NULL; KR> + KR> + free(tport); This seems a tad ugly, since it's just a special case for one of the transport types. Can we change the function to just construct a whole URI for us, and pass in the class and the destination host? KR> @@ -147,7 +186,7 @@ static CMPIStatus vs_migratable(const CM KR> uint32_t retcode = 1; KR> CMPIBoolean isMigratable = 0; KR> - uri = dest_uri(CLASSNAME(ref), destination); KR> + uri = dest_uri(CLASSNAME(ref), destination, CIM_MIGRATE_URI_SSH); Is this hardcoding the check function to SSH? Otherwise I'm really happy with this set, thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> + if (transport == CIM_MIGRATE_URI_TLS_STRICT) KR> + rc = asprintf(&uri, "%s://%s/system/?no_verify=1", tport, dest); KR> + else KR> + rc = asprintf(&uri, "%s://%s/system/", tport, dest); KR> + KR> + if (rc == -1) KR> uri = NULL; KR> + KR> + free(tport);
This seems a tad ugly, since it's just a special case for one of the transport types. Can we change the function to just construct a whole URI for us, and pass in the class and the destination host?
Yeah, that'll be a lot cleaner. It might make the function a little long, but definitely cleaner.
KR> @@ -147,7 +186,7 @@ static CMPIStatus vs_migratable(const CM KR> uint32_t retcode = 1; KR> CMPIBoolean isMigratable = 0;
KR> - uri = dest_uri(CLASSNAME(ref), destination); KR> + uri = dest_uri(CLASSNAME(ref), destination, CIM_MIGRATE_URI_SSH);
Is this hardcoding the check function to SSH?
Ah, I meant to note this it the commit log. Yes, currently because I haven't added the MSD support to the vs_migratable() call (the migrate_do() equivalent for the Check() functions). This will be changed in a future patch. I'll grab the transport from the MSD and use that. Or, I can just add the MSD support for the Check() calls to this patchset. I don't mind either way. =)
Otherwise I'm really happy with this set, thanks!
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

KR> This will be changed in a future patch. I'll grab the transport KR> from the MSD and use that. KR> Or, I can just add the MSD support for the Check() calls to this KR> patchset. I don't mind either way. =) Ah, okay, that's fine. Just wanted to point it out if it was an oversight. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Kaitlin Rupert wrote:
libvirt also allows extra parameters for some of these transport types, but this just providers the basic support.
I've tested this with ssh, tcp, and unix. Still trying to get the certs set up to test tls and tls_strict. I suspect this will need iterations though. ;) -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Jay Gagnon
-
Kaitlin Rupert