tools: pause/unpause/shutdown - don't stop on first failed VM

But still report a failure with exit code if any of them failed.

QubesOS/qubes-issues#853
This commit is contained in:
Marek Marczykowski-Górecki 2017-03-09 02:26:05 +01:00
parent 7baa7e4862
commit 795a06e400
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
3 changed files with 18 additions and 5 deletions

View File

@ -36,10 +36,15 @@ def main(args=None, app=None):
'''
args = parser.parse_args(args, app=app)
exit_code = 0
for domain in args.domains:
domain.pause()
try:
domain.pause()
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
exit_code = 1
parser.print_error(str(e))
return 0
return exit_code
if __name__ == '__main__':

View File

@ -28,6 +28,7 @@ import sys
import time
import qubesmgmt.tools
import qubesmgmt.exc
parser = qubesmgmt.tools.QubesArgumentParser(
description=__doc__, vmname_nargs='+')
@ -52,8 +53,10 @@ def main(args=None, app=None): # pylint: disable=missing-docstring
args = parser.parse_args(args, app=app)
for vm in args.domains:
if not vm.is_halted():
try:
vm.shutdown(force=args.force)
except qubesmgmt.exc.QubesVMNotStartedError:
pass
if not args.wait:
return

View File

@ -37,10 +37,15 @@ def main(args=None, app=None):
'''
args = parser.parse_args(args, app=app)
exit_code = 0
for domain in args.domains:
domain.unpause()
try:
domain.unpause()
except (IOError, OSError, qubesmgmt.exc.QubesException) as e:
exit_code = 1
parser.print_error(str(e))
return 0
return exit_code
if __name__ == '__main__':