[PATCH 0 of 6] Add migration support

This patch set adds preliminary migration support based on the current Virtual System Migration Profile. It's not quite done yet, but it does actually migrate VMs (tested with Xen). Still needing to be done are: - MigrationSettingData (perhaps to include ssh/TLS flag?) - Something for IsMigratable methods - Job support - Indication support

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID 143c73b947bd26659f5a8ef94e471a0a85e526f5 # Parent 7fd4f296b8cc328a7492a24c731d8722bc485452 Add VirtualSystemMigrationCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 7fd4f296b8cc -r 143c73b947bd src/Virt_VSMigrationCapabilities.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationCapabilities.c Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,175 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith <danms@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 + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include "libcmpiutil.h" +#include "misc_util.h" +#include "std_instance.h" + +#include "Virt_VSMigrationCapabilities.h" + +const static CMPIBroker *_BROKER; + +#define SVPC_MIG_MVSTH 2 +#define SVPC_MIG_MVSTS 3 +#define SVPC_MIG_CVSIMTH 4 +#define SVPC_MIG_CVSIMTS 5 + +static CMPIStatus set_method_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIArray *array; + CMPIStatus s; + uint16_t val; + + array = CMNewArray(broker, 4, CMPI_INTEGER, &s); + if (s.rc != CMPI_RC_OK) + return s; + + val = SVPC_MIG_MVSTH; + CMSetArrayElementAt(array, 0, (CMPIValue *)&val, CMPI_uint16); + + CMSetProperty(inst, "AsynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_ARRAY); + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +} + +CMPIStatus get_migration_caps(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker) +{ + CMPIInstance *inst; + CMPIStatus s; + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationCapabilities", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + return s; + } + + CMSetProperty(inst, "InstanceID", + (CMPIValue *)"MigrationCapabilities", CMPI_chars); + + s = set_method_properties(broker, inst); + + if (s.rc == CMPI_RC_OK) + *_inst = inst; + + return s; +} + +static CMPIStatus return_vsmc(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only) +{ + CMPIInstance *inst; + CMPIStatus s; + + s = get_migration_caps(ref, &inst, _BROKER); + + if (s.rc == CMPI_RC_OK) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsmc(ref, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + + return return_vsmc(ref, results, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + CMPIInstance *inst; + CMPIStatus s; + const char *prop; + + s = get_migration_caps(ref, &inst, _BROKER); + if (s.rc != CMPI_RC_OK) + return s; + + prop = cu_compare_ref(ref, inst); + if (prop != NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", prop); + } else { + CMReturnInstance(results, inst); + } + + return s; +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, Virt_VSMC, + _BROKER, + libvirt_cim_init()); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 7fd4f296b8cc -r 143c73b947bd src/Virt_VSMigrationCapabilities.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationCapabilities.h Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith <danms@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_caps(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ +

Dan Smith wrote:
# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID 143c73b947bd26659f5a8ef94e471a0a85e526f5 # Parent 7fd4f296b8cc328a7492a24c731d8722bc485452 Add VirtualSystemMigrationCapabilities
Signed-off-by: Dan Smith <danms@us.ibm.com>
+ +static CMPIStatus set_method_properties(const CMPIBroker *broker, + CMPIInstance *inst) +{ + CMPIArray *array; + CMPIStatus s; + uint16_t val; + + array = CMNewArray(broker, 4, CMPI_INTEGER, &s); + if (s.rc != CMPI_RC_OK) + return s; + + val = SVPC_MIG_MVSTH; + CMSetArrayElementAt(array, 0, (CMPIValue *)&val, CMPI_uint16); + + CMSetProperty(inst, "AsynchronousMethodsSupported", + (CMPIValue *)&array, CMPI_ARRAY); + + CMSetStatus(&s, CMPI_RC_OK); + + return s; +}
Just curious, why do you make an array of four elements but only put one item in it? Or am I just misunderstanding what's going on there? -- -Jay

JG> Just curious, why do you make an array of four elements but only JG> put one item in it? Or am I just misunderstanding what's going on JG> there? Heh, whoops. Initially, I added the "migrate to host" function in MigrationService and just added it as an async method in the capabilites. I need to go back and add the other three as well. However, two of them will be async and two will be sync, so I'll actually make this array 2-big and add another for the sync calls. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID 2e1935bc44ac74a96a210b0d6c1126e0f14081ef # Parent 143c73b947bd26659f5a8ef94e471a0a85e526f5 Add VirtualSystemMigrationCapabilties build support Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 143c73b947bd -r 2e1935bc44ac Makefile.am --- a/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/Makefile.am Mon Dec 03 11:55:44 2007 -0800 @@ -33,7 +33,8 @@ MOFS = \ schema/ResourceAllocationFromPool.mof \ schema/ElementAllocatedFromPool.mof \ schema/HostedService.mof \ - schema/ElementSettingData.mof + schema/ElementSettingData.mof \ + schema/VSMigrationCapabilities.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -72,7 +73,8 @@ REGS = \ schema/ResourceAllocationFromPool.registration \ schema/ElementAllocatedFromPool.registration \ schema/HostedService.registration \ - schema/ElementSettingData.registration + schema/ElementSettingData.registration \ + schema/VSMigrationCapabilities.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r 143c73b947bd -r 2e1935bc44ac schema/VSMigrationCapabilities.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationCapabilities.mof Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,17 @@ +// Copyright IBM Corp. 2007 + +class Virt_VirtualSystemMigrationCapabilities : CIM_Capabilities { + + uint16 DestinationHostFormatsSupported[]; + + uint16 SynchronousMethodsSupported[]; + + uint16 AsynchronousMethodsSupported[]; + +}; + +class Xen_VirtualSystemMigrationCapabilities : Virt_VirtualSystemMigrationCapabilities { +}; + +class KVM_VirtualSystemMigrationCapabilities : Virt_VirtualSystemMigrationCapabilities { +}; diff -r 143c73b947bd -r 2e1935bc44ac schema/VSMigrationCapabilities.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationCapabilities.registration Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationCapabilities root/virt Virt_VSMC Virt_VSMigrationCapabilities instance +KVM_VirtualSystemMigrationCapabilities root/virt Virt_VSMC Virt_VSMigrationCapabilities instance \ No newline at end of file diff -r 143c73b947bd -r 2e1935bc44ac src/Makefile.am --- a/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 @@ -50,7 +50,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ResourceAllocationFromPool.la \ libVirt_ElementAllocatedFromPool.la \ libVirt_HostedService.la \ - libVirt_ElementSettingData.la + libVirt_ElementSettingData.la \ + libVirt_VSMigrationCapabilities.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -138,3 +139,5 @@ libVirt_ElementSettingData_la_DEPENDENCI libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_RASD.la libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD -lVirt_RASD + +libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c \ No newline at end of file

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID 5ba311c0a725a603bb0e30349ad95d429a88f500 # Parent 2e1935bc44ac74a96a210b0d6c1126e0f14081ef Add VirtualSystemMigrationService Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 2e1935bc44ac -r 5ba311c0a725 src/Virt_VSMigrationService.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationService.c Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,369 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith <danms@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 + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#include <libvirt.h> + +#include <cmpidt.h> +#include <cmpift.h> +#include <cmpimacs.h> + +#include "libcmpiutil.h" +#include "misc_util.h" +#include "std_instance.h" +#include "std_invokemethod.h" + +#include "Virt_VSMigrationService.h" + +const static CMPIBroker *_BROKER; + +static CMPIStatus vs_migratable_host(CMPIMethodMI *self, + const CMPIContext *ctx, + const CMPIResult *results, + const CMPIObjectPath *ref, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + RETURN_UNSUPPORTED(); +} + +static CMPIStatus vs_migratable_system(CMPIMethodMI *self, + const CMPIContext *ctx, + const CMPIResult *results, + const CMPIObjectPath *ref, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + RETURN_UNSUPPORTED(); +} + +static const char *transport_from_ref(const CMPIObjectPath *ref) +{ + const char *cn; + + cn = CLASSNAME(ref); + + if (STARTS_WITH(cn, "Xen")) + return "xen+ssh"; + else if (STARTS_WITH(cn, "KVM")) + return "qemu+ssh"; + else + return NULL; +} + +static char *dest_uri(const CMPIObjectPath *ref, + const char *dest) +{ + char *uri; + const char *tport = NULL; + + tport = transport_from_ref(ref); + if (tport == NULL) { + CU_DEBUG("Failed to get transport for %s", CLASSNAME(ref)); + return NULL; + } + + if (asprintf(&uri, "%s://%s/", tport, dest) == -1) + uri = NULL; + + return uri; +} + +static CMPIStatus migrate_vs(const CMPIObjectPath *ref, + const char *domain, + const char *destination) +{ + CMPIStatus s; + virConnectPtr conn = NULL; + virConnectPtr dconn = NULL; + virDomainPtr dom = NULL; + virDomainPtr ddom = NULL; + char *uri = NULL; + + uri = dest_uri(ref, destination); + if (uri == NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to construct a valid libvirt URI"); + goto out; + } + + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + goto out; + + dom = virDomainLookupByName(conn, domain); + if (dom == NULL) { + CU_DEBUG("Failed to lookup `%s'", domain); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to lookup domain `%s'", domain); + goto out; + } + + dconn = 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; + } + + CMSetStatus(&s, CMPI_RC_OK); + CU_DEBUG("Migrating %s -> %s", 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; + } + + CU_DEBUG("Migration succeeded"); + CMSetStatus(&s, CMPI_RC_OK); + + out: + free(uri); + virDomainFree(dom); + virDomainFree(ddom); + virConnectClose(conn); + virConnectClose(dconn); + + return s; +} + +static CMPIStatus migrate_vs_host(CMPIMethodMI *self, + const CMPIContext *ctx, + const CMPIResult *results, + const CMPIObjectPath *ref, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s; + const char *dhost = NULL; + CMPIObjectPath *system; + const char *name = NULL; + + cu_get_str_arg(argsin, "DestinationHost", &dhost); + cu_get_ref_arg(argsin, "ComputerSystem", &system); + + if (cu_get_str_path(system, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing key (Name) in ComputerSystem"); + return s; + } + + return migrate_vs(ref, name, dhost); +} + +static CMPIStatus migrate_vs_system(CMPIMethodMI *self, + const CMPIContext *ctx, + const CMPIResult *results, + const CMPIObjectPath *ref, + const CMPIArgs *argsin, + CMPIArgs *argsout) +{ + CMPIStatus s; + CMPIObjectPath *dsys; + CMPIObjectPath *sys; + const char *dname; + const char *name; + + cu_get_ref_arg(argsin, "DestinationSystem", &dsys); + cu_get_ref_arg(argsin, "ComputerSystem", &sys); + + if (cu_get_str_path(dsys, "Name", &dname) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing key (Name) in DestinationSystem"); + return s; + } + + if (cu_get_str_path(sys, "Name", &name) != CMPI_RC_OK) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Missing key (Name) in ComputerSystem"); + return s; + } + + return migrate_vs(ref, name, dname); +} + +static struct method_handler vsimth = { + .name = "VirtualSystemIsMigratableToHost", + .handler = vs_migratable_host, + .args = {{"ComputerSystem", CMPI_ref}, + {"DestinationHost", CMPI_string}, + ARG_END + } +}; + +static struct method_handler vsimts = { + .name = "VirtualSystemIsMigratableToSystem", + .handler = vs_migratable_system, + .args = {{"ComputerSystem", CMPI_ref}, + {"DestinationSystem", CMPI_ref}, + ARG_END + } +}; + +static struct method_handler mvsth = { + .name = "MigrateVirtualSystemToHost", + .handler = migrate_vs_host, + .args = {{"ComputerSystem", CMPI_ref}, + {"DestinationHost", CMPI_string}, + ARG_END + } +}; + +static struct method_handler mvsts = { + .name = "MigrateVirtualSystemToSystem", + .handler = migrate_vs_system, + .args = {{"ComputerSystem", CMPI_ref}, + {"DestinationSystem", CMPI_ref}, + ARG_END + } +}; + +static struct method_handler *my_handlers[] = { + &vsimth, + &vsimts, + &mvsth, + &mvsts, + NULL +}; + +STDIM_MethodMIStub(, Virt_VSMigrationService, _BROKER, + libvirt_cim_init(), my_handlers); + +CMPIStatus get_migration_service(const CMPIObjectPath *ref, + CMPIInstance **_inst, + const CMPIBroker *broker) +{ + CMPIInstance *inst; + CMPIStatus s = {CMPI_RC_OK, NULL}; + + inst = get_typed_instance(broker, + CLASSNAME(ref), + "VirtualSystemMigrationService", + NAMESPACE(ref)); + if (inst == NULL) { + cu_statusf(broker, &s, + CMPI_RC_ERR_FAILED, + "Unable to get instance for %s", CLASSNAME(ref)); + return s; + } + + CMSetProperty(inst, "Name", + (CMPIValue *)"MigrationService", CMPI_chars); + + *_inst = inst; + + return s; +} + +static CMPIStatus return_vsms(const CMPIObjectPath *ref, + const CMPIResult *results, + bool name_only) +{ + CMPIInstance *inst; + CMPIStatus s; + + s = get_migration_service(ref, &inst, _BROKER); + if (s.rc == CMPI_RC_OK) { + if (name_only) + cu_return_instance_name(results, inst); + else + CMReturnInstance(results, inst); + } + + return s; +} + +static CMPIStatus EnumInstanceNames(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref) +{ + return return_vsms(ref, results, true); +} + +static CMPIStatus EnumInstances(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + + return return_vsms(ref, results, false); +} + + +static CMPIStatus GetInstance(CMPIInstanceMI *self, + const CMPIContext *context, + const CMPIResult *results, + const CMPIObjectPath *ref, + const char **properties) +{ + CMPIInstance *inst; + CMPIStatus s; + const char *prop; + + s = get_migration_service(ref, &inst, _BROKER); + if (s.rc != CMPI_RC_OK) + return s; + + prop = cu_compare_ref(ref, inst); + if (prop != NULL) { + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_NOT_FOUND, + "No such instance (%s)", prop); + } else { + CMReturnInstance(results, inst); + } + + return s; +} + +DEFAULT_CI(); +DEFAULT_MI(); +DEFAULT_DI(); +DEFAULT_EQ(); +DEFAULT_INST_CLEANUP(); + +STD_InstanceMIStub(, Virt_VSMigrationService, + _BROKER, + libvirt_cim_init()); +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ diff -r 2e1935bc44ac -r 5ba311c0a725 src/Virt_VSMigrationService.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Virt_VSMigrationService.h Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,35 @@ +/* + * Copyright IBM Corp. 2007 + * + * Authors: + * Dan Smith <danms@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_service(const CMPIObjectPath *reference, + CMPIInstance **_inst, + const CMPIBroker *broker); + +/* + * Local Variables: + * mode: C + * c-set-style: "K&R" + * tab-width: 8 + * c-basic-offset: 8 + * indent-tabs-mode: nil + * End: + */ +

Dan Smith wrote:
+ + conn = connect_by_classname(_BROKER, CLASSNAME(ref), &s); + if (conn == NULL) + goto out; + + dom = virDomainLookupByName(conn, domain); + if (dom == NULL) { + CU_DEBUG("Failed to lookup `%s'", domain); + cu_statusf(_BROKER, &s, + CMPI_RC_ERR_FAILED, + "Failed to lookup domain `%s'", domain); + goto out; + } + + dconn = virConnectOpen(uri); + if (conn == NULL) {
I think to mean: 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; + } + + CMSetStatus(&s, CMPI_RC_OK);
I'm unsure why you call CMSetStatus() before calling virDomainMigrate(). If virDomainMigrate() fails, we set a failure status. Otherwise, we set the status again below. Although, setting it here is harmless anyway. =)
+ CU_DEBUG("Migrating %s -> %s", 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; + } + + CU_DEBUG("Migration succeeded"); + CMSetStatus(&s, CMPI_RC_OK); + + out:
-- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

KR> I think to mean: KR> if (dconn == NULL) I think to mean that too :) KR> I'm unsure why you call CMSetStatus() before calling KR> virDomainMigrate(). If virDomainMigrate() fails, we set a failure KR> status. Otherwise, we set the status again below. Although, KR> setting it here is harmless anyway. =) Heh, oops. The reason is that when I was first working on it, the whole migrate function was just setting status to OK, which I apparently never removed. I've got a new version of this cooked up with more function anyway, I'll make these changes and send it out tomorrow. Thanks :) -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

