[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 1 of 5] graphics: add SPICE support



# HG changeset patch
# User Marc-André Lureau <marcandre lureau redhat com>
# Date 1289838349 -3600
# Node ID 111496a17d77102329cb4292186058e7fc3414a3
# Parent  b2eec170e9fab6d1c920fd8e2f29cc7c3299d59d
graphics: add SPICE support

diff -r b2eec170e9fa -r 111496a17d77 virtinst/VirtualGraphics.py
--- a/virtinst/VirtualGraphics.py	Wed Oct 27 13:11:47 2010 -0400
+++ b/virtinst/VirtualGraphics.py	Mon Nov 15 17:25:49 2010 +0100
@@ -33,18 +33,21 @@
     TYPE_SDL = "sdl"
     TYPE_VNC = "vnc"
     TYPE_RDP = "rdp"
-    types = [TYPE_VNC, TYPE_SDL, TYPE_RDP]
+    TYPE_SPICE = "spice"
+    types = [TYPE_VNC, TYPE_SDL, TYPE_RDP, TYPE_SPICE]
 
     KEYMAP_LOCAL = "local"
 
     def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
-                 keymap=None, conn=None, parsexml=None, parsexmlnode=None):
+                 keymap=None, conn=None, parsexml=None, parsexmlnode=None,
+                 tlsPort=-1):
 
         VirtualDevice.VirtualDevice.__init__(self, conn,
                                              parsexml, parsexmlnode)
 
         self._type   = None
         self._port   = None
+        self._tlsPort= None
         self._listen = None
         self._passwd = None
         self._keymap = None
@@ -54,6 +57,7 @@
 
         self.type = type
         self.port = port
+        self.tlsPort = tlsPort
         self.keymap = keymap
         self.listen = listen
         self.passwd = passwd
@@ -136,6 +140,26 @@
     passwd = _xml_property(get_passwd, set_passwd,
                            xpath="./@passwd")
 
+    def get_tlsPort(self):
+        return self._tlsPort
+    def set_tlsPort(self, val):
+        if val is None:
+            val = -1
+
+        try:
+            val = int(val)
+        except:
+            pass
+
+        if (type(val) is not int or
+            (val != -1 and (val < 5900 or val > 65535))):
+            raise ValueError(_("TLS port must be a number between "
+                               "5900 and 65535, or -1 for auto allocation"))
+        self._tlsPort = val
+    tlsPort = _xml_property(get_tlsPort, set_tlsPort,
+                            get_converter=int,
+                            xpath="./@tlsPort")
+
     def valid_keymaps(self):
         """
         Return a list of valid keymap values.
@@ -162,9 +186,30 @@
         return """    <graphics type='sdl' display='%s' xauth='%s'/>""" % \
                (disp, xauth)
 
-    def _get_xml_config(self):
-        if self._type == self.TYPE_SDL:
-            return self._sdl_config()
+    def _spice_config(self):
+        autoportxml = ""
+        keymapxml = ""
+        listenxml = ""
+        passwdxml = ""
+        if self._port == -1 or self._tlsPort == -1:
+            autoportxml = "autoport='yes'"
+        if self.keymap:
+            keymapxml = " keymap='%s'" % self._keymap
+        if self.listen:
+            listenxml = " listen='%s'" % self._listen
+        if self.passwd:
+            passwdxml = " passwd='%s'" % self._passwd
+
+        xml = "    <graphics type='spice' " + \
+                   "port='%(port)d' " % { "port" : self._port } + \
+                   "tlsPort='%(tlsPort)d' " % { "tlsPort" : self._tlsPort } + \
+                   "%(autoport)s " % { "autoport" : autoportxml } + \
+                   "%(keymapxml)s " % { "keymapxml" : keymapxml } + \
+                   "%(listenxml)s " % { "listenxml" : listenxml } + \
+                   "%(passwdxml)s/>" % { "passwdxml" : passwdxml }
+        return xml
+
+    def _vnc_config(self):
         keymapxml = ""
         listenxml = ""
         passwdxml = ""
@@ -181,3 +226,13 @@
                    "%(passwdxml)s"   % { "passwdxml" : passwdxml } + \
                    "/>"
         return xml
+
+    def _get_xml_config(self):
+        if self._type == self.TYPE_SDL:
+            return self._sdl_config()
+        if self._type == self.TYPE_SPICE:
+            return self._spice_config()
+        if self._type == self.TYPE_VNC:
+            return self._vnc_config()
+        else:
+            raise ValueError(_("Unknown graphics type"))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]