[PATCH 0 of 4] Update VSMigrationService to support static and offline migration

This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method.

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1202498491 28800 # Node ID 89cff8c40cafbce33b90a55e991721b8302714c2 # Parent 1aef50fa67a9ba1a3687afe03e3b1bf455d57685 Make get_migration_sd() of VSMigrationSettingData.c non-staitc. VSMigrationService will need to call this function to get the default VSMigrationSettingData instance. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 1aef50fa67a9 -r 89cff8c40caf src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Mon Feb 25 09:09:02 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Fri Feb 08 11:21:31 2008 -0800 @@ -30,6 +30,7 @@ #include <libcmpiutil/std_instance.h> #include "misc_util.h" +#include "Virt_VSMigrationSettingData.h" const static CMPIBroker *_BROKER; @@ -54,10 +55,10 @@ static CMPIStatus set_properties(const C return s; } -static CMPIStatus get_migration_sd(const CMPIObjectPath *ref, - CMPIInstance **_inst, - const CMPIBroker *broker, - bool is_get_inst) +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst) { CMPIInstance *inst; CMPIStatus s = {CMPI_RC_OK, NULL}; diff -r 1aef50fa67a9 -r 89cff8c40caf src/Virt_VSMigrationSettingData.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationSettingData.h Fri Feb 08 11:21:31 2008 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Kaitlin Rupert <karupert@us.ibm.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +CMPIStatus get_migration_sd(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker, + bool is_get_inst); +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ +

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1203986184 28800 # Node ID c089d134bfb70e3ab48d06ea4b7d229be1341646 # Parent 89cff8c40cafbce33b90a55e991721b8302714c2 Add migration types to VSMigrationSettingData.h These values specify the migration types CIM supports. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 89cff8c40caf -r c089d134bfb7 src/Virt_VSMigrationSettingData.c --- a/src/Virt_VSMigrationSettingData.c Fri Feb 08 11:21:31 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.c Mon Feb 25 16:36:24 2008 -0800 @@ -38,7 +38,7 @@ static CMPIStatus set_properties(const C CMPIInstance *inst) { CMPIStatus s; - uint16_t type = 3; /* Use live migration as default */ + uint16_t type = CIM_MIGRATE_LIVE; uint16_t priority = 0; /* Use default priority */ CMSetProperty(inst, "MigrationType", diff -r 89cff8c40caf -r c089d134bfb7 src/Virt_VSMigrationSettingData.h --- a/src/Virt_VSMigrationSettingData.h Fri Feb 08 11:21:31 2008 -0800 +++ b/src/Virt_VSMigrationSettingData.h Mon Feb 25 16:36:24 2008 -0800 @@ -19,6 +19,12 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +enum {CIM_MIGRATE_OTHER = 1, + CIM_MIGRATE_LIVE = 2, + CIM_MIGRATE_RESUME = 3, + CIM_MIGRATE_RESTART = 4, +} migration_type; + CMPIStatus get_migration_sd(const CMPIObjectPath *ref, CMPIInstance **_inst, const CMPIBroker *broker,

Kaitlin Rupert wrote:
- uint16_t type = 3; /* Use live migration as default */ + uint16_t type = CIM_MIGRATE_LIVE; ... +enum {CIM_MIGRATE_OTHER = 1, + CIM_MIGRATE_LIVE = 2, + CIM_MIGRATE_RESUME = 3, + CIM_MIGRATE_RESTART = 4, +} migration_type; +
What is now correct ? MIGRATE_LIVE 2 or 3 ? -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Heidi Eckhart wrote:
Kaitlin Rupert wrote:
- uint16_t type = 3; /* Use live migration as default */ + uint16_t type = CIM_MIGRATE_LIVE; ... +enum {CIM_MIGRATE_OTHER = 1, + CIM_MIGRATE_LIVE = 2, + CIM_MIGRATE_RESUME = 3, + CIM_MIGRATE_RESTART = 4, +} migration_type; +
What is now correct ? MIGRATE_LIVE 2 or 3 ?
I had a mistake earlier on, MIGRATE_LIVE is 2. Here's the relevant part from the mof: ValueMap {"0","1","2","3","4"}, Values { "Unknown", "Other", "Live", "Resume", "Restart" }] uint16 MigrationType; -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Heidi Eckhart wrote:
What is now correct ? MIGRATE_LIVE 2 or 3 ?
I had a mistake earlier on, MIGRATE_LIVE is 2. Here's the relevant part from the mof:
ValueMap {"0","1","2","3","4"}, Values { "Unknown", "Other", "Live", "Resume", "Restart" }] uint16 MigrationType;
Ok, thanks :) -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1203986185 28800 # Node ID 09153317203d6a60ede32daf5f2ce5765b6d9953 # Parent c089d134bfb70e3ab48d06ea4b7d229be1341646 Add MigrationType support to VirtualSystemMigrationService. This patch only handles the live and static migration cases. Other migration cases to follow. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r c089d134bfb7 -r 09153317203d src/Makefile.am --- a/src/Makefile.am Mon Feb 25 16:36:24 2008 -0800 +++ b/src/Makefile.am Mon Feb 25 16:36:25 2008 -0800 @@ -155,9 +155,9 @@ libVirt_ElementSettingData_la_LIBADD = - libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c -libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la +libVirt_VSMigrationService_la_DEPENDENCIES = libVirt_HostSystem.la libVirt_VSMigrationSettingData.la libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c -libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem +libVirt_VSMigrationService_la_LIBADD = -lVirt_HostSystem -lVirt_VSMigrationSettingData libVirt_VSMigrationSettingData_la_SOURCES = Virt_VSMigrationSettingData.c diff -r c089d134bfb7 -r 09153317203d src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Feb 25 16:36:24 2008 -0800 +++ b/src/Virt_VSMigrationService.c Mon Feb 25 16:36:25 2008 -0800 @@ -38,6 +38,7 @@ #include "Virt_VSMigrationService.h" #include "Virt_HostSystem.h" +#include "Virt_VSMigrationSettingData.h" #define CIM_JOBSTATE_STARTING 3 #define CIM_JOBSTATE_RUNNING 4 @@ -56,6 +57,7 @@ struct migration_job { char *host; char *ref_cn; char *ref_ns; + uint16_t type; char uuid[33]; }; @@ -385,13 +387,35 @@ static void migrate_job_set_state(struct CU_DEBUG("Failed to raise indication"); } +static CMPIStatus handle_migrate(virConnectPtr dconn, + virDomainPtr dom, + char *uri, + int type, + struct migration_job *job) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainPtr ddom = NULL; + + CU_DEBUG("Migrating %s -> %s", job->domain, uri); + ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0); + if (ddom == NULL) { + CU_DEBUG("Migration failed"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Migration Failed"); + } + + virDomainFree(ddom); + + return s; +} + static CMPIStatus migrate_vs(struct migration_job *job) { CMPIStatus s; virConnectPtr conn = NULL; virConnectPtr dconn = NULL; virDomainPtr dom = NULL; - virDomainPtr ddom = NULL; char *uri = NULL; uri = dest_uri(job->ref_cn, job->host); @@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr goto out; } - CU_DEBUG("Migrating %s -> %s", job->domain, uri); - - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); - if (ddom == NULL) { - CU_DEBUG("Migration failed"); - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Migration Failed"); - goto out; - } + switch(job->type) { + case CIM_MIGRATE_OTHER: + /* FIXME - Handle offline migration here */ + CU_DEBUG("Preparing for offline migration"); + break; + case CIM_MIGRATE_LIVE: + CU_DEBUG("Preparing for live migration"); + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, job); + break; + case CIM_MIGRATE_RESUME: + case CIM_MIGRATE_RESTART: + CU_DEBUG("Preparing for static migration"); + s = handle_migrate(dconn, dom, uri, 0, job); + break; + default: + CU_DEBUG("Unsupported migration type (%d)", job->type); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unsupported migration type (%d)", job->type); + goto out; + } + + if (s.rc != CMPI_RC_OK) + goto out; CU_DEBUG("Migration succeeded"); cu_statusf(_BROKER, &s, CMPI_RC_OK, ""); + out: free(uri); virDomainFree(dom); - virDomainFree(ddom); virConnectClose(conn); virConnectClose(dconn); @@ -568,7 +606,8 @@ static struct migration_job *migrate_job static struct migration_job *migrate_job_prepare(const CMPIContext *context, const CMPIObjectPath *ref, const char *domain, - const char *host) + const char *host, + uint16_t type) { struct migration_job *job; uuid_t uuid; @@ -581,6 +620,7 @@ 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); @@ -594,6 +634,7 @@ static CMPIStatus migrate_do(const CMPIO const CMPIContext *context, const char *domain, const char *host, + uint16_t type, const CMPIResult *results, CMPIArgs *argsout) { @@ -603,7 +644,7 @@ static CMPIStatus migrate_do(const CMPIO CMPI_THREAD_TYPE thread; uint32_t retcode = 1; - job = migrate_job_prepare(context, ref, domain, host); + job = migrate_job_prepare(context, ref, domain, host, type); if (job == NULL) { cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, @@ -625,6 +666,36 @@ 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; } @@ -640,7 +711,8 @@ 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); @@ -660,7 +732,13 @@ static CMPIStatus migrate_vs_host(CMPIMe return s; } - return migrate_do(ref, ctx, name, dhost, results, argsout); + 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); } static CMPIStatus migrate_vs_system(CMPIMethodMI *self, @@ -675,6 +753,7 @@ 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); @@ -703,7 +782,13 @@ static CMPIStatus migrate_vs_system(CMPI return s; } - return migrate_do(ref, ctx, name, dname, results, argsout); + 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); } static struct method_handler vsimth = { @@ -711,6 +796,7 @@ static struct method_handler vsimth = { .handler = vs_migratable_host, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationHost", CMPI_string, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -720,6 +806,7 @@ static struct method_handler vsimts = { .handler = vs_migratable_system, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationSystem", CMPI_ref, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -729,6 +816,7 @@ static struct method_handler mvsth = { .handler = migrate_vs_host, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationHost", CMPI_string, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } }; @@ -738,6 +826,7 @@ static struct method_handler mvsts = { .handler = migrate_vs_system, .args = {{"ComputerSystem", CMPI_ref, false}, {"DestinationSystem", CMPI_ref, false}, + {"MigrationSettingData", CMPI_instance, true}, ARG_END } };

