[virt-tools-list] [PATCH 2/2] A few spice tweaks to simplify setup

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


If Spice is enabled:
 - use QXL video device
 - add a spicevmc char device for the agent channel
---
 tests/xmlconfig-xml/boot-many-devices.xml |    2 +-
 virtinst/Guest.py                         |   24 +++++++++++++++++++++++-
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/tests/xmlconfig-xml/boot-many-devices.xml b/tests/xmlconfig-xml/boot-many-devices.xml
index 65e83f6..5f057d8 100644
--- a/tests/xmlconfig-xml/boot-many-devices.xml
+++ b/tests/xmlconfig-xml/boot-many-devices.xml
@@ -69,7 +69,7 @@
       <model type='cirrus' vram='10240' heads='3'/>
     </video>
     <video>
-      <model type='cirrus'/>
+      <model type='qxl'/>
     </video>
     <video>
       <model type='qxl'/>
diff --git a/virtinst/Guest.py b/virtinst/Guest.py
index de251e1..8755668 100644
--- a/virtinst/Guest.py
+++ b/virtinst/Guest.py
@@ -1412,6 +1412,8 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
         soundtype = VirtualDevice.VIRTUAL_DEV_AUDIO
         videotype = VirtualDevice.VIRTUAL_DEV_VIDEO
         inputtype = VirtualDevice.VIRTUAL_DEV_INPUT
+        gfxtype = VirtualDevice.VIRTUAL_DEV_GRAPHICS
+        channeltype = VirtualDevice.VIRTUAL_DEV_CHANNEL
 
         # Set default input values
         input_type = self._lookup_device_param(inputtype, "type")
@@ -1442,11 +1444,31 @@ class Guest(XMLBuilderDomain.XMLBuilderDomain):
                 sound.model = sound_model
 
         # Set video device model
-        video_model  = self._lookup_device_param(videotype, "model_type")
+        # QXL device (only if we use spice) - safe even if guest is VGA only
+        def has_spice():
+            for gfx in devlist_func(gfxtype):
+                if gfx.type == gfx.TYPE_SPICE:
+                    return True
+        if has_spice():
+            video_model  = "qxl"
+        else:
+            video_model  = self._lookup_device_param(videotype, "model_type")
         for video in devlist_func(videotype):
             if video.model_type == video.MODEL_DEFAULT:
                 video.model_type = video_model
 
+        # Spice agent channel (only if we use spice)
+        def has_spice_agent():
+            for chn in devlist_func(channeltype):
+                if chn.char_type == chn.CHAR_SPICEVMC:
+                    return True
+
+        if has_spice() and not has_spice_agent():
+            agentdev = VirtualCharDevice.get_dev_instance(self.conn,
+                                                          VirtualCharDevice.DEV_CHANNEL,
+                                                          VirtualCharDevice.CHAR_SPICEVMC)
+            self.add_device(agentdev)
+
         # Generate UUID
         if self.uuid is None:
             found = False
-- 
1.7.4




More information about the virt-tools-list mailing list