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

Michael Goldish
2010-12-27T16:01:31Z

client/tests/kvm/tests/migration_with_reboot.py | 19 +++++++------------
1 files changed, 7 insertions(+), 12 deletions(-)

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()
--
1.7.3.3