Kaitlin Rupert wrote:
@@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr goto out; }
- CU_DEBUG("Migrating %s -> %s", job->domain, uri); - - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); - if (ddom == NULL) { - CU_DEBUG("Migration failed"); - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Migration Failed"); - goto out; - } + switch(job->type) { + case CIM_MIGRATE_OTHER: + /* FIXME - Handle offline migration here */ + CU_DEBUG("Preparing for offline migration"); + break; + case CIM_MIGRATE_LIVE: + CU_DEBUG("Preparing for live migration"); + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, job);
Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ?
+ break; + case CIM_MIGRATE_RESUME: + case CIM_MIGRATE_RESTART: + CU_DEBUG("Preparing for static migration"); + s = handle_migrate(dconn, dom, uri, 0, job);
The type should be CIM_MIGRATE_RESTART
+ break; + default: + CU_DEBUG("Unsupported migration type (%d)", job->type); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unsupported migration type (%d)", job->type); + goto out; + } + + if (s.rc != CMPI_RC_OK) + goto out;
-- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Heidi Eckhart wrote:
Kaitlin Rupert wrote:
@@ -424,25 +448,39 @@ static CMPIStatus migrate_vs(struct migr goto out; }
- CU_DEBUG("Migrating %s -> %s", job->domain, uri); - - ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); - if (ddom == NULL) { - CU_DEBUG("Migration failed"); - cu_statusf(_BROKER, &s, - CMPI_RC_ERR_FAILED, - "Migration Failed"); - goto out; - } + switch(job->type) { + case CIM_MIGRATE_OTHER: + /* FIXME - Handle offline migration here */ + CU_DEBUG("Preparing for offline migration"); + break; + case CIM_MIGRATE_LIVE: + CU_DEBUG("Preparing for live migration"); + s = handle_migrate(dconn, dom, uri, VIR_MIGRATE_LIVE, job);
Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ?
The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, which is 2. However, the value of VIR_MIGRATE_LIVE is defined by libvirt. So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we call virDomainMigrate().
+ break; + case CIM_MIGRATE_RESUME: + case CIM_MIGRATE_RESTART: + CU_DEBUG("Preparing for static migration"); + s = handle_migrate(dconn, dom, uri, 0, job);
The type should be CIM_MIGRATE_RESTART
For static migration, libvirt uses a value of 0. There's two type values here.. the value set for the MigrationType attribute of MigrationSettingData and the value libvirt uses to differentiate between static and live migration. But it looks like the way I have it coded is confusing. Would the following make more sense: static CMPIStatus handle_migrate(virConnectPtr dconn, virDomainPtr dom, char *uri, int type, struct migration_job *job) { CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr ddom = NULL; CU_DEBUG("Migrating %s -> %s", job->domain, uri); if (type == CIM_MIGRATE_LIVE) ddom = virDomainMigrate(dom, dconn, VIR_MIGRATE_LIVE, NULL, NULL, 0); else if (type == CIM_MIGRATE_RESUME) || (type == CIM_MIGRATE_RESTART) ddom = virDomainMigrate(dom, dconn, 0, NULL, NULL, 0); else //Print error here and return if (ddom == NULL) { CU_DEBUG("Migration failed"); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Migration Failed"); } virDomainFree(ddom); return s; } And then in migrate_vs() have: switch(job->type) { case CIM_MIGRATE_OTHER: /* FIXME - Handle offline migration here */ CU_DEBUG("Preparing for offline migration"); break; case CIM_MIGRATE_LIVE: case CIM_MIGRATE_RESUME: case CIM_MIGRATE_RESTART: s = handle_migrate(dconn, dom, uri, job->type, job); break; default: CU_DEBUG("Unsupported migration type (%d)", job->type); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Unsupported migration type (%d)", job->type); goto out; } It is a little more redundant this way, but it might help with readability.
+ break; + default: + CU_DEBUG("Unsupported migration type (%d)", job->type); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unsupported migration type (%d)", job->type); + goto out; + } + + if (s.rc != CMPI_RC_OK) + goto out;
-- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, which is 2. However, the value of VIR_MIGRATE_LIVE is defined by
Heidi Eckhart wrote: libvirt.
So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we call virDomainMigrate(). Thanks for this explanation.
For static migration, libvirt uses a value of 0. There's two type values here.. the value set for the MigrationType attribute of MigrationSettingData and the value libvirt uses to differentiate between static and live migration. ... It is a little more redundant this way, but it might help with readability.
Thank you for this very good explanation. This makes now much more sense to me :). But I think recoding as you suggested is not necessary, as it would bring too much redundancy (as you already said) into the code. Now that I understood it, I'm absolutely fine with it. Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 (instead of VIR_MIGRATE_STATIC or something else) as values, but that's something we seem to live with. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

