graphics: set default port only for correct listen types

The default port and tlsPort should be configured only if no listen
type was specified or the listen type is "address" or "network".
For other listen types the port and tlsPort doesn't make sense.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2017-09-06 10:14:35 +02:00
parent f14b1f88a0
commit ccaef8c16a
2 changed files with 6 additions and 3 deletions

View File

@ -234,7 +234,7 @@
<mouse mode="client"/>
<filetransfer enable="yes"/>
</graphics>
<graphics type="spice" port="-1" tlsPort="-1" autoport="yes">
<graphics type="spice">
<gl enable="yes"/>
<image compression="off"/>
<listen type="socket"/>

View File

@ -144,12 +144,15 @@ class VirtualGraphics(VirtualDevice):
val = _validate_port("TLS Port", val)
self.autoport = self._get_default_autoport()
return val
def _listen_need_port(self):
listen = self.get_first_listen_type()
return not listen or listen in ["address", "network"]
def _get_default_port(self):
if self.type == "vnc" or self.type == "spice":
if (self.type == "vnc" or self.type == "spice") and self._listen_need_port():
return -1
return None
def _get_default_tlsport(self):
if self.type == "spice":
if self.type == "spice" and self._listen_need_port():
return -1
return None
def _get_default_autoport(self):