Subject: domain: Add idx parameter to open_graphics_fd() From: Feng Jiang jiangfeng@kylinos.cn Mon Jan 30 15:36:04 2023 +0800 Date: Sun Mar 3 12:52:20 2024 -0500: Git: d83074a001bc6cc7c01cb9a0a7c5d0b0764d2bf0 Now open_graphics_fd() always opens the 1st graphic device, when there are multiple graphic devices (e.g. spice + egl-headless), we need to specify the index number for libvirt. Signed-off-by: Feng Jiang Signed-off-by: Ming Xie Reviewed-by: Cole Robinson diff --git a/virtManager/details/console.py b/virtManager/details/console.py index 80c9c14e..15a76701 100644 --- a/virtManager/details/console.py +++ b/virtManager/details/console.py @@ -691,7 +691,7 @@ class vmmConsolePages(vmmGObjectUI): gdevs = self.vm.xmlobj.devices.graphics gdev = gdevs and gdevs[0] or None if gdev: - ginfo = ConnectionInfo(self.vm.conn, gdev) + ginfo = ConnectionInfo(self.vm.conn, gdev, 0) 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 diff --git a/virtManager/details/sshtunnels.py b/virtManager/details/sshtunnels.py index cb7ca7c0..f2b37f5a 100644 --- a/virtManager/details/sshtunnels.py +++ b/virtManager/details/sshtunnels.py @@ -20,7 +20,8 @@ class ConnectionInfo(object): """ Holds all the bits needed to make a connection to a graphical console """ - def __init__(self, conn, gdev): + def __init__(self, conn, gdev, gidx): + self.gidx = gidx self.gtype = gdev.type self.gport = str(gdev.port) if gdev.port else None self.gsocket = (gdev.listens and gdev.listens[0].socket) or gdev.socket diff --git a/virtManager/details/viewers.py b/virtManager/details/viewers.py index 2a8a7857..e1ec2e62 100644 --- a/virtManager/details/viewers.py +++ b/virtManager/details/viewers.py @@ -134,7 +134,7 @@ class Viewer(vmmGObject): if not self._vm.conn.support.domain_open_graphics(): return None - return self._vm.open_graphics_fd() + return self._vm.open_graphics_fd(self._ginfo.gidx) def _open(self): if self._ginfo.bad_config(): diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py index 1989a148..c5443c52 100644 --- a/virtManager/object/domain.py +++ b/virtManager/object/domain.py @@ -1164,9 +1164,9 @@ class vmmDomain(vmmLibvirtObject): def open_console(self, devname, stream, flags=0): return self._backend.openConsole(devname, stream, flags) - def open_graphics_fd(self): + def open_graphics_fd(self, idx): flags = 0 - return self._backend.openGraphicsFD(0, flags) + return self._backend.openGraphicsFD(idx, flags) def list_snapshots(self): if self._snapshot_list is None: