mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
viewer: move vm from ConnectionInfo to Viewer
I don't really like the VM in Viewer either, since it will encourage layering violations, but it's a better fit than in ConnectionInfo
This commit is contained in:
parent
bd725d6cfe
commit
7cc6141618
@ -621,7 +621,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
gdevs = self.vm.get_graphics_devices()
|
||||
gdev = gdevs and gdevs[0] or None
|
||||
if gdev:
|
||||
ginfo = ConnectionInfo(self.vm, gdev)
|
||||
ginfo = ConnectionInfo(self.vm.conn, gdev)
|
||||
except Exception, e:
|
||||
# We can fail here if VM is destroyed: xen is a bit racy
|
||||
# and can't handle domain lookups that soon after
|
||||
@ -667,7 +667,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
"SpiceClientGtk missing")
|
||||
|
||||
|
||||
self._viewer = viewer_class(ginfo)
|
||||
self._viewer = viewer_class(self.vm, ginfo)
|
||||
self._connect_viewer_signals()
|
||||
|
||||
self._refresh_enable_accel()
|
||||
|
@ -32,9 +32,7 @@ class ConnectionInfo(object):
|
||||
"""
|
||||
Holds all the bits needed to make a connection to a graphical console
|
||||
"""
|
||||
def __init__(self, vm, gdev):
|
||||
conn = vm.conn
|
||||
self.vm = vm
|
||||
def __init__(self, conn, gdev):
|
||||
self.gtype = gdev.type
|
||||
self.gport = gdev.port and str(gdev.port) or None
|
||||
self.gsocket = gdev.socket
|
||||
@ -49,9 +47,6 @@ class ConnectionInfo(object):
|
||||
if self._connhost == "localhost":
|
||||
self._connhost = "127.0.0.1"
|
||||
|
||||
def get_conn_fd(self):
|
||||
return self.vm.open_graphics_fd()
|
||||
|
||||
def _is_listen_localhost(self, host=None):
|
||||
try:
|
||||
return ipaddr.IPNetwork(host or self.gaddr).is_loopback
|
||||
|
@ -64,9 +64,10 @@ class Viewer(vmmGObject):
|
||||
"usb-redirect-error": (GObject.SignalFlags.RUN_FIRST, None, [str]),
|
||||
}
|
||||
|
||||
def __init__(self, ginfo):
|
||||
def __init__(self, vm, ginfo):
|
||||
vmmGObject.__init__(self)
|
||||
self._display = None
|
||||
self._vm = vm
|
||||
self._ginfo = ginfo
|
||||
self._tunnels = SSHTunnels(self._ginfo)
|
||||
|
||||
@ -84,6 +85,7 @@ class Viewer(vmmGObject):
|
||||
if self._display:
|
||||
self._display.destroy()
|
||||
self._display = None
|
||||
self._vm = None
|
||||
|
||||
self._tunnels.close_all()
|
||||
|
||||
@ -137,7 +139,7 @@ class Viewer(vmmGObject):
|
||||
def _get_fd_for_open(self):
|
||||
if self._ginfo.need_tunnel():
|
||||
return self._tunnels.open_new()
|
||||
return self._ginfo.get_conn_fd()
|
||||
return self._vm.open_graphics_fd()
|
||||
|
||||
def _open(self):
|
||||
fd = self._get_fd_for_open()
|
||||
|
Loading…
Reference in New Issue
Block a user