Skip to content

Commit e13bc1a

Browse files
committed
Merge remote-tracking branch 'origin/pr/460'
* origin/pr/460: qvm-start-daemon: skip GUI/AUDIO for dead domain Pull request description: Fixes QubesOS/qubes-issues#10793 `qvm-start-daemon` may attempt to start GUI and AUDIO daemons for a domain that has already terminated early, resulting in an invalid XID (`-1`) being passed to `qubes-guid` and `pacat-simple-vchan`. Add checks to ensure the VM is still running and the XID is valid (>= 0) before spawning daemons. This prevents errors and handles race conditions where the domain terminates between event handling and daemon startup.
2 parents d8a91cd + fa79045 commit e13bc1a

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

qubesadmin/tools/qvm_start_daemon.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,14 @@ async def start_gui_for_vm(self, vm, monitor_layout=None):
725725
"""
726726
if getattr(vm, "is_preload", False):
727727
return
728+
729+
if vm.xid < 0:
730+
vm.log.warning(
731+
"Skipping GUI start: invalid XID (%s)",
732+
vm.xid,
733+
)
734+
return
735+
728736
guid_cmd = self.common_guid_args(vm)
729737
guid_cmd.extend(["-d", str(vm.xid)])
730738

@@ -753,6 +761,15 @@ async def start_gui_for_stubdomain(self, vm, force=False):
753761
"""
754762
if getattr(vm, "is_preload", False):
755763
return
764+
765+
stubdom_xid = getattr(vm, "stubdom_xid", -1)
766+
if stubdom_xid < 0:
767+
vm.log.warning(
768+
"Skipping stubdomain GUI start: invalid stubdom XID (%s)",
769+
stubdom_xid,
770+
)
771+
return
772+
756773
want_stubdom = force
757774
if not want_stubdom and vm.features.check_with_template(
758775
"gui-emulated", False
@@ -786,10 +803,19 @@ async def start_audio_for_vm(self, vm):
786803
"""
787804
if getattr(vm, "is_preload", False):
788805
return
806+
807+
xid = self.pacat_domid(vm)
808+
if xid < 0:
809+
vm.log.warning(
810+
"Skipping AUDIO start: invalid XID (%s)",
811+
xid,
812+
)
813+
return
814+
789815
pacat_cmd = [
790816
PACAT_DAEMON_PATH,
791817
"-l",
792-
str(self.pacat_domid(vm)),
818+
str(xid),
793819
vm.name,
794820
]
795821
vm.log.info("Starting AUDIO")

0 commit comments

Comments
 (0)