Skip to content

Commit 34d090c

Browse files
committed
Merge remote-tracking branch 'origin/pr/711'
* origin/pr/711: Fail early on missing necessary preload service Pull request description: Occurs when the global max preload feature, set on dom0, with the default-dispvm being an unsupported template, which can happen on 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. Handle gracefully in case the qube is the default-dispvm and the global max feature is set. Without this validation, it tries to preload and fails on startup check of the same supported-rpc, but this time, running it as a service. For: QubesOS/qubes-issues#1512 Without it, doesn't break anything, but a minor annoyance of failing the `qubes-preload-dispvm.service` and `qubesd` logs and the preloads trying to start to just fail. This has more chance of happening with the global preload feature as it doesn't check if the default-dispvm supports the necessary RPC service.
2 parents db71280 + 4fb5be9 commit 34d090c

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)