console: allow localhost connections over TCP

Fix console config validation for an edge case where both libvirt and
Spice/VNC TCP connection are on localhost. Transport over TCP does not
necessarily mean that libvirt connection is to a remote host.

Compare libvirt and graphics device addresses to localhost individually.
Raise an error only when guest device is bound to localhost but libvirt
connection is non-local (remote).

Validation that prevents fully local TCP seems to go back all the way to
bc13c302de ("console: Warn if qemu+tcp URI and listen == 127.0.0.1").

Signed-off-by: Sami Loone <sloone@forcepoint.com>
This commit is contained in:
Sami Loone 2023-10-09 13:53:11 +02:00 committed by Cole Robinson
parent 258df88eab
commit 380af310e7

View File

@ -70,7 +70,8 @@ class ConnectionInfo(object):
if (not self.need_tunnel() and
self.transport and
self._is_listen_localhost(self.get_conn_host()[0])):
self._is_listen_localhost() and
not self._is_listen_localhost(self._connhost)):
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 "