From adb282ef8eb2b514a6918208a608642a2aca4ec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sat, 26 Dec 2015 02:14:28 +0100 Subject: [PATCH] Implement qvm-shutdown --wait-time option Flexible VM shutdown timeout option. Fixes QubesOS/qubes-issues#1320 --- qvm-tools/qvm-shutdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qvm-tools/qvm-shutdown b/qvm-tools/qvm-shutdown index 37374cba..da3eeec2 100755 --- a/qvm-tools/qvm-shutdown +++ b/qvm-tools/qvm-shutdown @@ -36,6 +36,10 @@ def main(): help="Force operation, even if may damage other VMs (eg shutdown of NetVM)") parser.add_option ("--wait", action="store_true", dest="wait_for_shutdown", default=False, help="Wait for the VM(s) to shutdown") + parser.add_option("--wait-time", action="store", dest="wait_time", + default=defaults["shutdown_counter_max"], + help="Timout after which VM will be killed when --wait " + "is used") parser.add_option ("--all", action="store_true", dest="shutdown_all", default=False, help="Shutdown all running VMs") parser.add_option ("--exclude", action="append", dest="exclude_list", @@ -107,7 +111,7 @@ def main(): continue else: halting_vms.append(vm) - if shutdown_counter > defaults["shutdown_counter_max"]: + if shutdown_counter > int(options.wait_time): # kill the VM if options.verbose: print >> sys.stderr, "Killing the (apparently hanging) VM '{0}'...".format(vm.name)