[virt-tools-list] [PATCH] Use spice by default if SpiceGtk is available

Marc-André Lureau marcandre.lureau at redhat.com
Tue Mar 15 12:34:58 UTC 2011


---
 src/virtManager/config.py |    9 +++++++++
 src/virtManager/create.py |   12 ++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/virtManager/config.py b/src/virtManager/config.py
index b9bb275..db3296f 100644
--- a/src/virtManager/config.py
+++ b/src/virtManager/config.py
@@ -325,6 +325,15 @@ class vmmConfig(object):
         except:
             return False
 
+    # Check whether we have SpiceGtk.
+    # TODO: check if QEMU/libvirt supports it too
+    def spice_supported(self):
+        try:
+            import SpiceClientGtk
+            return True
+        except:
+            return False
+
     # Keys preferences
     def get_keys_combination(self, syms=False):
         val = self.conf.get_string(self.conf_dir + "/keys/grab-keys")
diff --git a/src/virtManager/create.py b/src/virtManager/create.py
index 5062085..74ecded 100644
--- a/src/virtManager/create.py
+++ b/src/virtManager/create.py
@@ -1174,7 +1174,6 @@ class vmmCreate(vmmGObjectUI):
     def build_guest(self, installer, name):
         guest = installer.guest_from_installer()
         guest.name = name
-
         # Generate UUID
         try:
             guest.uuid = virtinst.util.uuidToString(virtinst.util.randomUUID())
@@ -1185,9 +1184,14 @@ class vmmCreate(vmmGObjectUI):
 
         # Set up graphics device
         try:
-            guest.add_device(virtinst.VirtualGraphics(
-                                        type=virtinst.VirtualGraphics.TYPE_VNC,
-                                        conn=guest.conn))
+            if self.config.spice_supported():
+                guest.add_device(virtinst.VirtualGraphics(
+                        type=virtinst.VirtualGraphics.TYPE_SPICE,
+                        conn=guest.conn))
+            else:
+                guest.add_device(virtinst.VirtualGraphics(
+                        type=virtinst.VirtualGraphics.TYPE_VNC,
+                        conn=guest.conn))
             guest.add_device(virtinst.VirtualVideoDevice(conn=guest.conn))
         except Exception, e:
             self.err.show_err(_("Error setting up graphics device:") + str(e),
-- 
1.7.4




More information about the virt-tools-list mailing list