Skip to content

Commit ec5e1b2

Browse files
committed
Skip RemoteVM when suspending the system
Perform suspend-related actions only on LocalVMs. Fixes QubesOS/qubes-issues#11001
1 parent 9fa3b63 commit ec5e1b2

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

qubes/api/internal.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ async def suspend_pre(self):
310310
for vm in self.app.domains:
311311
if isinstance(vm, qubes.vm.adminvm.AdminVM):
312312
continue
313+
if not isinstance(vm, qubes.vm.LocalVM):
314+
continue
313315
if not vm.is_running():
314316
continue
315317
if vm.name in previously_paused:
@@ -352,6 +354,8 @@ async def suspend_pre(self):
352354
for vm in self.app.domains:
353355
if isinstance(vm, qubes.vm.adminvm.AdminVM):
354356
continue
357+
if not isinstance(vm, qubes.vm.LocalVM):
358+
continue
355359
if vm.name in previously_paused:
356360
continue
357361
if vm.is_running():
@@ -395,6 +399,8 @@ async def suspend_post(self):
395399
for vm in self.app.domains:
396400
if isinstance(vm, qubes.vm.adminvm.AdminVM):
397401
continue
402+
if not isinstance(vm, qubes.vm.LocalVM):
403+
continue
398404
if vm.name in previously_paused:
399405
continue
400406
if vm.get_power_state() in ["Paused", "Suspended"]:
@@ -407,6 +413,8 @@ async def suspend_post(self):
407413
for vm in self.app.domains:
408414
if isinstance(vm, qubes.vm.adminvm.AdminVM):
409415
continue
416+
if not isinstance(vm, qubes.vm.LocalVM):
417+
continue
410418
if not vm.is_running():
411419
continue
412420
if vm.name in previously_paused:

qubes/tests/api_internal.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,19 @@ def tearDown(self):
6464
def create_mockvm(self, features=None):
6565
if features is None:
6666
features = {}
67-
vm = mock.Mock()
67+
vm = mock.Mock(spec=qubes.vm.LocalVM)
68+
vm.configure_mock(
69+
features=mock.Mock(),
70+
run_service=mock.AsyncMock(),
71+
suspend=mock.AsyncMock(),
72+
resume=mock.AsyncMock(),
73+
is_running=mock.Mock(),
74+
get_power_state=mock.Mock(),
75+
remove_preload_excess=mock.Mock(),
76+
)
6877
vm.features.check_with_template.side_effect = features.get
6978
vm.features.get.side_effect = features.get
70-
vm.run_service.return_value.wait = mock_coro(
71-
vm.run_service.return_value.wait
72-
)
73-
vm.run_service = mock_coro(vm.run_service)
74-
vm.suspend = mock_coro(vm.suspend)
75-
vm.resume = mock_coro(vm.resume)
79+
vm.run_service.return_value.wait = mock.AsyncMock()
7680
return vm
7781

7882
def call_mgmt_func(self, method, arg=b"", payload=b""):

0 commit comments

Comments
 (0)