@@ -133,7 +133,7 @@ def reboot(vm, session, method="shell", sleep_before_reset=10, nic_index=0,
def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
- mig_cancel=False):
+ mig_cancel=False, dest_host='localhost', mig_port=None):
"""
Migrate a VM locally and re-register it in the environment.
@@ -143,6 +143,8 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
@param mig_timeout: timeout value for migration.
@param mig_protocol: migration protocol
@param mig_cancel: Test migrate_cancel or not when protocol is tcp.
+ @param dest_host: Destination host (defaults to 'localhost').
+ @param mig_port: Port that will be used for migration.
@return: The post-migration VM.
"""
def mig_finished():
@@ -181,7 +183,8 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
raise error.TestFail("Timeout expired while waiting for migration "
"to finish")
- dest_vm = vm.clone()
+ if dest_host == 'localhost':
+ dest_vm = vm.clone()
if mig_protocol == "exec":
# Exec is a little different from other migrate methods - first we
@@ -196,9 +199,11 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
vm.monitor.migrate(uri)
wait_for_migration()
- if not dest_vm.create(migration_mode=mig_protocol,
- migration_exec_cmd=exec_cmd, mac_source=vm):
- raise error.TestError("Could not create dest VM")
+ if dest_host == 'localhost':
+ if not dest_vm.create(migration_mode=mig_protocol,
+ migration_exec_cmd=exec_cmd,
+ mac_source=vm):
+ raise error.TestError("Could not create dest VM")
finally:
logging.debug("Removing migration file %s", exec_file)
try:
@@ -206,11 +211,15 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
except OSError:
pass
else:
- if not dest_vm.create(migration_mode=mig_protocol, mac_source=vm):
- raise error.TestError("Could not create dest VM")
+ if dest_host == 'localhost':
+ if not dest_vm.create(migration_mode=mig_protocol, mac_source=vm):
+ raise error.TestError("Could not create dest VM")
try:
if mig_protocol == "tcp":
- uri = "tcp:localhost:%d" % dest_vm.migration_port
+ if dest_host == 'localhost':
+ uri = "tcp:localhost:%d" % dest_vm.migration_port
+ else:
+ uri = 'tcp:%s:%d' % (dest_host, mig_port)
elif mig_protocol == "unix":
uri = "unix:%s" % dest_vm.migration_file
vm.monitor.migrate(uri)
@@ -222,12 +231,14 @@ def migrate(vm, env=None, mig_timeout=3600, mig_protocol="tcp",
"Waiting for migration "
"cancellation"):
raise error.TestFail("Failed to cancel migration")
- dest_vm.destroy(gracefully=False)
+ if dest_host == 'localhost':
+ dest_vm.destroy(gracefully=False)
return vm
else:
wait_for_migration()
except:
- dest_vm.destroy()
+ if dest_host == 'localhost':
+ dest_vm.destroy()
raise
# Report migration status