HE> Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 HE> (instead of VIR_MIGRATE_STATIC or something else) as values, but HE> that's something we seem to live with. The reason for this is that it's not a "type" parameter, but a "flags" parameter. Static migration is considered the default, with Live being an option. You could potentially also have a flag like VIR_MIGRATE_SECURE, which would give you the following two combinations: VIR_MIGRATE_SECURE -- Static, secure migration VIR_MIGRATE_SECURE | VIR_MIGRATE_LIVE -- Live, secure migration Make sense? -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
HE> Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 HE> (instead of VIR_MIGRATE_STATIC or something else) as values, but HE> that's something we seem to live with.
The reason for this is that it's not a "type" parameter, but a "flags" parameter. Static migration is considered the default, with Live being an option. You could potentially also have a flag like VIR_MIGRATE_SECURE, which would give you the following two combinations:
VIR_MIGRATE_SECURE -- Static, secure migration VIR_MIGRATE_SECURE | VIR_MIGRATE_LIVE -- Live, secure migration
Make sense?
The code bit that caused the confusion is: static CMPIStatus handle_migrate(virConnectPtr dconn, virDomainPtr dom, char *uri, int type, struct migration_job *job) { CMPIStatus s = {CMPI_RC_OK, NULL}; virDomainPtr ddom = NULL; CU_DEBUG("Migrating %s -> %s", job->domain, uri); ddom = virDomainMigrate(dom, dconn, type, NULL, NULL, 0); if (ddom == NULL) { CU_DEBUG("Migration failed"); cu_statusf(_BROKER, &s, CMPI_RC_ERR_FAILED, "Migration Failed"); } virDomainFree(ddom); return s; } Would it be better to change the variable name from int type to int flag? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Heidi Eckhart wrote:
Kaitlin Rupert wrote:
Is the type CIM_MIGRATE_LIVE or VIR_MIGRATE_LIVE ? The CIM_MIGRATE_LIVE corresponds to the value defined in the mof, which is 2. However, the value of VIR_MIGRATE_LIVE is defined by
Heidi Eckhart wrote: libvirt.
So when someone specifies a migration type of 2 (CIM_MIGRATE_LIVE) in the MigrationSettingData, we'll need to use VIR_MIGRATE_LIVE when we call virDomainMigrate(). Thanks for this explanation.
For static migration, libvirt uses a value of 0. There's two type values here.. the value set for the MigrationType attribute of MigrationSettingData and the value libvirt uses to differentiate between static and live migration. ... It is a little more redundant this way, but it might help with readability.
Thank you for this very good explanation. This makes now much more sense to me :). But I think recoding as you suggested is not necessary, as it would bring too much redundancy (as you already said) into the code. Now that I understood it, I'm absolutely fine with it. Its not very consistent that libvirt uses VIR_MIGRATE_LIVE and 0 (instead of VIR_MIGRATE_STATIC or something else) as values, but that's something we seem to live with.
Yes, this confused me too as well. =) When I checked libvirt.h, I was surprised to see only one migration flag listed. I wonder if this will change in the future? -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

