[PATCH 4/4] KVM test: Modifications on the migrate utility function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In order to accomodate multi-host migration, make migrate
accept 2 additional parameters, dest_host and mig_port.
Also, handle properly the case where we are doing migration
inside the same host.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/kvm_test_utils.py |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
index 2269cd7..cdad442 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -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
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux