KVM test: shutdown test: do not close session immediately after shutdown command
If the session is closed immediately after a command is sent, the command may
not be executed. To overcome this, first wait for the guest to shut down, and
then close the session.
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3540 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 0f34bb9..ce66141 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -80,18 +80,20 @@
if not session:
raise error.TestFail("Could not log into guest")
- logging.info("Logged in")
+ try:
+ logging.info("Logged in")
- # Send the VM's shutdown command
- session.sendline(vm.get_params().get("cmd_shutdown"))
- session.close()
+ # Send the VM's shutdown command
+ session.sendline(vm.get_params().get("cmd_shutdown"))
- logging.info("Shutdown command sent; waiting for guest to go down...")
+ logging.info("Shutdown command sent; waiting for guest to go down...")
- if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
- raise error.TestFail("Guest refuses to go down")
+ if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
+ raise error.TestFail("Guest refuses to go down")
- logging.info("Guest is down")
+ logging.info("Guest is down")
+ finally:
+ session.close()
def run_migration(test, params, env):