[virt-tools-list] [PATCH 3 of 4] graphics: add spice channel configuration

Marc-André Lureau marcandre.lureau at redhat.com
Wed Nov 17 15:54:58 UTC 2010


# HG changeset patch
# User Marc-André Lureau <marcandre.lureau at redhat.com>
# Date 1289999260 -3600
# Node ID 51fa3f6bbf1612a124eeb30d8311ae2b98ec30f5
# Parent  7a18947b3a1421a7dcfd6f3bf9cf570b058d7e10
graphics: add spice channel configuration

diff -r 7a18947b3a14 -r 51fa3f6bbf16 tests/xmlparse-xml/change-graphics-in.xml
--- a/tests/xmlparse-xml/change-graphics-in.xml	Wed Nov 17 13:08:13 2010 +0100
+++ b/tests/xmlparse-xml/change-graphics-in.xml	Wed Nov 17 14:07:40 2010 +0100
@@ -27,6 +27,11 @@
     <graphics type="sdl" xauth="/tmp/.Xauthority" display="1:2"/>
     <graphics type="rdp"/>
     <graphics type="vnc" port="-1"/>
+    <graphics type="spice" passwd="foobar" port="100" tlsPort="101" listen="0.0.0.0">
+      <channel name='inputs' mode='insecure'/>
+      <channel name='main' mode='secure'/>
+      <channel name='record' mode='any'/>
+    </graphics>
   </devices>
   <seclabel type="static" model="selinux">
     <label>foolabel</label>
diff -r 7a18947b3a14 -r 51fa3f6bbf16 tests/xmlparse-xml/change-graphics-out.xml
--- a/tests/xmlparse-xml/change-graphics-out.xml	Wed Nov 17 13:08:13 2010 +0100
+++ b/tests/xmlparse-xml/change-graphics-out.xml	Wed Nov 17 14:07:40 2010 +0100
@@ -27,6 +27,11 @@
     <graphics type="sdl" xauth="/tmp/.Xauthority" display="1:2"/>
     <graphics type="rdp"/>
     <graphics type="vnc" port="-1"/>
+    <graphics type="spice" passwd="newpass" port="6000" tlsPort="6001" listen="1.2.3.4">
+      <channel name="inputs" mode="secure"/>
+      <channel name="main" mode="any"/>
+      <channel name="record" mode="insecure"/>
+    </graphics>
   </devices>
   <seclabel type="static" model="selinux">
     <label>foolabel</label>
diff -r 7a18947b3a14 -r 51fa3f6bbf16 tests/xmlparse.py
--- a/tests/xmlparse.py	Wed Nov 17 13:08:13 2010 +0100
+++ b/tests/xmlparse.py	Wed Nov 17 14:07:40 2010 +0100
@@ -390,6 +390,7 @@
         dev2 = guest.get_devices("graphics")[1]
         dev3 = guest.get_devices("graphics")[2]
         dev4 = guest.get_devices("graphics")[3]
+        dev5 = guest.get_devices("graphics")[4]
 
         check = self._make_checker(dev1)
         check("type", "vnc")
@@ -407,6 +408,16 @@
         check("type", "vnc")
         check("port", -1)
 
+        check = self._make_checker(dev5)
+        check("type", "spice")
+        check("passwd", "foobar", "newpass")
+        check("port", 100, 6000)
+        check("tlsPort", 101, 6001)
+        check("listen", "0.0.0.0", "1.2.3.4")
+        check("channel_inputs_mode", "insecure", "secure")
+        check("channel_main_mode", "secure", "any")
+        check("channel_record_mode", "any", "insecure")
+
         self._alter_compare(guest.get_config_xml(), outfile)
 
     def testAlterVideos(self):
diff -r 7a18947b3a14 -r 51fa3f6bbf16 virtinst/VirtualGraphics.py
--- a/virtinst/VirtualGraphics.py	Wed Nov 17 13:08:13 2010 +0100
+++ b/virtinst/VirtualGraphics.py	Wed Nov 17 14:07:40 2010 +0100
@@ -36,11 +36,25 @@
     TYPE_SPICE = "spice"
     types = [TYPE_VNC, TYPE_SDL, TYPE_RDP, TYPE_SPICE]
 
+    CHANNEL_TYPE_MAIN     = "main"
+    CHANNEL_TYPE_DISPLAY  = "display"
+    CHANNEL_TYPE_INPUTS   = "inputs"
+    CHANNEL_TYPE_CURSOR   = "cursor"
+    CHANNEL_TYPE_PLAYBACK = "playback"
+    CHANNEL_TYPE_RECORD   = "record"
+    channel_types = [CHANNEL_TYPE_MAIN, CHANNEL_TYPE_DISPLAY, CHANNEL_TYPE_INPUTS,
+                     CHANNEL_TYPE_CURSOR, CHANNEL_TYPE_PLAYBACK, CHANNEL_TYPE_RECORD]
+
+    CHANNEL_MODE_SECURE   = "secure"
+    CHANNEL_MODE_INSECURE = "insecure"
+    CHANNEL_MODE_ANY      = "any"
+    channel_modes = [CHANNEL_MODE_SECURE, CHANNEL_MODE_INSECURE, CHANNEL_MODE_ANY]
+
     KEYMAP_LOCAL = "local"
 
     def __init__(self, type=TYPE_VNC, port=-1, listen=None, passwd=None,
                  keymap=None, conn=None, parsexml=None, parsexmlnode=None,
-                 tlsPort=-1):
+                 tlsPort=-1, channels={}):
 
         VirtualDevice.VirtualDevice.__init__(self, conn,
                                              parsexml, parsexmlnode)
@@ -51,6 +65,7 @@
         self._listen = None
         self._passwd = None
         self._keymap = None
+        self._channels = {}
 
         if self._is_parse():
             return
@@ -61,6 +76,8 @@
         self.keymap = keymap
         self.listen = listen
         self.passwd = passwd
+        self.channels = channels
+
 
     def _default_keymap(self):
         if (self.conn and
@@ -160,6 +177,21 @@
                             get_converter=int,
                             xpath="./@tlsPort")
 
+    def _get_mode_prop(channel_type, channel_mode=None):
+        xpath = "./channel[@name='%s']/@mode" % channel_type
+        def get_mode(self):
+            return self._channels.get(channel_type, None)
+        def set_mode(self, val):
+            self._channels[channel_type] = val
+        return _xml_property(get_mode, set_mode, xpath=xpath)
+
+    channel_main_mode = _get_mode_prop(CHANNEL_TYPE_MAIN)
+    channel_display_mode = _get_mode_prop(CHANNEL_TYPE_DISPLAY)
+    channel_inputs_mode = _get_mode_prop(CHANNEL_TYPE_INPUTS)
+    channel_cursor_mode = _get_mode_prop(CHANNEL_TYPE_CURSOR)
+    channel_playback_mode = _get_mode_prop(CHANNEL_TYPE_PLAYBACK)
+    channel_record_mode = _get_mode_prop(CHANNEL_TYPE_RECORD)
+
     def valid_keymaps(self):
         """
         Return a list of valid keymap values.




More information about the virt-tools-list mailing list