diff mbox

[KVM-AUTOTEST,04/28] KVM test: migration_with_reboot: use kvm_utils.Thread

Message ID 1293465715-16599-4-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Dec. 27, 2010, 4:01 p.m. UTC
None
diff mbox

Patch

diff --git a/client/tests/kvm/tests/migration_with_reboot.py b/client/tests/kvm/tests/migration_with_reboot.py
index 5070dbc..af5de64 100644
--- a/client/tests/kvm/tests/migration_with_reboot.py
+++ b/client/tests/kvm/tests/migration_with_reboot.py
@@ -19,7 +19,6 @@  def run_migration_with_reboot(test, params, env):
     @param params: Dictionary with test parameters.
     @param env: Dictionary with the test environment.
     """
-
     def reboot_test(client, session, address, reboot_command, port, username,
                     password, prompt, linesep, log_filename, timeout):
         """
@@ -67,24 +66,20 @@  def run_migration_with_reboot(test, params, env):
     mig_timeout = float(params.get("mig_timeout", "3600"))
     mig_protocol = params.get("migration_protocol", "tcp")
     mig_cancel = bool(params.get("mig_cancel"))
-    bg = None
 
     try:
-        # reboot the VM in background
-        bg = kvm_test_utils.BackgroundTest(reboot_test,
-                                           (client, session, address,
+        # Reboot the VM in the background
+        bg = kvm_utils.Thread(reboot_test, (client, session, address,
                                             reboot_command, port, username,
                                             password, prompt, linesep,
                                             log_filename, timeout))
         bg.start()
 
-        while bg.is_alive():
-            # Migrate the VM
-            dest_vm = kvm_test_utils.migrate(vm, env, mig_timeout, mig_protocol,
-                                             False)
-            vm = dest_vm
+        try:
+            while bg.is_alive():
+                vm = kvm_test_utils.migrate(vm, env, mig_timeout, mig_protocol)
+        finally:
+            bg.join()
 
     finally:
-        if bg:
-            bg.join()
         session.close()