KVM test: add option to kill all unresponsive VMs at the end of each test
This is useful for tests that may leave VMs in a bad state but can't afford to
use kill_vm_on_error = yes.
For example, timedrift.with_reboot can fail because the reboot failed or
because the time drift was too large. In the latter case there's no reason to
kill the VM.
Signed-off-by: Michael Goldish <mgoldish@redhat.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@3837 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/tests/kvm/kvm_preprocessing.py b/client/tests/kvm/kvm_preprocessing.py
index 26f7f8e..e624a42 100644
--- a/client/tests/kvm/kvm_preprocessing.py
+++ b/client/tests/kvm/kvm_preprocessing.py
@@ -293,6 +293,18 @@
int(params.get("post_command_timeout", "600")),
params.get("post_command_noncritical") == "yes")
+ # Kill all unresponsive VMs
+ if params.get("kill_unresponsive_vms") == "yes":
+ logging.debug("'kill_unresponsive_vms' specified; killing all VMs "
+ "that fail to respond to a remote login request...")
+ for vm in kvm_utils.env_get_all_vms(env):
+ if vm.is_alive():
+ session = vm.remote_login()
+ if session:
+ session.close()
+ else:
+ vm.destroy(gracefully=False)
+
# Kill the tailing threads of all VMs
for vm in kvm_utils.env_get_all_vms(env):
vm.kill_tail_thread()