Dan Smith wrote:
KR> I think to mean: KR> if (dconn == NULL)
I think to mean that too :)
Excellent typo on my part ;)
KR> I'm unsure why you call CMSetStatus() before calling KR> virDomainMigrate(). If virDomainMigrate() fails, we set a failure KR> status. Otherwise, we set the status again below. Although, KR> setting it here is harmless anyway. =)
Heh, oops. The reason is that when I was first working on it, the whole migrate function was just setting status to OK, which I apparently never removed.
I've got a new version of this cooked up with more function anyway, I'll make these changes and send it out tomorrow.
Thanks :)
Could you also include instructions on testing migration? It seems difficult to do via wbemcli - I haven't tested a method provider before. -- Kaitlin Rupert IBM Linux Technology Center karupert@us.ibm.com

KR> Could you also include instructions on testing migration? It KR> seems difficult to do via wbemcli - I haven't tested a method KR> provider before. I use the following xml with wbemcat or wbemexec to make the method call: <?xml version="1.0" encoding="UTF-8"?> <CIM CIMVERSION="2.0" DTDVERSION="2.0"> <MESSAGE ID="5" PROTOCOLVERSION="1.0"> <SIMPLEREQ> <METHODCALL NAME="MigrateVirtualSystemToHost"> <LOCALINSTANCEPATH> <LOCALNAMESPACEPATH> <NAMESPACE NAME="root"/><NAMESPACE NAME="virt"/> </LOCALNAMESPACEPATH> <INSTANCENAME CLASSNAME="Xen_VirtualSystemMigrationService"> <KEYBINDING NAME="CreationClassName"> <KEYVALUE VALUETYPE="string">Xen_VirtualSystemMigrationService</KEYVALUE> </KEYBINDING> <KEYBINDING NAME="SystemName"> <KEYVALUE VALUETYPE="string">foo.bar.com</KEYVALUE> </KEYBINDING> </INSTANCENAME> </LOCALINSTANCEPATH> <PARAMVALUE NAME="ComputerSystem"> <VALUE.REFERENCE> <INSTANCENAME CLASSNAME="Xen_ComputerSystem"> <KEYBINDING NAME="CreationClassName"> <KEYVALUE VALUETYPE="string">Xen_ComputerSystem</KEYVALUE> </KEYBINDING> <KEYBINDING NAME="Name"> <KEYVALUE VALUETYPE="string">pv0</KEYVALUE> </KEYBINDING> </INSTANCENAME> </VALUE.REFERENCE> </PARAMVALUE> <PARAMVALUE NAME="DestinationHost" PARAMTYPE="string"> <VALUE> localhost </VALUE> </PARAMVALUE> </METHODCALL> </SIMPLEREQ> </MESSAGE> </CIM> You'll need to change "pv0" to the name of a valid domain, and the "localhost" to a valid destination host (or leave it as localhost to test on loopback). Note that unless you have a key setup, you'll need to type root's password on the CIMOM's stdin. You should be able to tweak the above to test the IsMigratable flavor as well. -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID d22f5f8cf494b7d1290e58b337843d2d70fc7f96 # Parent 5ba311c0a725a603bb0e30349ad95d429a88f500 Add build support for VirtualSystemMigrationService Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 5ba311c0a725 -r d22f5f8cf494 Makefile.am --- a/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/Makefile.am Mon Dec 03 11:55:44 2007 -0800 @@ -34,7 +34,8 @@ MOFS = \ schema/ElementAllocatedFromPool.mof \ schema/HostedService.mof \ schema/ElementSettingData.mof \ - schema/VSMigrationCapabilities.mof + schema/VSMigrationCapabilities.mof \ + schema/VSMigrationService.mof INTEROP_MOFS = \ schema/ComputerSystem.mof \ @@ -74,7 +75,8 @@ REGS = \ schema/ElementAllocatedFromPool.registration \ schema/HostedService.registration \ schema/ElementSettingData.registration \ - schema/VSMigrationCapabilities.registration + schema/VSMigrationCapabilities.registration \ + schema/VSMigrationService.registration INTEROP_REGS = \ schema/RegisteredProfile.registration \ diff -r 5ba311c0a725 -r d22f5f8cf494 schema/VSMigrationService.mof --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationService.mof Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,41 @@ +// Copyright IBM Corp. 2007 + +// Placeholder definition until schema is available upstream + +class CIM_VirtualSystemMigrationService : CIM_Service { + uint32 VirtualSystemIsMigratableToHost( + [Out] + CIM_ConcreteJob REF Job, + [In, EmbeddedInstance("CIM_ResourceAllocationSettingData")] + string NewResourceSettingData[], + [In, EmbeddedInstance("CIM_SettingData")] + string MigrationSettingData, + [In, EmbeddedInstance("CIM_VirtualSystemSettingData")] + string NewSystemSettingData, + [In] + CIM_ComputerSystem REF ComputerSystem, + [In] + string DestinationHost); + + uint32 MigrateVirtualSystemToHost( + [Out] + CIM_ConcreteJob REF Job, + [In, EmbeddedInstance("CIM_ResourceAllocationSettingData")] + string NewResourceSettingData[], + [In, EmbeddedInstance("CIM_SettingData")] + string MigrationSettingData, + [In, EmbeddedInstance("CIM_VirtualSystemSettingData")] + string NewSystemSettingData, + [In] + CIM_ComputerSystem REF ComputerSystem, + [In] + string DestinationHost); + +}; + +class Xen_VirtualSystemMigrationService : CIM_VirtualSystemMigrationService { +}; + +class KVM_VirtualSystemMigrationService : CIM_VirtualSystemMigrationService { +}; + diff -r 5ba311c0a725 -r d22f5f8cf494 schema/VSMigrationService.registration --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/schema/VSMigrationService.registration Mon Dec 03 11:55:44 2007 -0800 @@ -0,0 +1,4 @@ +# Copyright IBM Corp. 2007 +# Classname Namespace ProviderName ProviderModule ProviderTypes +Xen_VirtualSystemMigrationService root/virt Virt_VSMigrationService Virt_VSMigrationService instance method +KVM_VirtualSystemMigrationService root/virt Virt_VSMigrationService Virt_VSMigrationService instance method \ No newline at end of file diff -r 5ba311c0a725 -r d22f5f8cf494 src/Makefile.am --- a/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 @@ -51,7 +51,8 @@ provider_LTLIBRARIES = libVirt_ComputerS libVirt_ElementAllocatedFromPool.la \ libVirt_HostedService.la \ libVirt_ElementSettingData.la \ - libVirt_VSMigrationCapabilities.la + libVirt_VSMigrationCapabilities.la \ + libVirt_VSMigrationService.la libVirt_ComputerSystem_la_SOURCES = Virt_ComputerSystem.c libVirt_Device_la_SOURCES = Virt_Device.c @@ -140,4 +141,6 @@ libVirt_ElementSettingData_la_SOURCES = libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c libVirt_ElementSettingData_la_LIBADD = -lVirt_VSSD -lVirt_RASD -libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c \ No newline at end of file +libVirt_VSMigrationCapabilities_la_SOURCES = Virt_VSMigrationCapabilities.c + +libVirt_VSMigrationService_la_SOURCES = Virt_VSMigrationService.c \ No newline at end of file

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711744 28800 # Node ID 316176ff9b6325e920a8484d09793c16026d1ce7 # Parent d22f5f8cf494b7d1290e58b337843d2d70fc7f96 Add HostedService support for VirtualSystemMigrationService Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r d22f5f8cf494 -r 316176ff9b63 src/Makefile.am --- a/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 @@ -133,9 +133,9 @@ libVirt_ElementAllocatedFromPool_la_SOUR libVirt_ElementAllocatedFromPool_la_SOURCES = Virt_ElementAllocatedFromPool.c libVirt_ElementAllocatedFromPool_la_LIBADD = -lVirt_DevicePool -lVirt_Device -libVirt_HostedService_la_DEPENDENCIES = libVirt_VirtualSystemManagementService.la libVirt_ResourcePoolConfigurationService.la +libVirt_HostedService_la_DEPENDENCIES = libVirt_VirtualSystemManagementService.la libVirt_ResourcePoolConfigurationService.la libVirt_VSMigrationService.la libVirt_HostedService_la_SOURCES = Virt_HostedService.c -libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService -lVirt_ResourcePoolConfigurationService +libVirt_HostedService_la_LIBADD = -lVirt_VirtualSystemManagementService -lVirt_ResourcePoolConfigurationService -lVirt_VSMigrationService libVirt_ElementSettingData_la_DEPENDENCIES = libVirt_VSSD.la libVirt_RASD.la libVirt_ElementSettingData_la_SOURCES = Virt_ElementSettingData.c diff -r d22f5f8cf494 -r 316176ff9b63 src/Virt_HostedService.c --- a/src/Virt_HostedService.c Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Virt_HostedService.c Mon Dec 03 11:55:44 2007 -0800 @@ -33,6 +33,7 @@ #include "Virt_HostSystem.h" #include "Virt_VirtualSystemManagementService.h" #include "Virt_ResourcePoolConfigurationService.h" +#include "Virt_VSMigrationService.h" const static CMPIBroker *_BROKER; @@ -72,6 +73,12 @@ static CMPIStatus host_to_service(const return s; if (!CMIsNullObject(inst)) inst_list_add(list, inst); + + s = get_migration_service(ref, &inst, _BROKER); + if (s.rc != CMPI_RC_OK) + return s; + if (!CMIsNullObject(inst)) + inst_list_add(list, inst); return s; } @@ -116,8 +123,10 @@ char* dependent[] = { char* dependent[] = { "Xen_ResourcePoolConfigurationService", "Xen_VirtualSystemManagementService", + "Xen_VirtualSystemMigrationService", "KVM_ResourcePoolConfigurationService", "KVM_VirtualSystemManagementService", + "KVM_VirtualSystemMigrationService", NULL };

