console: Error for more non-working graphical configs

- If connecting remotely but graphics has no listen address,
    like the spice GL case.
- Trying to connect to a TLS using VM over an ssh tunnel, it doesn't
    seem to work: https://bugzilla.redhat.com/show_bug.cgi?id=1320331
This commit is contained in:
Cole Robinson 2016-05-18 16:57:38 -04:00
parent 0f88ebbc0b
commit 8c2adb83ae
3 changed files with 22 additions and 17 deletions

View File

@ -710,14 +710,6 @@ class vmmConsolePages(vmmGObjectUI):
self._activate_unavailable_page(msg)
return
if ginfo.is_bad_localhost():
self._activate_unavailable_page(
_("Guest is on a remote host with transport '%s' "
"but is only configured to listen locally. "
"Connect using 'ssh' transport or change the"
"guest's listen address." % ginfo.transport))
return
self._activate_unavailable_page(
_("Connecting to graphical console for guest"))

View File

@ -59,20 +59,30 @@ class ConnectionInfo(object):
except:
return False
def _is_listen_none(self):
return not (self.gsocket or self.gport or self.gtlsport)
def need_tunnel(self):
if not self._is_listen_localhost():
return False
return self.transport == "ssh"
def is_bad_localhost(self):
"""
Return True if the guest is listening on localhost, but the libvirt
URI doesn't give us any way to tunnel the connection
"""
if self.need_tunnel():
return False
host, ignore, ignore = self.get_conn_host()
return self.transport and self._is_listen_localhost(host)
def bad_config(self):
if self.transport and self._is_listen_none():
return _("Guest is on a remote host, but is only configured "
"to allow local file descriptor connections.")
if self.need_tunnel() and (self.gtlsport and not self.gport):
return _("Guest is configured for TLS only which does not "
"work over SSH.")
if (not self.need_tunnel() and
self.transport and
self._is_listen_localhost(self.get_conn_host()[0])):
return _("Guest is on a remote host with transport '%s' "
"but is only configured to listen locally. "
"To connect remotely you will need to change the guest's "
"listen address." % self.transport)
def get_conn_host(self):
"""

View File

@ -156,6 +156,9 @@ class Viewer(vmmGObject):
return self._vm.open_graphics_fd()
def _open(self):
if self._ginfo.bad_config():
raise RuntimeError(self._ginfo.bad_config())
fd = self._get_fd_for_open()
if fd is not None:
self._open_fd(fd)