Skip to content

Commit f88fdec

Browse files
committed
Late GUID for preloaded disposables
- Autostarted applications don't show when preloading; and - Preloaded qubes paused before the session will have a working GUI when the session starts. For: QubesOS/qubes-issues#1512 For: QubesOS/qubes-issues#9940 For: QubesOS/qubes-issues#9907 Requires: QubesOS/qubes-core-admin-client#359
1 parent 78aacd1 commit f88fdec

File tree

6 files changed

+21
-63
lines changed

6 files changed

+21
-63
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ all:
179179

180180
install:
181181
ifeq ($(OS),Linux)
182-
$(MAKE) install -C linux/autostart
183182
$(MAKE) install -C linux/systemd
184183
$(MAKE) install -C linux/aux-tools
185184
$(MAKE) install -C linux/system-config

linux/autostart/Makefile

Lines changed: 0 additions & 6 deletions
This file was deleted.

linux/autostart/qubes-preload-dispvm.desktop

Lines changed: 0 additions & 9 deletions
This file was deleted.

qubes/vm/dispvm.py

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
8787
8888
- Full start: Preloaded disposable must only be interrupted
8989
(paused/suspended) or used after all basic services in it have been
90-
started. Autostarted applications allows user interaction before the it
91-
should, that is a bug.
90+
started. Failure to complete this step must remove the qube from the
91+
preload list.
9292
9393
- **Prevents accidental tampering**:
9494
@@ -102,12 +102,11 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
102102
GUI applications, that is a bug because features cannot be set before
103103
that event.
104104
105-
- Preloaded qubes must be marked as used when prior to being
106-
unpaused/resumed, even if it was not requested. The goal of
107-
pause/suspend in case of preloaded disposables is mostly detecting
108-
whether a qube was used or not, and not managing resource consumption;
109-
thus, even with abundant system resources, they should not be
110-
unpaused/resumed without being requested.
105+
- Preloaded qubes must be marked as used after being unpaused/resumed,
106+
even if it was not requested. The goal of pause/suspend in case of
107+
preloaded disposables is mostly detecting whether a qube was used or
108+
not, not managing resource consumption; thus, even with abundant system
109+
resources, they should not be unpaused/resumed without being requested.
111110
112111
**Features and properties relationship on stages**:
113112
@@ -136,14 +135,6 @@ class DispVM(qubes.vm.qubesvm.QubesVM):
136135
applicable). Only in this phase, GUI applications treat the qube as any
137136
other unnamed disposable and the qube object is returned to the caller if
138137
requested.
139-
140-
**Outstanding bugs**:
141-
142-
- GUI applications set to autostart can appear on the screen and be
143-
interactive for a brief moment before the qube is allowed to be used
144-
followed by a sudden freeze.
145-
- Can't interrupt qubes before the GUI session has started if the qube's
146-
usage will require a GUI (GUI daemon cannot handle an interrupted qube).
147138
"""
148139

149140
template = qubes.VMProperty(
@@ -341,43 +332,33 @@ async def on_domain_started_dispvm(
341332
"""
342333
if not self.is_preload:
343334
return
344-
# TODO: pause is late for autostarted GUI applications
345-
# https://github.com/QubesOS/qubes-issues/issues/9907
346335
timeout = self.qrexec_timeout
347-
gui = bool(self.guivm and self.features.get("gui", True))
348-
service = "qubes.WaitForSession"
349-
if not gui:
350-
# https://github.com/QubesOS/qubes-issues/issues/9964
351-
# service = "qubes.WaitForRunningSystem"
352-
rpc = "qubes.WaitForRunningSystem"
353-
path = "/run/qubes-rpc:/usr/local/etc/qubes-rpc:/etc/qubes-rpc"
354-
service = '$(PATH="' + path + '" command -v ' + rpc + ")"
336+
# https://github.com/QubesOS/qubes-issues/issues/9964
337+
rpc = "qubes.WaitForRunningSystem"
338+
path = "/run/qubes-rpc:/usr/local/etc/qubes-rpc:/etc/qubes-rpc"
339+
service = '$(PATH="' + path + '" command -v ' + rpc + ")"
355340
try:
356341
self.log.info(
357342
"Preload startup waiting '%s' with '%d' seconds timeout",
358343
service,
359344
timeout,
360345
)
361-
runner = self.run_service_for_stdio if gui else self.run_for_stdio
362346
await asyncio.wait_for(
363-
runner(
347+
self.run(
364348
service,
365349
stdout=subprocess.DEVNULL,
366350
stderr=subprocess.DEVNULL,
367351
),
368352
timeout=timeout,
369353
)
370354
except asyncio.TimeoutError:
371-
# TODO: if pause occurs before the GUI session starts (on boot
372-
# before login manager), results in an unusable GUI for the qube:
373-
# https://github.com/QubesOS/qubes-issues/issues/9940
374355
raise qubes.exc.QubesException(
375-
"Timed out Qrexec call to '%s' after '%d' seconds during "
376-
"preload startup" % (service, timeout)
356+
"Timed out call to '%s' after '%d' seconds during preload "
357+
"startup" % (service, timeout)
377358
)
378359
except (subprocess.CalledProcessError, qubes.exc.QubesException):
379360
raise qubes.exc.QubesException(
380-
"Error on Qrexec call to '%s' during preload startup" % service
361+
"Error on call to '%s' during preload startup" % service
381362
)
382363

383364
if not self.preload_requested:
@@ -397,11 +378,11 @@ def on_domain_paused(
397378
if self.is_preload:
398379
self.log.info("Paused preloaded qube")
399380

400-
@qubes.events.handler("domain-pre-unpaused")
401-
def on_domain_pre_unpaused(
381+
@qubes.events.handler("domain-unpaused")
382+
def on_domain_unpaused(
402383
self, event, **kwargs
403384
): # pylint: disable=unused-argument
404-
"""Mark preloaded domains as used before being unpaused."""
385+
"""Mark preloaded disposables as used."""
405386
# Qube start triggers unpause via 'libvirt_domain.resume()'.
406387
if self.is_preload and self.is_fully_usable():
407388
self.log.info("Unpaused preloaded qube will be marked as used")

qubes/vm/mix/dvmtemplate.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,10 @@ def on_feature_pre_set_preload_dispvm_max(
100100
if not self.features.check_with_template("qrexec", None):
101101
raise qubes.exc.QubesValueError("Qube does not support qrexec")
102102

103-
gui = bool(self.guivm and self.features.get("gui", True))
104-
if gui:
105-
service = "qubes.WaitForSession"
106-
else:
107-
service = "qubes.WaitForRunningSystem"
108-
supported_service = "supported-rpc." + service
109-
if not self.features.check_with_template(supported_service, False):
103+
service = "supported-rpc.qubes.WaitForRunningSystem"
104+
if not self.features.check_with_template(service, False):
110105
raise qubes.exc.QubesValueError(
111-
"Qube GUI is '%s' and does not support the RPC '%s'"
112-
% (gui, service)
106+
"Qube does not support the RPC '%s'" % service
113107
)
114108

115109
value = value or "0"

rpm_spec/core-dom0.spec.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,6 @@ done
368368
/usr/bin/qubes-*
369369
/usr/bin/qmemmand
370370
/usr/bin/qubesd*
371-
/etc/xdg/autostart/qubes-preload-dispvm.desktop
372371

373372
%{_mandir}/man1/qubes*.1*
374373

0 commit comments

Comments
 (0)