Subject: console: Select the first embeddable graphics device as graphical console
From: Feng Jiang jiangfeng@kylinos.cn Mon Jan 30 15:49:24 2023 +0800
Date: Sun Mar 3 12:52:20 2024 -0500:
Git: 409e4bf2d11829206d1fc784500ed1fd72a5735a
Currently, when there are multiple graphics devices, the first graphics
device is always selected as the graphical console. For the following
configuration:
virt-manager will report an error:
Cannot display graphical console type 'egl-headless'
The patch will iterate through all graphics devices to try to select the
first embeddable graphics device as graphical console.
Signed-off-by: Feng Jiang
Signed-off-by: Liming Sun
Reviewed-by: Cole Robinson
diff --git a/virtManager/details/console.py b/virtManager/details/console.py
index 15a76701..b3616bfb 100644
--- a/virtManager/details/console.py
+++ b/virtManager/details/console.py
@@ -221,15 +221,23 @@ class _ConsoleMenu:
from ..device.gfxdetails import vmmGraphicsDetails
ret = []
+ preferred = None
for idx, dev in enumerate(devs):
label = (_("Graphical Console") + " " +
vmmGraphicsDetails.graphics_pretty_type_simple(dev.type))
- tooltip = None
if idx > 0:
label += " %s" % (idx + 1)
+
+ tooltip = None
+ if dev.type not in self.embeddable_graphics():
+ tooltip = _("virt-manager cannot display graphical "
+ "console type '%s'") % (dev.type)
+ elif preferred is not None:
tooltip = _("virt-manager does not support more "
"than one graphical console")
+ else:
+ preferred = idx
ret.append([label, dev, tooltip])
return ret
@@ -689,9 +697,10 @@ class vmmConsolePages(vmmGObjectUI):
ginfo = None
try:
gdevs = self.vm.xmlobj.devices.graphics
- gdev = gdevs and gdevs[0] or None
- if gdev:
- ginfo = ConnectionInfo(self.vm.conn, gdev, 0)
+ for idx, dev in enumerate(gdevs):
+ if dev.type in self._consolemenu.embeddable_graphics():
+ ginfo = ConnectionInfo(self.vm.conn, gdevs[idx], idx)
+ break
except Exception as e: # pragma: no cover
# We can fail here if VM is destroyed: xen is a bit racy
# and can't handle domain lookups that soon after