tools: adjust qvm-start message and logic, update tests
QubesOS/qubes-issues#3130
This commit is contained in:
parent
bf4c9bacb4
commit
0187588531
@ -32,6 +32,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.Start', None, None)] = b'0\x00'
|
||||
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app)
|
||||
@ -56,14 +59,12 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
self.assertAllCalled()
|
||||
|
||||
def test_003_already_running(self):
|
||||
# TODO: some option to ignore this error?
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.Start', None, None)] = \
|
||||
b'2\x00QubesVMNotHaltedError\x00\x00Domain is running: ' \
|
||||
b'some-vm\x00'
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Runnin\n'
|
||||
self.assertEqual(
|
||||
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app),
|
||||
1)
|
||||
@ -74,6 +75,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.device.block.Available', None, None)] = \
|
||||
b'0\x00sr0\n'
|
||||
@ -94,6 +98,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.device.block.Available', None, None)] = \
|
||||
b'0\x00sdb1\n'
|
||||
@ -114,6 +121,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.device.block.Available', None, None)] = \
|
||||
b'0\x00sdb1\n'
|
||||
@ -135,6 +145,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
('dom0', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('dom0', 'admin.vm.device.block.Available', None, None)] = \
|
||||
b'0\x00loop12\n'
|
||||
@ -161,6 +174,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'other-vm class=AppVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('other-vm', 'admin.vm.device.block.Available', None, None)] = \
|
||||
b'0\x00loop7\n'
|
||||
@ -191,6 +207,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'other-vm class=AppVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.device.block.Attach', 'other-vm+loop7',
|
||||
b'devtype=cdrom persistent=True read-only=True')] = b'0\x00'
|
||||
@ -212,6 +231,9 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
|
||||
b'0\x00dom0 class=AdminVM state=Running\n' \
|
||||
b'other-vm class=AppVM state=Running\n' \
|
||||
b'some-vm class=AppVM state=Running\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.List', None, None)] = \
|
||||
b'0\x00some-vm class=AppVM state=Halted\n'
|
||||
self.app.expected_calls[
|
||||
('some-vm', 'admin.vm.device.block.Attach', 'other-vm+loop7',
|
||||
b'devtype=cdrom persistent=True read-only=True')] = \
|
||||
|
@ -147,11 +147,12 @@ def main(args=None, app=None):
|
||||
|
||||
exit_code = 0
|
||||
for domain in args.domains:
|
||||
if args.skip_if_running and domain.is_running():
|
||||
continue
|
||||
elif domain.is_running():
|
||||
if domain.is_running():
|
||||
if args.skip_if_running:
|
||||
continue
|
||||
exit_code = 1
|
||||
parser.print_error("domain is already running")
|
||||
parser.print_error(
|
||||
'domain {} is already running'.format(domain.name))
|
||||
return exit_code
|
||||
drive_assignment = None
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user