[PATCH 0 of 5] [TEST] Added new tc to verify remote live migration.

Verified with KVM. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com>

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237383716 25200 # Node ID 783c9510aaf930a05766707da9a5569f491cad60 # Parent cfc6d625e43e7e78161da8eaf3364bd117e2ff3f [TESTAdding option to main.py to accept target machine info for Migration Tests. New option can be specified as below: CIM_NS=root/virt CIM_USER=userid CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -v KVM -g VirtualSystemMigrationService -t 06_remote_migration.py --target_url <hostname> or CIM_NS=root/virt CIM_USER=userid CIM_PASS=pass ./runtests libvirt-cim -i localhost -c -v KVM -g VirtualSystemMigrationService -t 06_remote_migration.py -m <hostname> Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r cfc6d625e43e -r 783c9510aaf9 suites/libvirt-cim/main.py --- a/suites/libvirt-cim/main.py Wed Mar 18 06:39:53 2009 -0700 +++ b/suites/libvirt-cim/main.py Wed Mar 18 06:41:56 2009 -0700 @@ -44,6 +44,8 @@ parser = OptionParser() parser.add_option("-i", "--ip", dest="ip", default="localhost", help="IP address of machine to test (default: localhost)") +parser.add_option("-m", "--target_url", dest="t_url", default="localhost:5988", + help="URL of destination host for remote migration ") parser.add_option("-p", "--port", dest="port", type="int", default=5988, help="CIMOM port (default: 5988)") parser.add_option("-g", "--group", dest="group", @@ -199,6 +201,14 @@ # with a different port if options.port: os.environ['CIMOM_PORT'] = str(options.port) + + # src and target host info to be able to use + # in the tc for comparison in remote migration case + if ":" in options.ip: + (options.ip, port) = options.ip.split(":") + + if ":" in options.t_url: + (options.t_url, port) = options.t_url.split(":") if options.report: to_addr = options.report @@ -243,8 +253,9 @@ t_path = os.path.join(TEST_SUITE, test['group']) os.environ['CIM_TC'] = test['test'] cdto = 'cd %s' % t_path - run = 'python %s -i %s -v %s %s' % (test['test'], options.ip, - options.virt, dbg) + run = 'python %s -i %s -v %s %s -m %s' % (test['test'], options.ip, + options.virt, dbg, + options.t_url) cmd = cdto + ' && ' + ' ' + run status, output = commands.getstatusoutput(cmd)

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237384005 25200 # Node ID 26b80beef9adac44d524266ca1600c08b1742e53 # Parent 783c9510aaf930a05766707da9a5569f491cad60 [TEST]Modifying emulator information to be used for KVM. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 783c9510aaf9 -r 26b80beef9ad suites/libvirt-cim/lib/XenKvmLib/const.py --- a/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Mar 18 06:41:56 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/const.py Wed Mar 18 06:46:45 2009 -0700 @@ -82,10 +82,12 @@ Xen_default_mac = '11:22:33:aa:bb:cc' # vxml.KVMXML -if fv_cap(CIM_IP): - KVM_default_emulator = '/usr/bin/qemu-kvm' -else: - KVM_default_emulator = '/usr/bin/qemu' +KVM_default_emulator = '/usr/local/bin/qemu-system-x86_64' +if not os.path.exists(KVM_default_emulator): + if fv_cap(CIM_IP): + KVM_default_emulator = '/usr/bin/qemu-kvm' + else: + KVM_default_emulator = '/usr/bin/qemu' KVM_disk_path = os.path.join(_image_dir, 'default-kvm-dimage') KVM_secondary_disk_path = os.path.join(_image_dir, 'default-kvm-dimage.2ND') KVM_default_disk_dev = 'hda' @@ -115,6 +117,8 @@ parser = OptionParser() parser.add_option("-i", "--ip", dest="ip", default="localhost", help="IP address of machine to test, default: localhost") +parser.add_option("-m", "--target_url", dest="t_url", default="localhost:5988", + help="URL of destination host for remote migration ") parser.add_option("-v", "--virt", dest="virt", type="choice", choices=['Xen', 'KVM', 'XenFV', 'LXC'], default="Xen", help="Virt type, select from: 'Xen' & 'KVM' & 'XenFV' & 'LXC', default: Xen")

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237384331 25200 # Node ID b8c1d36035b8077c3b2242fc8f76b8faf6d0d0b6 # Parent 26b80beef9adac44d524266ca1600c08b1742e53 [TEST] Adding support for remote migration in the vsmigrations library. 1) Added local_remote_migrate() fn to migrate the VM. 2) Modified check_migration_job(), get_migration_job_instance(), migrate_guest_to_host(), check_possible_host_migration() to support remote migration. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 26b80beef9ad -r b8c1d36035b8 suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Wed Mar 18 06:46:45 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsmigrations.py Wed Mar 18 06:52:11 2009 -0700 @@ -3,6 +3,7 @@ # # Authors: # Guolian Yun <yunguol@cn.ibm.com> +# Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public @@ -18,34 +19,59 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -import pywbem -import time +# + +from time import sleep +from pywbem import WBEMConnection, CIMInstanceName from CimTest.CimExt import CIMMethodClass, CIMClassMOF -from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS from CimTest.ReturnCodes import PASS, FAIL -from XenKvmLib.test_doms import destroy_and_undefine_domain -from CimTest.Globals import logger, CIM_ERROR_ENUMERATE from XenKvmLib import enumclass -from XenKvmLib.classes import get_typed_class +from XenKvmLib.classes import get_typed_class, virt_types from XenKvmLib.xm_virt_util import domain_list from XenKvmLib.const import get_provider_version +from CimTest.Globals import logger, CIM_USER, CIM_PASS, CIM_NS, \ + CIM_ERROR_ENUMERATE +# Migration constants +CIM_MIGRATE_OFFLINE=1 +CIM_MIGRATE_LIVE=2 +CIM_MIGRATE_RESUME=3 +CIM_MIGRATE_RESTART=4 + +CIM_JOBSTATE_STARTING=3 +CIM_JOBSTATE_COMPLETE=7 +CIM_JOBSTATE_RUNNING=4 libvirt_mig_changes = 668 +def eval_cls(basename): + def func(f): + def body(virt): + if virt in virt_types: + return eval(get_typed_class(virt, basename)) + return body + return func + + class CIM_VirtualSystemMigrationService(CIMMethodClass): conn = None inst = None - def __init__(self, server, hyp): - self.conn = pywbem.WBEMConnection('http://%s' % server, - (CIM_USER, CIM_PASS), CIM_NS) + def __init__(self, server, virt='Xen'): + self.conn = WBEMConnection('http://%s' % server, + (CIM_USER, CIM_PASS), CIM_NS) - self.inst = hyp + '_VirtualSystemMigrationService' + self.inst = get_typed_class(virt, 'VirtualSystemMigrationService') +@eval_cls('VirtualSystemMigrationService') +def get_vs_mig_setting_class(virt): + pass + class Xen_VirtualSystemMigrationService(CIM_VirtualSystemMigrationService): - def __init__(self, server): - CIM_VirtualSystemMigrationService.__init__(self, server, 'Xen') + pass + +class KVM_VirtualSystemMigrationService(CIM_VirtualSystemMigrationService): + pass # classes to define VirtualSystemMigrationSettingData parameters class CIM_VirtualSystemMigrationSettingData(CIMClassMOF): @@ -56,118 +82,242 @@ self.Priority = priority class Xen_VirtualSystemMigrationSettingData(CIM_VirtualSystemMigrationSettingData): - def __init__(self, type, priority): - CIM_VirtualSystemMigrationSettingData.__init__(self, type, - priority) + pass class KVM_VirtualSystemMigrationSettingData(CIM_VirtualSystemMigrationSettingData): - def __init__(self, type, priority): - CIM_VirtualSystemMigrationSettingData.__init__(self, type, - priority) + pass +def get_msd(virt, mtype='live', mpriority=0): + if mtype == "live": + mtype = CIM_MIGRATE_LIVE + elif mtype == "resume": + mtype = CIM_MIGRATE_RESUME + elif mtype == "restart": + mtype = CIM_MIGRATE_RESTART + elif mtype == "offline": + mtype = CIM_MIGRATE_OFFLINE + else: + logger.error("Invalid migration type '%s' specified", mtype) + return None + try: + vsmsd_cn = get_typed_class(virt, "VirtualSystemMigrationSettingData") + msd = eval(vsmsd_cn)(type=mtype, priority=mpriority) + except Exception, details: + logger.error("In get_msd() Exception details: %s", details) + return None + + return msd.mof() + +def get_guest_ref(guest, virt): + guest_cn = get_typed_class(virt, "ComputerSystem") + keys = { 'Name' : guest, 'CreationClassName' : guest_cn } + cs_ref = None + + try: + cs_ref = CIMInstanceName(guest_cn, keybindings=keys) + + except Exception, details: + logger.error("In fn get_guest_ref() Exception details: %s", details) + return None + + return cs_ref + +#Remove this once vsms.02_host_migrate_type.py uses get_msd() def default_msd_str(mtype=3, mpriority=0): msd = Xen_VirtualSystemMigrationSettingData(type=mtype, priority=mpriority) return msd.mof() -def check_possible_host_migration(service, cs_ref, ip): - rc = None +def check_possible_host_migration(service, cs_ref, ip, msd=None): + res = None try: - rc = service.CheckVirtualSystemIsMigratableToHost(ComputerSystem=cs_ref, - DestinationHost=ip) + checkfn_name = 'service.CheckVirtualSystemIsMigratableToHost' + if msd == None: + res = eval(checkfn_name)(ComputerSystem=cs_ref, DestinationHost=ip) + else: + res = eval(checkfn_name)(ComputerSystem=cs_ref, + DestinationHost=ip, + MigrationSettingData=msd) except Exception, details: - logger.error("Error invoke 'CheckVirtualSystemIsMigratableToHost\'.") + logger.error("Error invoke 'CheckVirtualSystemIsMigratableToHost'.") logger.error("%s", details) return FAIL - if rc == None or rc[1]['IsMigratable'] != True: + if res == None or res[1]['IsMigratable'] != True: + logger.error("Migration check failed") return FAIL return PASS -def migrate_guest_to_host(service, ref, ip, msd=None): + +def migrate_guest_to_host(service, cs_ref, dest_ip, msd=None): ret = [] try: if msd == None: - ret = service.MigrateVirtualSystemToHost(ComputerSystem=ref, - DestinationHost=ip) + ret = service.MigrateVirtualSystemToHost(ComputerSystem=cs_ref, + DestinationHost=dest_ip) else: - ret = service.MigrateVirtualSystemToHost(ComputerSystem=ref, - DestinationHost=ip, + ret = service.MigrateVirtualSystemToHost(ComputerSystem=cs_ref, + DestinationHost=dest_ip, MigrationSettingData=msd) except Exception, details: - logger.error("Error invoke method 'MigrateVirtualSystemToHost\'.") - logger.error("%s", details) + logger.error("Failed to invoke method 'MigrateVirtualSystemToHost'.") + logger.error("Exception in fn migrate_guest_to_host() %s", details) return FAIL, ret if len(ret) == 0: logger.error("MigrateVirtualSystemToHost returns an empty list") return FAIL, ret + return PASS, ret -def get_migration_job_instance(ip, virt, id): +def get_migration_job_instance(src_ip, virt, id): job = [] - key_list = ["instanceid"] - curr_cim_rev, changeset = get_provider_version(virt, ip) + curr_cim_rev, changeset = get_provider_version(virt, src_ip) if curr_cim_rev < libvirt_mig_changes: mig_job_cn = 'Virt_MigrationJob' else: mig_job_cn = get_typed_class(virt, 'MigrationJob') try: - job = enumclass.EnumInstances(ip, mig_job_cn) + job = enumclass.EnumInstances(src_ip, mig_job_cn) + if len(job) < 1: + logger.error("'%s' returned empty list", mig_job_cn) + return FAIL, None + + for i in range(0, len(job)): + if job[i].InstanceID == id: + break + elif i == len(job)-1 and job[i].InstanceID != id: + logger.error("%s err: can't find expected job inst", mig_job_cn) + return FAIL, None except Exception, details: logger.error(CIM_ERROR_ENUMERATE, mig_job_cn) - logger.error(details) + logger.error("Exception in fn get_migration_job_instance() " \ + "details: %s", details) return FAIL, None - if len(job) < 1: - return FAIL, None - - for i in range(0, len(job)): - if job[i].InstanceID == id: - break - elif i == len(job)-1 and job[i].InstanceID != id: - logger.error("%s err: can't find expected job inst", mig_job_cn) - return FAIL, None - return PASS, job[i] -def verify_domain_list(list, local_migrate, test_dom): - status = PASS - if local_migrate == 0 and test_dom not in list: - status = FAIL - if local_migrate == 1 and test_dom in list: +def verify_domain_list(virt, remote_migrate, test_dom, src_ip, target_ip): + status = FAIL + list_src = domain_list(src_ip, virt) + if remote_migrate == 0: + if test_dom in list_src: + status = PASS + elif remote_migrate == 1 : + list_target = domain_list(target_ip, virt) + if test_dom not in list_src and test_dom in list_target: + status = PASS + else: + logger.error("Invalid migration option") + + if status != PASS: + logger.error("Migration verification for '%s' failed", test_dom) + return status + + return status + +def check_migration_job(src_ip, id, target_ip, test_dom, + remote_migrate, virt='Xen', timeout=50): + try: + status, job_inst = get_migration_job_instance(src_ip, virt, id) + if status != PASS: + logger.error("Unable to get mig_job instance for '%s'", test_dom) + return FAIL + status = FAIL - if status != PASS: - logger.error("%s migrate failed", test_dom) + for i in range(0, timeout): + if job_inst.JobState == CIM_JOBSTATE_COMPLETE: + sleep(3) + if job_inst.Status != "Completed": + logger.error("JobStatus for dom '%s' has '%s' instead of "\ + "'Completed'", test_dom, job_inst.Status) + return FAIL + else: + status = verify_domain_list(virt, remote_migrate, test_dom, + src_ip, target_ip) + if status != FAIL: + logger.info("Migration for '%s' succeeded.", test_dom) + logger.info("Migration job status is : %s", + job_inst.Status) + return status + elif job_inst.JobState == CIM_JOBSTATE_RUNNING and i < (timeout-1): + sleep(3) + status, job_inst = get_migration_job_instance(src_ip, virt, id) + if status != PASS: + logger.error("Could not get mig_job instance for '%s'", + test_dom) + return status + else: + logger.error("Migration timed out.... ") + logger.error("Increase timeout > %s and try again..", timeout) + return FAIL + + except Exception, details: + logger.error("In check_migration_job() Exception details: %s", details) + return FAIL + +# Desc: +# Fn Name : local_remote_migrate() +# +# Parameters: +# This fn executes local/remote migration depending on the +# value of remote_migrate. +# Parameters used: +# vsmservice = VSMigrationService Instance +# s_sysname = src host on which migration is initiated +# t_sysname = Target machine for migration +# virt = Xen, KVM +# remote_migrate = 1 [for remote migration, 0 for local] +# mtype = live/resume/offline/restart +# mpriority=0 by default +# guest_name = name of the guest to be migrated +# time_out = time for which migration is tried. +# +def local_remote_migrate(s_sysname, t_sysname, virt='KVM', + remote_migrate=1, mtype='live', mpriority=0, + guest_name=None, time_out=40): + + if guest_name == None: + logger.error("Guest to be migrated not specified.") + return FAIL + + # Get the guest ref + guest_ref = get_guest_ref(guest_name, virt) + if guest_ref == None or guest_ref['Name'] != guest_name: + logger.error("Failed to get the guest refernce to be migrated") + return FAIL + + # Get MigrationSettingData information + msd = get_msd(virt, mtype, mpriority) + if msd == None: return FAIL - return PASS + # Get VirtualSystemMigrationService object + vsms_cn = get_vs_mig_setting_class(virt) + vsmservice = vsms_cn(s_sysname, virt) -def check_migration_job(ip, id, target_ip, test_dom, local_migrate, virt='Xen'): - status, job_inst = get_migration_job_instance(ip, virt, id) + # Verify is destination(t_sysname) can be used for migration + status = check_possible_host_migration(vsmservice, guest_ref, + t_sysname, msd) if status != PASS: return FAIL - for i in range(0, 50): - if job_inst.JobState == 7: - if job_inst.Status != "Completed": - logger.error("%s migrate failed", test_dom) - return FAIL - list_after = domain_list(ip) - status = verify_domain_list(list_after, local_migrate, test_dom) - break - elif job_inst.JobState == 4 and i < 49: - time.sleep(3) - status, job_inst = get_migration_job_instance(ip, virt, id) - if status != PASS: - return FAIL - else: - logger.error("MigrateVirtualSystemToHost took too long") - return FAIL + logger.info("Migrating %s.. this will take some time.", guest_name) + # Migrate the guest to t_sysname + status, ret = migrate_guest_to_host(vsmservice, guest_ref, t_sysname, msd) + if status == FAIL: + logger.error("Failed to Migrate guest '%s' from '%s' to '%s'", + guest_name, s_sysname, t_sysname) + return status + elif len(ret) == 2: + id = ret[1]['Job'].keybindings['InstanceID'] - return PASS + # Verify if migration status + status = check_migration_job(s_sysname, id, t_sysname, guest_name, + remote_migrate, virt, timeout=time_out) + return status

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237384697 25200 # Node ID 7e5d84e400ea3e90ea93c7cec02d94558b41c343 # Parent b8c1d36035b8077c3b2242fc8f76b8faf6d0d0b6 [TEST] Adding the Emulator field to VSSD for successful remote migration. To test these change we need the "Add Emulator attribute so users can specify an emulator for the guest" Libvirt-CIM provider patch. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r b8c1d36035b8 -r 7e5d84e400ea suites/libvirt-cim/lib/XenKvmLib/vsms.py --- a/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Mar 18 06:52:11 2009 -0700 +++ b/suites/libvirt-cim/lib/XenKvmLib/vsms.py Wed Mar 18 06:58:17 2009 -0700 @@ -98,6 +98,10 @@ self.CreationClassName = self.__class__.__name__ self.AutomaticShutdownAction = VSSD_RECOVERY_NONE self.AutomaticRecoveryAction = VSSD_RECOVERY_NONE + if virt == 'KVM' : + self.Emulator = const.KVM_default_emulator + elif virt == 'XenFV' : + self.Emulator = const.XenFV_default_emulator self.isFullVirt = (type == 'KVM' or virt == 'XenFV') if self.isFullVirt:

# HG changeset patch # User Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> # Date 1237458102 25200 # Node ID 0ce3d668a5fde8ff8c47e7987ce0efacbe9762fc # Parent 7e5d84e400ea3e90ea93c7cec02d94558b41c343 [TEST] Added new tc to verify remote live migration. Verified with KVM. Signed-off-by: Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> diff -r 7e5d84e400ea -r 0ce3d668a5fd suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_live_migration.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/suites/libvirt-cim/cimtest/VirtualSystemMigrationService/06_remote_live_migration.py Thu Mar 19 03:21:42 2009 -0700 @@ -0,0 +1,154 @@ +#!/usr/bin/python +# +# Copyright 2009 IBM Corp. +# +# Authors: +# Deepti B. Kalakeri <deeptik@linux.vnet.ibm.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU 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 +# General Public License for more details. +# +# You should have received a copy of the GNU 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 +# +# +# This testcase is used to verify the live remote migration. +# +# Date : 12-03-09 +# + +import sys +import os +from socket import gethostname, gethostbyaddr +from XenKvmLib import vxml +from XenKvmLib.xm_virt_util import domain_list, net_list +from CimTest.Globals import logger +from XenKvmLib.const import do_main, default_network_name +from CimTest.ReturnCodes import PASS, FAIL, SKIP +from XenKvmLib.classes import get_typed_class +from XenKvmLib.vsmigrations import local_remote_migrate +from XenKvmLib.common_util import poll_for_state_change, create_netpool_conf,\ + destroy_netpool + +sup_types = ['KVM', 'Xen'] + +REQUESTED_STATE = 2 + +def setup_guest(test_dom, ip, virt): + virt_xml = vxml.get_class(virt) + cxml = virt_xml(test_dom) + ret = cxml.cim_define(ip) + if not ret: + logger.error("Error define domain %s", test_dom) + return FAIL, cxml + + status = cxml.cim_start(ip) + if status != PASS: + cxml.undefine(test_dom) + logger.error("Error to start domain %s", test_dom) + return FAIL, cxml + + status, dom_cs = poll_for_state_change(ip, virt, test_dom, + REQUESTED_STATE) + if status != PASS: + cxml.cim_destroy(test_dom) + cxml.undefine(test_dom) + logger.error("'%s' didn't change state as expected" % test_dom) + return FAIL, cxml + + return PASS, cxml + +def cleanup_guest_netpool(virt, cxml, test_dom, t_sysname, s_sysname): + # Clean the domain on target machine. + # This is req when migration is successful, also when migration is not + # completely successful VM might be created on the target machine + # and hence need to clean. + target_list = domain_list(t_sysname, virt) + if target_list != None and test_dom in target_list: + ret_value = cxml.destroy(t_sysname) + if not ret_value: + logger.info("Failed to destroy the migrated domain '%s' on '%s'", + test_dom, t_sysname) + + ret_value = cxml.undefine(t_sysname) + if not ret_value: + logger.info("Failed to undefine the migrated domain '%s' on '%s'", + test_dom, t_sysname) + + # clean the networkpool created on the remote machine + target_net_list = net_list(t_sysname, virt) + if target_net_list != None and default_network_name in target_net_list: + ret_value = destroy_netpool(t_sysname, virt, default_network_name) + if ret_value != PASS: + logger.info("Unable to destroy networkpool '%s' on '%s'", + default_network_name, t_sysname) + + # Remote Migration not Successful, clean the domain on src machine + src_list = domain_list(s_sysname, virt) + if src_list != None and test_dom in src_list: + ret_value = cxml.cim_destroy(s_sysname) + if not ret_value: + logger.info("Failed to destroy the domain '%s' on the source '%s'", + test_dom, s_sysname) + + ret_value = cxml.undefine(s_sysname) + if not ret_value: + logger.info("Failed to undefine the domain '%s' on source '%s'", + test_dom, s_sysname) + + +@do_main(sup_types) +def main(): + options = main.options + virt = options.virt + s_sysname = gethostbyaddr(options.ip)[0] + t_sysname = gethostbyaddr(options.t_url)[0] + if options.virt == 'KVM' and (t_sysname == s_sysname or \ + t_sysname in s_sysname): + logger.info("Libvirt does not support local migratoin for KVM") + return SKIP + + status = FAIL + test_dom = 'VM_frm_' + gethostname() + + try: + status, cxml = setup_guest(test_dom, s_sysname, virt) + if status != PASS: + logger.error("Error setting up the guest") + return status + + # create the networkpool used in the domain to be migrated + # on the target machine. + t_net_list = net_list(t_sysname, virt) + if t_net_list != None and default_network_name not in t_net_list: + status, netpool = create_netpool_conf(t_sysname, virt, + net_name=default_network_name) + if status != PASS: + raise Exception("Unable to create network pool '%s' on '%s'" + % (default_network_name, t_sysname)) + + # Migrate the test_dom to t_sysname. + # local_remote_migrate executes live migration by default + # Enable remote migration by setting remote_migrate=1 + status = local_remote_migrate(s_sysname, t_sysname, virt, + remote_migrate=1, guest_name=test_dom) + except Exception, details: + logger.error("Exception details :%s", details) + status = FAIL + + cleanup_guest_netpool(virt, cxml, test_dom, t_sysname, s_sysname) + + return status + +if __name__ == "__main__": + sys.exit(main()) +
participants (1)
-
Deepti B. Kalakeri