Skip to content

Commit 1b7fd4b

Browse files
committed
Fail early on missing necessary preload service
Occurs when the global max preload feature, set on dom0, with the default-dispvm being an unsupported template, or old ISOs, old templates, downgraded templates or packages. When setting the dom0 feature or 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. For: QubesOS/qubes-issues#1512
1 parent d95888b commit 1b7fd4b

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

qubes/vm/mix/dvmtemplate.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ def on_feature_pre_set_preload_dispvm_max(
103103
raise qubes.exc.QubesValueError("Qube does not support qrexec")
104104

105105
service = "qubes.WaitForRunningSystem"
106-
supported_service = "supported-rpc." + service
107-
if not self.features.check_with_template(supported_service, False):
106+
if not self.supports_preload():
108107
raise qubes.exc.QubesValueError(
109108
"Qube does not support the RPC '%s'" % service
110109
)
@@ -265,6 +264,13 @@ async def on_domain_preload_dispvm_used(
265264
event_log += " because %s" % str(kwargs.get("reason"))
266265
self.log.info(event_log)
267266

267+
service = "qubes.WaitForRunningSystem"
268+
if not self.supports_preload():
269+
raise qubes.exc.QubesValueError(
270+
"Qube does not support the RPC '%s' but tried to preload, "
271+
"check if template is outdated" % service
272+
)
273+
268274
if event == "autostart":
269275
self.remove_preload_excess(0)
270276
elif not self.can_preload():
@@ -406,3 +412,12 @@ def remove_preload_excess(self, max_preload: Optional[int] = None) -> None:
406412
if unwanted_disp in self.app.domains:
407413
dispvm = self.app.domains[unwanted_disp]
408414
asyncio.ensure_future(dispvm.cleanup())
415+
416+
def supports_preload(self) -> bool:
417+
"""Returns ``True`` if the necessary RPC is supported."""
418+
assert isinstance(self, qubes.vm.BaseVM)
419+
service = "qubes.WaitForRunningSystem"
420+
supported_service = "supported-rpc." + service
421+
if self.features.check_with_template(supported_service, False):
422+
return True
423+
return False

0 commit comments

Comments
 (0)