This patch adds a cleanup function to clean up environment on destination host 
after migration.
So that we can do uni-direction migration in this test.

Signed-off-by: Tang Chen <[email protected]>
---
 client/tests/libvirt/tests/virsh_migrate.py |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/client/tests/libvirt/tests/virsh_migrate.py 
b/client/tests/libvirt/tests/virsh_migrate.py
index e19c921..dbdd062 100644
--- a/client/tests/libvirt/tests/virsh_migrate.py
+++ b/client/tests/libvirt/tests/virsh_migrate.py
@@ -3,9 +3,26 @@ from autotest_lib.client.common_lib import error
 
 def run_virsh_migrate(test, params, env):
     """
-    Test the migrate command with parameter --live.
+    Test virsh migrate command.
     """
 
+    def cleanup_dest(vm, src_uri = ""):
+        """
+        Clean up the destination host environment 
+        when doing the uni-direction migration.
+        """
+        vm_state = vm.state()
+        if vm_state == "running":
+            vm.destroy()
+        elif vm_state == "paused":
+            vm.resume()
+            vm.destroy()
+
+        if vm.is_persistent():
+            vm.undefine()
+
+        vm.connect_uri = src_uri
+
     def do_migration(dly, vm, dest_uri, options, extra):
         logging.info("Sleeping %d seconds before migration" % dly)
         time.sleep(dly)
@@ -57,3 +74,6 @@ def run_virsh_migrate(test, params, env):
         if back_extra == 'default':
             back_extra = extra
         do_migration(dly, vm, back_dest_uri, back_options, back_extra)
+    # Do the uni-direction migration here.
+    else:
+        cleanup_dest(vm, src_uri)
-- 
1.7.3.1


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

Reply via email to