[virt-tools-list] [virt-manager PATCH 1/4] graphics: set default port only for correct listen types

Pavel Hrdina phrdina at redhat.com
Wed Sep 6 08:35:58 UTC 2017


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 at redhat.com>
---
 tests/cli-test-xml/compare/virt-install-many-devices.xml | 2 +-
 virtinst/devicegraphics.py                               | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml
index 11a0771b..d0ab6eec 100644
--- a/tests/cli-test-xml/compare/virt-install-many-devices.xml
+++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml
@@ -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"/>
diff --git a/virtinst/devicegraphics.py b/virtinst/devicegraphics.py
index ac69df5e..d7f04535 100644
--- a/virtinst/devicegraphics.py
+++ b/virtinst/devicegraphics.py
@@ -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):
-- 
2.13.5




More information about the virt-tools-list mailing list