[virt-tools-list] [PATCH v2 1/3] Add VirtualCharSpicevmcDevice

Marc-André Lureau marcandre.lureau at redhat.com
Thu Mar 17 17:06:33 UTC 2011


Here is an example of resulting XML:

    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0'/>
    </channel>

Updated since v1:
- splitted the address bits in a seperate patch
- added --channel spicevmc documentation in man/en/virt-install.pod.in
---
 man/en/virt-install.pod.in                |    7 +++++
 tests/xmlconfig-xml/boot-many-devices.xml |    3 ++
 tests/xmlconfig.py                        |    4 +++
 virtinst/VirtualCharDevice.py             |   42 ++++++++++++++++++++--------
 4 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/man/en/virt-install.pod.in b/man/en/virt-install.pod.in
index 38d42ce..0088727 100644
--- a/man/en/virt-install.pod.in
+++ b/man/en/virt-install.pod.in
@@ -907,6 +907,13 @@ can be any string, such as org.linux-kvm.virtioport1.
 If specified, this will be exposed in the guest at
 /sys/class/virtio-ports/vport0p1/NAME
 
+=item B<--channel spicevmc,target_type=virtio[,name=NAME]>
+
+Communication channel for QEMU spice agent, using virtio serial
+(requires 2.6.34 or later host and guest). NAME is optional metadata,
+and can be any string, such as the default com.redhat.spice.0 that
+specifies how the guest will see the channel.
+
 =back
 
 =item --console
diff --git a/tests/xmlconfig-xml/boot-many-devices.xml b/tests/xmlconfig-xml/boot-many-devices.xml
index 602419d..47479c6 100644
--- a/tests/xmlconfig-xml/boot-many-devices.xml
+++ b/tests/xmlconfig-xml/boot-many-devices.xml
@@ -57,6 +57,9 @@
     <parallel type='unix'>
       <source mode='bind' path='/tmp/foobar'/>
     </parallel>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0'/>
+    </channel>
     <sound model='sb16'/>
     <sound model='es1370'/>
     <video>
diff --git a/tests/xmlconfig.py b/tests/xmlconfig.py
index c281fad..5692cb5 100644
--- a/tests/xmlconfig.py
+++ b/tests/xmlconfig.py
@@ -892,8 +892,12 @@ class TestXMLConfig(unittest.TestCase):
                                                    VirtualCharDevice.DEV_PARALLEL,
                                                    VirtualCharDevice.CHAR_UNIX)
         cdev2.source_path = "/tmp/foobar"
+        cdev3 = VirtualCharDevice.get_dev_instance(g.conn,
+                                                   VirtualCharDevice.DEV_CHANNEL,
+                                                   VirtualCharDevice.CHAR_SPICEVMC)
         g.add_device(cdev1)
         g.add_device(cdev2)
+        g.add_device(cdev3)
 
         # Video Devices
         vdev1 = VirtualVideoDevice(g.conn)
diff --git a/virtinst/VirtualCharDevice.py b/virtinst/VirtualCharDevice.py
index ae4ad58..77c8c3b 100644
--- a/virtinst/VirtualCharDevice.py
+++ b/virtinst/VirtualCharDevice.py
@@ -35,18 +35,20 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
     DEV_CHANNEL  = "channel"
     dev_types    = [ DEV_SERIAL, DEV_PARALLEL, DEV_CONSOLE, DEV_CHANNEL]
 
-    CHAR_PTY    = "pty"
-    CHAR_DEV    = "dev"
-    CHAR_STDIO  = "stdio"
-    CHAR_PIPE   = "pipe"
-    CHAR_FILE   = "file"
-    CHAR_VC     = "vc"
-    CHAR_NULL   = "null"
-    CHAR_TCP    = "tcp"
-    CHAR_UDP    = "udp"
-    CHAR_UNIX   = "unix"
+    CHAR_PTY      = "pty"
+    CHAR_DEV      = "dev"
+    CHAR_STDIO    = "stdio"
+    CHAR_PIPE     = "pipe"
+    CHAR_FILE     = "file"
+    CHAR_VC       = "vc"
+    CHAR_NULL     = "null"
+    CHAR_TCP      = "tcp"
+    CHAR_UDP      = "udp"
+    CHAR_UNIX     = "unix"
+    CHAR_SPICEVMC = "spicevmc"
     char_types  = [ CHAR_PTY, CHAR_DEV, CHAR_STDIO, CHAR_FILE, CHAR_VC,
-                    CHAR_PIPE, CHAR_NULL, CHAR_TCP, CHAR_UDP, CHAR_UNIX ]
+                    CHAR_PIPE, CHAR_NULL, CHAR_TCP, CHAR_UDP, CHAR_UNIX,
+                    CHAR_SPICEVMC ]
 
     CHAR_MODE_CONNECT = "connect"
     CHAR_MODE_BIND = "bind"
@@ -92,6 +94,8 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
             desc = _("UDP net console")
         elif char_type == VirtualCharDevice.CHAR_UNIX:
             desc = _("Unix socket")
+        elif char_type == VirtualCharDevice.CHAR_SPICEVMC:
+            desc = _("Spice agent")
 
         return desc
     get_char_type_desc = staticmethod(get_char_type_desc)
@@ -144,6 +148,8 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
             c = VirtualCharUnixDevice
         elif char_type == VirtualCharDevice.CHAR_UDP:
             c = VirtualCharUdpDevice
+        elif char_type == VirtualCharDevice.CHAR_SPICEVMC:
+            c = VirtualCharSpicevmcDevice
         else:
             raise ValueError(_("Unknown character device type '%s'.") %
                              char_type)
@@ -332,7 +338,7 @@ class VirtualCharDevice(VirtualDevice.VirtualDevice):
 
     def _char_file_xml(self):
         """
-        Provide source xml for devs that require only a patch (dev, pipe)
+        Provide source xml for devs that require only a path (dev, pipe)
         """
         file_xml = ""
         mode_xml = ""
@@ -530,3 +536,15 @@ class VirtualCharUdpDevice(VirtualCharDevice):
         xml += ("      <source mode='connect'%s service='%s'/>\n" %
                 (source_host_xml, self.source_port))
         return xml
+
+class VirtualCharSpicevmcDevice(VirtualCharDevice):
+    _char_type = VirtualCharDevice.CHAR_SPICEVMC
+    _char_xml = VirtualCharDevice._char_empty_xml
+    target_types = [ VirtualCharDevice.CHAR_CHANNEL_TARGET_VIRTIO ]
+
+    def __init__(self, conn, dev_type,
+                 parsexml=None, parsexmlnode=None, caps=None):
+        VirtualCharDevice.__init__(self, conn, dev_type,
+                                   parsexml, parsexmlnode, caps)
+        self._target_type = VirtualCharDevice.CHAR_CHANNEL_TARGET_VIRTIO
+        self._target_name = "com.redhat.spice.0"
-- 
1.7.4




More information about the virt-tools-list mailing list