Implement qvm-shutdown --wait-time option

Flexible VM shutdown timeout option.

Fixes QubesOS/qubes-issues#1320
This commit is contained in:
Marek Marczykowski-Górecki 2015-12-26 02:14:28 +01:00
parent d4a42093b1
commit adb282ef8e
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -36,6 +36,10 @@ def main():
help="Force operation, even if may damage other VMs (eg shutdown of NetVM)") 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, parser.add_option ("--wait", action="store_true", dest="wait_for_shutdown", default=False,
help="Wait for the VM(s) to shutdown") 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, parser.add_option ("--all", action="store_true", dest="shutdown_all", default=False,
help="Shutdown all running VMs") help="Shutdown all running VMs")
parser.add_option ("--exclude", action="append", dest="exclude_list", parser.add_option ("--exclude", action="append", dest="exclude_list",
@ -107,7 +111,7 @@ def main():
continue continue
else: else:
halting_vms.append(vm) halting_vms.append(vm)
if shutdown_counter > defaults["shutdown_counter_max"]: if shutdown_counter > int(options.wait_time):
# kill the VM # kill the VM
if options.verbose: if options.verbose:
print >> sys.stderr, "Killing the (apparently hanging) VM '{0}'...".format(vm.name) print >> sys.stderr, "Killing the (apparently hanging) VM '{0}'...".format(vm.name)