[virt-tools-list] [PATCH virt-manager 2/4] addhw: add CharDevice.source_channel

Marc-André Lureau marcandre.lureau at gmail.com
Tue Mar 25 14:42:32 UTC 2014


This property maps to channel/source/@channel domain XML.
---
 tests/xmlparse-xml/change-chars-in.xml  | 4 ++++
 tests/xmlparse-xml/change-chars-out.xml | 4 ++++
 tests/xmlparse.py                       | 7 +++++++
 virtinst/devicechar.py                  | 5 ++++-
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/tests/xmlparse-xml/change-chars-in.xml b/tests/xmlparse-xml/change-chars-in.xml
index 1fd40c2..ceee29e 100644
--- a/tests/xmlparse-xml/change-chars-in.xml
+++ b/tests/xmlparse-xml/change-chars-in.xml
@@ -44,5 +44,9 @@
       <source mode="bind" path="/tmp/foobar"/>
       <target type="guestfwd" address="1.2.3.4" port="4567"/>
     </channel>
+    <channel type="spiceport">
+      <source channel="org.spice-space.webdav.0"/>
+      <target type="virtio" name="org.spice-space.webdav.0"/>
+    </channel>
   </devices>
 </domain>
diff --git a/tests/xmlparse-xml/change-chars-out.xml b/tests/xmlparse-xml/change-chars-out.xml
index eefc894..119d121 100644
--- a/tests/xmlparse-xml/change-chars-out.xml
+++ b/tests/xmlparse-xml/change-chars-out.xml
@@ -47,5 +47,9 @@
       <source mode="bind" path="/tmp/foobar"/>
       <target type="guestfwd" address="5.6.7.8" port="1199"/>
     </channel>
+    <channel type="spiceport">
+      <source channel="test.1"/>
+      <target type="virtio" name="test.2"/>
+    </channel>
   </devices>
 </domain>
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index ad2ffc3..3e78a5d 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -361,6 +361,7 @@ class XMLParseTest(unittest.TestCase):
         console2    = guest.get_devices("console")[1]
         channel1    = guest.get_devices("channel")[0]
         channel2    = guest.get_devices("channel")[1]
+        channel3    = guest.get_devices("channel")[2]
 
         check = self._make_checker(serial1)
         check("type", "null", "udp")
@@ -408,6 +409,12 @@ class XMLParseTest(unittest.TestCase):
         check("target_address", "1.2.3.4", "5.6.7.8")
         check("target_port", 4567, 1199)
 
+        check = self._make_checker(channel3)
+        check("type", "spiceport")
+        check("source_channel", "org.spice-space.webdav.0", "test.1")
+        check("target_type", "virtio")
+        check("target_name", "org.spice-space.webdav.0", "test.2")
+
         self._alter_compare(guest.get_xml_config(), outfile)
 
     def testAlterControllers(self):
diff --git a/virtinst/devicechar.py b/virtinst/devicechar.py
index 233fcaa..3d0d6cf 100644
--- a/virtinst/devicechar.py
+++ b/virtinst/devicechar.py
@@ -170,7 +170,7 @@ class _VirtualCharDevice(VirtualDevice):
 
     _XML_PROP_ORDER = ["type", "_has_mode_bind", "_has_mode_connect",
                        "bind_host", "bind_port",
-                       "source_mode", "_source_path",
+                       "source_mode", "_source_path", "source_channel",
                        "source_host", "source_port",
                        "target_type", "target_name"]
 
@@ -191,6 +191,9 @@ class _VirtualCharDevice(VirtualDevice):
         self._source_path = val
     source_path = property(_get_source_path, _set_source_path)
 
+    source_channel = XMLProperty(xpath="./source/@channel",
+                                 doc=_("Source channel name."))
+
     def _get_default_source_mode(self):
         if self.type == self.TYPE_UDP:
             return self.MODE_CONNECT
-- 
1.8.5.3




More information about the virt-tools-list mailing list