Skip to content

Commit 1cda417

Browse files
committed
Add Debug Console to Qui Domains systray widget
fixes: QubesOS/qubes-issues#9788
1 parent 7652c60 commit 1cda417

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

qui/tray/domains.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def __init__(self):
5252
self.icon_files = {
5353
"pause": "qubes-vm-pause",
5454
"terminal": "qubes-terminal",
55+
"debug": "qubes-info",
5556
"preferences": "qubes-vm-settings",
5657
"kill": "qubes-vm-kill",
5758
"shutdown": "qubes-vm-shutdown",
@@ -316,6 +317,32 @@ async def perform_action(self):
316317
)
317318

318319

320+
class RunDebugConsoleItem(VMActionMenuItem):
321+
"""Run Debug Console menu Item. When activated runs a qvm-console-dispvm."""
322+
323+
def __init__(self, vm, icon_cache):
324+
super().__init__(
325+
vm,
326+
label=_("Debug Console"),
327+
icon_cache=icon_cache,
328+
icon_name="debug",
329+
)
330+
331+
async def perform_action(self):
332+
try:
333+
proc = await asyncio.create_subprocess_exec(
334+
"qvm-console-dispvm", self.vm.name, stderr=subprocess.PIPE
335+
)
336+
_stdout, stderr = await proc.communicate()
337+
if proc.returncode != 0:
338+
raise exc.QubesException(stderr)
339+
except exc.QubesException as ex:
340+
show_error(
341+
_(f"Error connecting the debug console to {self.vm.name}"),
342+
_("{0}").format(str(ex)),
343+
)
344+
345+
319346
class OpenFileManagerItem(VMActionMenuItem):
320347
"""Attempts to open a file manager in the VM. If fails, displays an
321348
error message."""
@@ -368,6 +395,12 @@ def __init__(self, vm, app, icon_cache):
368395

369396
self.add(OpenFileManagerItem(self.vm, icon_cache))
370397
self.add(RunTerminalItem(self.vm, icon_cache))
398+
if (
399+
self.app.wizard_mode
400+
or not getattr(self.vm, "guivm")
401+
or getattr(self.vm, "debug")
402+
):
403+
self.add(RunDebugConsoleItem(self.vm, icon_cache))
371404
self.add(PreferencesItem(self.vm, icon_cache))
372405
self.add(PauseItem(self.vm, icon_cache))
373406
self.add(ShutdownItem(self.vm, icon_cache))
@@ -668,6 +701,11 @@ def __init__(self, app_name, qapp, dispatcher, stats_dispatcher):
668701
self.set_application_id(app_name)
669702
self.register() # register Gtk Application
670703

704+
# to display debug console for all qubes
705+
self.wizard_mode = self.qapp.domains["dom0"].features.get(
706+
"wizard-mode", False
707+
)
708+
671709
def register_events(self):
672710
self.dispatcher.add_handler("connection-established", self.refresh_all)
673711
self.dispatcher.add_handler("domain-pre-start", self.update_domain_item)

0 commit comments

Comments
 (0)