qvm-kill: make error message more clear

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

View File

@ -64,3 +64,17 @@ class TC_00_qvm_kill(qubesadmin.tests.QubesTestCase):
0)
self.assertAllCalled()
def test_004_other_error(self):
self.app.expected_calls[
('some-vm', 'admin.vm.Kill', None, None)] = \
b'2\x00QubesVMError\x00\x00Error message\x00'
self.app.expected_calls[
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
with qubesadmin.tests.tools.StderrBuffer() as stderr:
self.assertEqual(
qubesadmin.tools.qvm_kill.main(['some-vm'], app=self.app),
1)
self.assertAllCalled()
self.assertIn("Failed to kill 'some-vm': Error message",
stderr.getvalue())

View File

@ -45,7 +45,8 @@ def main(args=None, app=None):
pass
except (IOError, OSError, qubesadmin.exc.QubesException) as e:
exit_code = 1
parser.print_error(str(e))
parser.print_error("Failed to kill '{}': {}".format(
domain.name, e))
return exit_code