[virt-tools-list] [PATCH 2 of 6] domain: learn to build spice:// uri

Marc-André Lureau marcandre.lureau at redhat.com
Fri Dec 17 13:51:23 UTC 2010


# HG changeset patch
# User Marc-André Lureau <marcandre.lureau at redhat.com>
# Date 1289577771 -3600
# Node ID 7dc4cc7ae3ddf954d42907e537c5e30e64f7fece
# Parent  4b25ae193e5ccdba7012a8e2d92b219532ecefd7
domain: learn to build spice:// uri

diff -r 4b25ae193e5c -r 7dc4cc7ae3dd src/virtManager/domain.py
--- a/src/virtManager/domain.py	Fri Dec 17 14:36:02 2010 +0100
+++ b/src/virtManager/domain.py	Fri Nov 12 17:02:51 2010 +0100
@@ -472,15 +472,14 @@
         gdevs = self.get_graphics_devices()
         connhost = self.connection.get_uri_hostname()
         transport, username = self.connection.get_transport()
-        vncport = None
         gport = None
         gtype = None
         if gdevs:
             gport = gdevs[0].port
             gtype = gdevs[0].type
 
-        if gtype == 'vnc':
-            vncport = int(gport)
+        if gtype in ['vnc', 'spice']:
+            gport = int(gport)
 
         if connhost == None:
             # Force use of 127.0.0.1, because some (broken) systems don't
@@ -494,16 +493,17 @@
         if connhost.count(":"):
             connhost, connport = connhost.split(":", 1)
 
-        # Build VNC uri for debugging
-        vncuri = None
-        if gtype == 'vnc':
-            vncuri = str(gtype) + "://"
+        # Build VNC/SPICE uri for debugging
+        guri = None
+        if gtype in ['vnc', 'spice']:
+            guri = str(gtype) + "://"
             if username:
-                vncuri = vncuri + str(username) + '@'
-            vncuri += str(connhost) + ":" + str(vncport)
+                guri = guri + str(username) + '@'
+            sep = {'vnc': ':', 'spice': '?port='}[gtype]
+            guri += str(connhost) + sep + str(gport)
 
-        return [gtype, connhost, vncport, transport, username, connport,
-                vncuri]
+        return [gtype, connhost, gport, transport, username, connport,
+                guri]
 
 
     def _build_device_list(self, device_type,




More information about the virt-tools-list mailing list