OLD | NEW |
1 import logging, time | 1 import logging, time |
2 from autotest_lib.client.common_lib import error | 2 from autotest_lib.client.common_lib import error |
3 import kvm_utils | 3 from autotest_lib.client.virt import virt_utils |
4 | 4 |
5 | 5 |
6 @error.context_aware | 6 @error.context_aware |
7 def run_guest_s4(test, params, env): | 7 def run_guest_s4(test, params, env): |
8 """ | 8 """ |
9 Suspend guest to disk, supports both Linux & Windows OSes. | 9 Suspend guest to disk, supports both Linux & Windows OSes. |
10 | 10 |
11 @param test: kvm test object. | 11 @param test: kvm test object. |
12 @param params: Dictionary with test parameters. | 12 @param params: Dictionary with test parameters. |
13 @param env: Dictionary with the test environment. | 13 @param env: Dictionary with the test environment. |
(...skipping 28 matching lines...) Expand all Loading... |
42 error.context() | 42 error.context() |
43 error.base_context() | 43 error.base_context() |
44 | 44 |
45 # Suspend to disk | 45 # Suspend to disk |
46 logging.info("Starting suspend to disk now...") | 46 logging.info("Starting suspend to disk now...") |
47 session2.sendline(params.get("set_s4_cmd")) | 47 session2.sendline(params.get("set_s4_cmd")) |
48 | 48 |
49 # Make sure the VM goes down | 49 # Make sure the VM goes down |
50 error.base_context("after S4") | 50 error.base_context("after S4") |
51 suspend_timeout = 240 + int(params.get("smp")) * 60 | 51 suspend_timeout = 240 + int(params.get("smp")) * 60 |
52 if not kvm_utils.wait_for(vm.is_dead, suspend_timeout, 2, 2): | 52 if not virt_utils.wait_for(vm.is_dead, suspend_timeout, 2, 2): |
53 raise error.TestFail("VM refuses to go down. Suspend failed.") | 53 raise error.TestFail("VM refuses to go down. Suspend failed.") |
54 logging.info("VM suspended successfully. Sleeping for a while before " | 54 logging.info("VM suspended successfully. Sleeping for a while before " |
55 "resuming it.") | 55 "resuming it.") |
56 time.sleep(10) | 56 time.sleep(10) |
57 | 57 |
58 # Start vm, and check whether the program is still running | 58 # Start vm, and check whether the program is still running |
59 logging.info("Resuming suspended VM...") | 59 logging.info("Resuming suspended VM...") |
60 vm.create() | 60 vm.create() |
61 | 61 |
62 # Log into the resumed VM | 62 # Log into the resumed VM |
63 relogin_timeout = int(params.get("relogin_timeout", 240)) | 63 relogin_timeout = int(params.get("relogin_timeout", 240)) |
64 logging.info("Logging into resumed VM, timeout %s", relogin_timeout) | 64 logging.info("Logging into resumed VM, timeout %s", relogin_timeout) |
65 session2 = vm.wait_for_login(timeout=relogin_timeout) | 65 session2 = vm.wait_for_login(timeout=relogin_timeout) |
66 | 66 |
67 # Check whether the test command is still alive | 67 # Check whether the test command is still alive |
68 error.context("making sure background program is still running", | 68 error.context("making sure background program is still running", |
69 logging.info) | 69 logging.info) |
70 session2.cmd(check_s4_cmd) | 70 session2.cmd(check_s4_cmd) |
71 error.context() | 71 error.context() |
72 | 72 |
73 logging.info("VM resumed successfuly after suspend to disk") | 73 logging.info("VM resumed successfuly after suspend to disk") |
74 session2.cmd_output(params.get("kill_test_s4_cmd")) | 74 session2.cmd_output(params.get("kill_test_s4_cmd")) |
75 session.close() | 75 session.close() |
76 session2.close() | 76 session2.close() |
OLD | NEW |