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@xxxxxxxxxx> --- client/tests/kvm/kvm_tests.py | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py index d98dbae..9cd01e2 100644 --- a/client/tests/kvm/kvm_tests.py +++ b/client/tests/kvm/kvm_tests.py @@ -80,18 +80,20 @@ def run_shutdown(test, params, env): 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("shutdown_command")) - session.close() + # Send the VM's shutdown command + session.sendline(vm.get_params().get("shutdown_command")) + 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): -- 1.5.4.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html