domain: Add idx parameter to open_graphics_fd()

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 <jiangfeng@kylinos.cn>
Signed-off-by: Ming Xie <xieming@kylinos.cn>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Feng Jiang 2023-01-30 15:36:04 +08:00 committed by Cole Robinson
parent 9c242ef79c
commit d83074a001
4 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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():

View File

@ -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: