[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



If Spice is enabled:
 - use QXL video device
 - add a spicevmc char device for the agent channel

Updated since v1:
- added some blurb in virt-install.pod.in that --graphics spice will
  add --video qxl and --channel spicevmc
- fixed the test_cli after the virtio port name got a default value
- check that spicevmc is supported before using it
---
 man/en/virt-install.pod.in                 |    4 ++++
 tests/cli-test-xml/compare/kvm-machine.xml |    5 ++++-
 tests/xmlconfig-xml/boot-many-devices.xml  |    2 +-
 virtinst/Guest.py                          |   26 +++++++++++++++++++++++++-
 4 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/man/en/virt-install.pod.in b/man/en/virt-install.pod.in
index 0088727..14b86bc 100644
--- a/man/en/virt-install.pod.in
+++ b/man/en/virt-install.pod.in
@@ -592,6 +592,10 @@ Export the guest's console using the Spice protocol. Spice allows advanced
 features like audio and USB device streaming, as well as improved graphical
 performance.
 
+Using spice graphic type will work as if those arguments were given:
+
+    --video qxl --channel spicevmc
+
 none
 
 No graphical console will be allocated for the guest. Fully virtualized guests
diff --git a/tests/cli-test-xml/compare/kvm-machine.xml b/tests/cli-test-xml/compare/kvm-machine.xml
index 12196d7..9edadcc 100644
--- a/tests/cli-test-xml/compare/kvm-machine.xml
+++ b/tests/cli-test-xml/compare/kvm-machine.xml
@@ -25,8 +25,11 @@
     <input type='tablet' bus='usb'/>
     <graphics type='spice' port='-1' tlsPort='-1' autoport='yes'/>
     <console type='pty'/>
+    <channel type='spicevmc'>
+      <target type='virtio' name='com.redhat.spice.0'/>
+    </channel>
     <video>
-      <model type='cirrus'/>
+      <model type='qxl'/>
     </video>
   </devices>
 </domain>
diff --git a/tests/xmlconfig-xml/boot-many-devices.xml b/tests/xmlconfig-xml/boot-many-devices.xml
index 47479c6..006e0cb 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..2d48a1d 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,33 @@ 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 \
+                support.check_conn_support(self.conn, support.SUPPORT_CONN_HV_CHAR_SPICEVMC) 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]