# HG changeset patch # User Dan Smith <danms@us.ibm.com> # Date 1196711755 28800 # Node ID f1cece43c3fd0f0646729ab378bfdbcc303ecbf9 # Parent 316176ff9b6325e920a8484d09793c16026d1ce7 Add ElementCapabilities support for VirtualSystemMigrationCapabilities Signed-off-by: Dan Smith <danms@us.ibm.com> diff -r 316176ff9b63 -r f1cece43c3fd src/Makefile.am --- a/src/Makefile.am Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Makefile.am Mon Dec 03 11:55:55 2007 -0800 @@ -88,12 +88,13 @@ libVirt_ElementConformsToProfile_la_LIBA libVirt_EnabledLogicalElementCapabilities_la_SOURCES = Virt_EnabledLogicalElementCapabilities.c -libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la +libVirt_ElementCapabilities_la_DEPENDENCIES = libVirt_VirtualSystemManagementCapabilities.la libVirt_EnabledLogicalElementCapabilities.la libVirt_ComputerSystem.la libVirt_HostSystem.la libVirt_VSMigrationCapabilities.la libVirt_ElementCapabilities_la_SOURCES = Virt_ElementCapabilities.c libVirt_ElementCapabilities_la_LIBADD = -lVirt_VirtualSystemManagementCapabilities \ -lVirt_EnabledLogicalElementCapabilities \ -lVirt_ComputerSystem \ - -lVirt_HostSystem + -lVirt_HostSystem \ + -lVirt_VSMigrationCapabilities libVirt_AllocationCapabilities_la_DEPENDENCIES = libVirt_RASD.la libVirt_DevicePool.la libVirt_AllocationCapabilities_la_SOURCES = Virt_AllocationCapabilities.c diff -r 316176ff9b63 -r f1cece43c3fd src/Virt_ElementCapabilities.c --- a/src/Virt_ElementCapabilities.c Mon Dec 03 11:55:44 2007 -0800 +++ b/src/Virt_ElementCapabilities.c Mon Dec 03 11:55:55 2007 -0800 @@ -37,6 +37,7 @@ #include "Virt_EnabledLogicalElementCapabilities.h" #include "Virt_ComputerSystem.h" #include "Virt_HostSystem.h" +#include "Virt_VSMigrationCapabilities.h" /* Associate an XXX_Capabilities to the proper XXX_ManagedElement. * @@ -70,6 +71,11 @@ static CMPIStatus sys_to_cap(const CMPIO s = get_vsm_cap(_BROKER, ref, &inst); if (s.rc == CMPI_RC_OK) inst_list_add(list, inst); + + s = get_migration_caps(ref, &inst, _BROKER); + if (s.rc == CMPI_RC_OK) + inst_list_add(list, inst); + out: return s; } @@ -249,8 +255,10 @@ char* host_system[] = { char* virtual_system_management_capabilities[] = { "Xen_VirtualSystemManagementCapabilities", + "Xen_VirtualSystemMigrationCapabilities", "KVM_VirtualSystemManagementCapabilities", - NULL + "KVM_VirtualSystemMigrationCapabilities", + NULL, }; struct std_assoc system_to_vsm_cap = {