# HG changeset patch # User Kaitlin Rupert <karupert@us.ibm.com> # Date 1204070582 28800 # Node ID 4310ed87a132963947ad866eccca7d9697ef8fcf # Parent 09153317203d6a60ede32daf5f2ce5765b6d9953 Add offline migration support. Signed-off-by: Kaitlin Rupert <karupert@us.ibm.com> diff -r 09153317203d -r 4310ed87a132 src/Virt_VSMigrationService.c --- a/src/Virt_VSMigrationService.c Mon Feb 25 16:36:25 2008 -0800 +++ b/src/Virt_VSMigrationService.c Tue Feb 26 16:03:02 2008 -0800 @@ -410,6 +410,69 @@ static CMPIStatus handle_migrate(virConn return s; } +static CMPIStatus prepare_offline_migrate(virDomainPtr dom, + char **xml) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainInfo info; + int ret; + + ret = virDomainGetInfo(dom, &info); + if (ret != 0) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unabled to get info for domain."); + goto out; + } + + if ((const int)info.state != VIR_DOMAIN_SHUTOFF) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_INVALID_PARAMETER, + "Domain must be shutoff for offline migration."); + goto out; + } + + *xml = virDomainGetXMLDesc(dom, 0); + if (*xml == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Unable to retrieve domain XML."); + goto out; + } + + out: + return s; +} + +static CMPIStatus handle_offline_migrate(virConnectPtr dconn, + virDomainPtr dom, + char *uri, + char *xml, + struct migration_job *job) +{ + CMPIStatus s = {CMPI_RC_OK, NULL}; + virDomainPtr new_dom; + + if (domain_exists(dconn, job->domain)) { + CU_DEBUG("This domain already exists on the target system."); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "This domain already exists on the target system"); + goto out; + } + + new_dom = virDomainDefineXML(dconn, xml); + if (new_dom == NULL) { + CU_DEBUG("Failed to define domain from XML"); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to create domain"); + } + + out: + return s; +} + static CMPIStatus migrate_vs(struct migration_job *job) { CMPIStatus s; @@ -417,6 +480,7 @@ static CMPIStatus migrate_vs(struct migr virConnectPtr dconn = NULL; virDomainPtr dom = NULL; char *uri = NULL; + char *xml = NULL; uri = dest_uri(job->ref_cn, job->host); if (uri == NULL) { @@ -439,6 +503,12 @@ static CMPIStatus migrate_vs(struct migr goto out; } + if (job->type == CIM_MIGRATE_OTHER) { + s = prepare_offline_migrate(dom, &xml); + if (s.rc != CMPI_RC_OK) + goto out; + } + dconn = virConnectOpen(uri); if (dconn == NULL) { CU_DEBUG("Failed to connect to remote host (%s)", uri); @@ -450,8 +520,8 @@ static CMPIStatus migrate_vs(struct migr switch(job->type) { case CIM_MIGRATE_OTHER: - /* FIXME - Handle offline migration here */ CU_DEBUG("Preparing for offline migration"); + s = handle_offline_migrate(dconn, dom, uri, xml, job); break; case CIM_MIGRATE_LIVE: CU_DEBUG("Preparing for live migration"); @@ -480,6 +550,7 @@ static CMPIStatus migrate_vs(struct migr out: free(uri); + free(xml); virDomainFree(dom); virConnectClose(conn); virConnectClose(dconn);

