From e499e6e88cbb2513ef64d5f834cee2b7c9a4c8e3 Mon Sep 17 00:00:00 2001 From: "M. Vefa Bicakci" Date: Tue, 14 Mar 2017 16:36:51 +0300 Subject: [PATCH] qvm-shutdown: Allow multiple VMs to be shut down with one invocation Prior to this commit, qvm-shutdown had a limitation where only one VM name could be passed in via the command line for shutting down. This commit removes the aforementioned limitation by adapting the code for multiple command line arguments. Signed-off-by: M. Vefa Bicakci --- qvm-tools/qvm-shutdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/qvm-tools/qvm-shutdown b/qvm-tools/qvm-shutdown index 98f19d23..81b1fab4 100755 --- a/qvm-tools/qvm-shutdown +++ b/qvm-tools/qvm-shutdown @@ -47,7 +47,7 @@ def main(): "repeated)") (options, args) = parser.parse_args () - if not options.shutdown_all and (len (args) != 1): + if not options.shutdown_all and not args: parser.error ("You must specify VM name!") qvm_collection = QubesVmCollection() @@ -66,12 +66,12 @@ def main(): if vm.is_running(): vms_list.append (vm) else: - vmname = args[0] - vm = qvm_collection.get_vm_by_name(vmname) - if vm is None: - print >> sys.stderr, "A VM with the name '{0}' does not exist in the system!".format(vmname) - exit(1) - vms_list.append(vm) + for vmname in args: + vm = qvm_collection.get_vm_by_name(vmname) + if vm is None: + print >> sys.stderr, "A VM with the name '{0}' does not exist in the system!".format(vmname) + exit(1) + vms_list.append(vm) # Check VMs network dependencies if not options.force: