From: tangchen <[email protected]>

If migration failed, VM could be alive on destination,
but not running (paused). So vm.is_alive() cannot make
sure that migration succeeded. VM state on destination
needs to be checked.

Signed-off-by: Tang Chen <[email protected]>
---
 client/tests/libvirt/tests/virsh_migrate.py |   19 +++++++++++++++++++
 client/virt/subtests.cfg.sample             |    9 ++++++++-
 2 files changed, 27 insertions(+), 1 deletions(-)

diff --git a/client/tests/libvirt/tests/virsh_migrate.py 
b/client/tests/libvirt/tests/virsh_migrate.py
index dbdd062..7e74505 100644
--- a/client/tests/libvirt/tests/virsh_migrate.py
+++ b/client/tests/libvirt/tests/virsh_migrate.py
@@ -6,6 +6,16 @@ def run_virsh_migrate(test, params, env):
     Test virsh migrate command.
     """
 
+    def check_vm_state(vm, state):
+        """
+        Return True if vm is in the correct state.
+        """
+        actual_state = vm.state()
+        if cmp(actual_state, state) == 0:
+            return True
+        else:
+            return False
+
     def cleanup_dest(vm, src_uri = ""):
         """
         Clean up the destination host environment 
@@ -35,6 +45,15 @@ def run_virsh_migrate(test, params, env):
             logging.info("Alive guest found on destination %s." % dest_uri)
         else:
             raise error.TestFail("VM not running on destination %s" % dest_uri)
+
+        # Migration may fail, but VM is alive on destination.
+        dest_state = params.get("virsh_migrate_dest_state")
+        ret = check_vm_state(vm, dest_state)
+        logging.info("Supposed state: %s" % dest_state)
+        logging.info("Actual state: %s" % vm.state())
+        if not ret:
+            raise error.TestFail("VM is not in the supposed state.")
+
         # FIXME: This needs to be tested, but won't work currently
         # vm.verify_kernel_crash()
 
diff --git a/client/virt/subtests.cfg.sample b/client/virt/subtests.cfg.sample
index 93021e3..ba8cd7c 100644
--- a/client/virt/subtests.cfg.sample
+++ b/client/virt/subtests.cfg.sample
@@ -358,6 +358,7 @@ variants:
         # FIXME: Impliment libvirt URI connect user/password
         # virsh_migrate_destuser = root
         # virsh_migrate_destpwd = ""
+        virsh_migrate_dest_state = running
         variants:
             - there_and_back:
                 virsh_migrate_delay = 60
@@ -405,7 +406,13 @@ variants:
                 virsh_migrate_delay = 60
                 virsh_migrate_back = 'no'
                 connect_uri = qemu+ssh://SOURCE_HOSTNAME.EXAMPLE.COM/system
-
+            - there_suspend:
+                # Uni-direction migration with option --suspend.
+                virsh_migrate_options = "--live --suspend"
+                virsh_migrate_delay = 60
+                virsh_migrate_back = 'no'
+                connect_uri = qemu+ssh://SOURCE_HOSTNAME.EXAMPLE.COM/system
+                virsh_migrate_dest_state = paused
 
     - migrate: install setup image_copy unattended_install.cdrom
         type = migration
-- 
1.7.7.6

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to