Dan Smith wrote:
This patch set adds preliminary migration support based on the current Virtual System Migration Profile. It's not quite done yet, but it does actually migrate VMs (tested with Xen).
Still needing to be done are: - MigrationSettingData (perhaps to include ssh/TLS flag?) - Something for IsMigratable methods - Job support - Indication support
_______________________________________________ Libvirt-cim mailing list Libvirt-cim@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-cim
Other than the one question for patch number one, which I expect you'll have a good answer for, this looks good to me. I won't pretend to understand exactly what is going on with the actual migration, but your CIM side of things looks pretty good, and since it looks like libvirt is doing most of the heavy lifting for us anyway (and you said it works in testing), this looks like a pretty good start. I assume the "still needing to be done" stuff doesn't block what you've got here? If so, +1. -- -Jay

Dan Smith wrote:
This patch set adds preliminary migration support based on the current Virtual System Migration Profile. It's not quite done yet, but it does actually migrate VMs (tested with Xen).
Still needing to be done are: - MigrationSettingData (perhaps to include ssh/TLS flag?) - Something for IsMigratable methods - Job support - Indication support
Great work :). Can we add a check to the configure script for the right libvirt version ? My one seems to be outdated and the compile exits with error. cc1: warnings being treated as errors Virt_VSMigrationService.c: In function 'migrate_vs': Virt_VSMigrationService.c:278: warning: implicit declaration of function 'virDomainMigrate' Virt_VSMigrationService.c:278: error: 'VIR_MIGRATE_LIVE' undeclared (first use in this function) Virt_VSMigrationService.c:278: error: (Each undeclared identifier is reported only once Virt_VSMigrationService.c:278: error: for each function it appears in.) Virt_VSMigrationService.c:278: warning: assignment makes pointer from integer without a cast -- Regards Heidi Eckhart Software Engineer Linux Technology Center - Open Hypervisor heidieck@linux.vnet.ibm.com ************************************************** IBM Deutschland Entwicklung GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschaeftsfuehrung: Herbert Kircher Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

HE> Can we add a check to the configure script for the right libvirt HE> version ? My one seems to be outdated and the compile exits with HE> error. Yeah, absolutely. I actually hit another such error when I first test-compiled on an older box because I forgot to point it at /usr/local. Thanks! -- Dan Smith IBM Linux Technology Center Open Hypervisor Team email: danms@us.ibm.com
participants (4)
-
Dan Smith
-
Heidi Eckhart
-
Jay Gagnon
-
Kaitlin Rupert