Skip to content

Commit 4fb5be9

Browse files
committed
Fail early on missing necessary preload service
When switching the default-dispvm, there is no supported-rpc validation. Without this validation, it tries to preload and fails on startup validation. Raise exception early. It can happen also a packages in the template has been downgraded. For: QubesOS/qubes-issues#1512
1 parent 8de4cd0 commit 4fb5be9

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

qubes/vm/mix/dvmtemplate.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ def on_feature_pre_set_preload_dispvm_max(
124124
raise qubes.exc.QubesValueError("Qube does not support qrexec")
125125

126126
service = "qubes.WaitForRunningSystem"
127-
supported_service = "supported-rpc." + service
128-
if not self.features.check_with_template(supported_service, False):
127+
if not self.supports_preload():
129128
raise qubes.exc.QubesValueError(
130129
"Qube does not support the RPC '%s'" % service
131130
)
@@ -283,7 +282,12 @@ async def on_domain_preload_dispvm_used(
283282
if delay:
284283
event_log += " with a delay of %s second(s)" % f"{delay:.1f}"
285284
self.log.info(event_log)
286-
285+
service = "qubes.WaitForRunningSystem"
286+
if not self.supports_preload():
287+
raise qubes.exc.QubesValueError(
288+
"Qube does not support the RPC '%s' but tried to preload, "
289+
"check if template is outdated" % service
290+
)
287291
if delay:
288292
await asyncio.sleep(delay)
289293

@@ -460,3 +464,12 @@ def remove_preload_excess(self, max_preload: Optional[int] = None) -> None:
460464
if unwanted_disp in self.app.domains:
461465
dispvm = self.app.domains[unwanted_disp]
462466
asyncio.ensure_future(dispvm.cleanup())
467+
468+
def supports_preload(self) -> bool:
469+
"""Returns ``True`` if the necessary RPC is supported."""
470+
assert isinstance(self, qubes.vm.BaseVM)
471+
service = "qubes.WaitForRunningSystem"
472+
supported_service = "supported-rpc." + service
473+
if self.features.check_with_template(supported_service, False):
474+
return True
475+
return False

0 commit comments

Comments
 (0)