Kaitlin Rupert wrote:
This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method.
FYI - I did not had any problems to apply and compile these patches. But haven't tested yet. -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Kaitlin Rupert wrote:
This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
I run into problems with KVM (output with sfcbd): std_invokemethod.c(303): Executing handler for method `CheckVirtualSystemIsMigratableToSystem' misc_util.c(70): Connecting to libvirt with uri `qemu:///system' ssh: kvm2-f8: Name or service not known libvir: Remote error : Connection reset by peer Virt_VSMigrationService.c(164): Failed to connect to remote host (qemu+ssh://kvm2-f8/system) std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' returned 1 Attached is the XML request submitted via wbemexec. Do you know what I'm doing wrong ? thanks -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Heidi Eckhart wrote:
Kaitlin Rupert wrote:
This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
I run into problems with KVM (output with sfcbd):
std_invokemethod.c(303): Executing handler for method `CheckVirtualSystemIsMigratableToSystem' misc_util.c(70): Connecting to libvirt with uri `qemu:///system' ssh: kvm2-f8: Name or service not known libvir: Remote error : Connection reset by peer Virt_VSMigrationService.c(164): Failed to connect to remote host (qemu+ssh://kvm2-f8/system) std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' returned 1
Attached is the XML request submitted via wbemexec. Do you know what I'm doing wrong ?
thanks
You'll want the DestinationSystem to be the reference of KVM_HostSystem on the target machine. So, something like: <PARAMVALUE NAME="DestinationSystem"> <VALUE.REFERENCE> <LOCALINSTANCEPATH> <LOCALNAMESPACEPATH> <NAMESPACE NAME="root"/> <NAMESPACE NAME="virt"/> </LOCALNAMESPACEPATH> <INSTANCENAME CLASSNAME="KVM_HostSystem"> <KEYBINDING NAME="CreationClassName"> <KEYVALUE VALUETYPE="string">KVM_HostSystem</KEYVALUE> </KEYBINDING> <KEYBINDING NAME="Name"> <KEYVALUE VALUETYPE="string">target_sys_hostname</KEYVALUE> </KEYBINDING> </INSTANCENAME> </LOCALINSTANCEPATH> </VALUE.REFERENCE> </PARAMVALUE> -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com

Kaitlin Rupert wrote:
You'll want the DestinationSystem to be the reference of KVM_HostSystem on the target machine.
So, something like:
<PARAMVALUE NAME="DestinationSystem"> <VALUE.REFERENCE> <LOCALINSTANCEPATH> <LOCALNAMESPACEPATH> <NAMESPACE NAME="root"/> <NAMESPACE NAME="virt"/> </LOCALNAMESPACEPATH> <INSTANCENAME CLASSNAME="KVM_HostSystem"> <KEYBINDING NAME="CreationClassName"> <KEYVALUE VALUETYPE="string">KVM_HostSystem</KEYVALUE> </KEYBINDING> <KEYBINDING NAME="Name"> <KEYVALUE VALUETYPE="string">target_sys_hostname</KEYVALUE> </KEYBINDING> </INSTANCENAME> </LOCALINSTANCEPATH> </VALUE.REFERENCE> </PARAMVALUE>
Thanks. I was able to send the request and got a valid result. Well, the migration failed - but I saw the provider working fine :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Kaitlin Rupert wrote:
You'll want the DestinationSystem to be the reference of KVM_HostSystem on the target machine.
So, something like:
<PARAMVALUE NAME="DestinationSystem"> <VALUE.REFERENCE> <LOCALINSTANCEPATH> <LOCALNAMESPACEPATH> <NAMESPACE NAME="root"/> <NAMESPACE NAME="virt"/> </LOCALNAMESPACEPATH> <INSTANCENAME CLASSNAME="KVM_HostSystem"> <KEYBINDING NAME="CreationClassName"> <KEYVALUE VALUETYPE="string">KVM_HostSystem</KEYVALUE> </KEYBINDING> <KEYBINDING NAME="Name"> <KEYVALUE VALUETYPE="string">target_sys_hostname</KEYVALUE> </KEYBINDING> </INSTANCENAME> </LOCALINSTANCEPATH> </VALUE.REFERENCE> </PARAMVALUE>
Thanks. I was able to send the request and got a valid result. Well, the migration failed - but I saw the provider working fine :). An excellent work :). -- Regards Heidi Eckhart Software Engineer IBM Linux Technology Center - Open Hypervisor

Heidi Eckhart wrote:
Kaitlin Rupert wrote:
This patchset updates VSMigrationService so that it reads the MigrationType attribute from MigrationSettingData and then launches the appropriate migration method.
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
I run into problems with KVM (output with sfcbd):
std_invokemethod.c(303): Executing handler for method `CheckVirtualSystemIsMigratableToSystem' misc_util.c(70): Connecting to libvirt with uri `qemu:///system' ssh: kvm2-f8: Name or service not known libvir: Remote error : Connection reset by peer Virt_VSMigrationService.c(164): Failed to connect to remote host (qemu+ssh://kvm2-f8/system) std_invokemethod.c(305): Method `CheckVirtualSystemIsMigratableToSystem' returned 1
Attached is the XML request submitted via wbemexec. Do you know what I'm doing wrong ?
thanks
I also meant to mention that in order to test MigrateVirtualSystemToHost() and MigrateVirtualSystemToSystem(), you'll need to have the "Add set_int_property() function to EO parse" patch applied. The current EO parser doesn't handle uint16 values, which CIM_VirtualSystemMigrationSettingData has. -- Kaitlin Rupert IBM Linux Technology Center kaitlin@linux.vnet.ibm.com
participants (3)
-
Dan Smith
-
Heidi Eckhart
-
Kaitlin Rupert