qvm-kill: ignore already off domains

See QubesOS/qubes-issues#5607.
This commit is contained in:
Pawel Marczewski 2020-01-31 11:16:11 +01:00
parent 47188a38e5
commit b8d1884cb1
No known key found for this signature in database
GPG Key ID: DE42EE9B14F96465
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -52,7 +52,6 @@ class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase):
self.assertAllCalled()
def test_003_not_running(self):
# TODO: some option to ignore this error?
self.app.expected_calls[
('some-vm', 'admin.vm.Kill', None, None)] = \
b'2\x00QubesVMNotStartedError\x00\x00Domain is powered off: ' \
@ -62,6 +61,6 @@ class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase):
b'0\x00some-vm class=AppVM state=Halted\n'
self.assertEqual(
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app),
1)
0)
self.assertAllCalled()

View File

@ -28,7 +28,6 @@ import qubesadmin.tools
parser = qubesadmin.tools.QubesArgumentParser(
description='forceful shutdown of a domain', vmname_nargs='+')
def main(args=None, app=None):
'''Main routine of :program:`qvm-kill`.
@ -42,6 +41,8 @@ def main(args=None, app=None):
for domain in args.domains:
try:
domain.kill()
except qubesadmin.exc.QubesVMNotStartedError:
pass
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
exit_code = 1
parser.print_error(str(e))