[libvirt] [PATCHv2] spice: support streaming-video parameter

Alon Levy alevy at redhat.com
Mon May 16 12:32:58 UTC 2011


This adds a streaming-video=filter|all|off attribute. It is used to change
the behavior of video stream detection in spice, the default is filter (the
default for libvirt is not to specify it - the actual default is defined in
libspice-server.so).

Usage:

    <graphics type='spice' autoport='yes'>
      <streaming mode='off'/>
    </graphics>

Tested with the above and with tests/qemuxml2argvtest.

Signed-off-by: Alon Levy <alevy at redhat.com>
---
Fixed: error code for missing mode is now VIR_ERR_XML_ERROR, and added documentation.
Note: I'm not registered to the list, so please cc me on reply, thanks.
---
 docs/formatdomain.html.in                          |    6 ++++
 docs/schemas/domain.rng                            |   12 ++++++++
 src/conf/domain_conf.c                             |   30 ++++++++++++++++++++
 src/conf/domain_conf.h                             |   11 +++++++
 src/libvirt_private.syms                           |    2 +
 src/qemu/qemu_command.c                            |    3 ++
 .../qemuxml2argv-graphics-spice.args               |    2 +-
 .../qemuxml2argv-graphics-spice.xml                |    1 +
 8 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 5013c48..78fbc09 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -1775,6 +1775,7 @@ qemu-kvm -net nic,model=? /dev/null
     <channel name='main' mode='secure'/>
     <channel name='record' mode='insecure'/>
     <image compression='auto_glz'/>
+    <streaming mode='filter'/>
   </graphics></pre>
             <p>
               Spice supports variable compression settings for audio,
@@ -1793,6 +1794,11 @@ qemu-kvm -net nic,model=? /dev/null
               and <code>playback</code> for enabling audio stream
               compression (accepts <code>on</code> or <code>off</code>).
             </p>
+            <p>
+              Streaming mode is set by the <code>streaming</code>
+              element, settings it's <code>mode</code> attribute to one
+              of <code>filter</code>,<code>all</code> or <code>off</code>.
+            </p>
           </dd>
           <dt><code>"rdp"</code></dt>
           <dd>
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 7163c6e..9083ff9 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -1334,6 +1334,18 @@
                 <empty/>
               </element>
             </optional>
+            <optional>
+              <element name="streaming">
+                <attribute name="mode">
+                  <choice>
+                    <value>filter</value>
+                    <value>all</value>
+                    <value>off</value>
+                  </choice>
+                </attribute>
+                <empty/>
+              </element>
+            </optional>
           </interleave>
         </group>
         <group>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 2a681d9..9be459c 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -352,6 +352,13 @@ VIR_ENUM_IMPL(virDomainGraphicsSpicePlaybackCompression,
               "on",
               "off");
 
+VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode,
+              VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST,
+              "default",
+              "filter",
+              "all",
+              "off");
+
 VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
               "subsystem",
               "capabilities")
@@ -4082,6 +4089,26 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, int flags) {
                     VIR_FREE(compression);
 
                     def->data.spice.playback = compressionVal;
+                } else if (xmlStrEqual(cur->name, BAD_CAST "streaming")) {
+                    const char *mode = virXMLPropString(cur, "mode");
+                    int modeVal;
+
+                    if (!mode) {
+                        virDomainReportError(VIR_ERR_XML_ERROR, "%s",
+                                             _("spice streaming missing mode"));
+                        goto error;
+                    }
+                    if ((modeVal =
+                         virDomainGraphicsSpiceStreamingModeTypeFromString(mode)) <= 0) {
+                        virDomainReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                                             _("unknown spice streaming mode"));
+                        VIR_FREE(mode);
+                        goto error;
+
+                    }
+                    VIR_FREE(mode);
+
+                    def->data.spice.streaming = modeVal;
                 }
             }
             cur = cur->next;
@@ -7979,6 +8006,9 @@ virDomainGraphicsDefFormat(virBufferPtr buf,
         if (def->data.spice.playback)
             virBufferVSprintf(buf, "      <playback compression='%s'/>\n",
                               virDomainGraphicsSpicePlaybackCompressionTypeToString(def->data.spice.playback));
+        if (def->data.spice.streaming)
+            virBufferVSprintf(buf, "      <streaming mode='%s'/>\n",
+                              virDomainGraphicsSpiceStreamingModeTypeToString(def->data.spice.streaming));
     }
 
     if (children) {
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 1dadf98..7a1f29a 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -696,6 +696,15 @@ enum virDomainGraphicsSpicePlaybackCompression {
     VIR_DOMAIN_GRAPHICS_SPICE_PLAYBACK_COMPRESSION_LAST
 };
 
+enum virDomainGraphicsSpiceStreamingMode {
+    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_DEFAULT = 0,
+    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_FILTER,
+    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_ALL,
+    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_OFF,
+
+    VIR_DOMAIN_GRAPHICS_SPICE_STREAMING_MODE_LAST
+};
+
 typedef struct _virDomainGraphicsDef virDomainGraphicsDef;
 typedef virDomainGraphicsDef *virDomainGraphicsDefPtr;
 struct _virDomainGraphicsDef {
@@ -737,6 +746,7 @@ struct _virDomainGraphicsDef {
             int jpeg;
             int zlib;
             int playback;
+            int streaming;
         } spice;
     } data;
 };
@@ -1476,6 +1486,7 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression)
 VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression)
+VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode)
 /* from libvirt.h */
 VIR_ENUM_DECL(virDomainState)
 VIR_ENUM_DECL(virDomainSeclabel)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 1b22be6..2e25202 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -273,6 +273,8 @@ virDomainGraphicsSpicePlaybackCompressionTypeFromString;
 virDomainGraphicsSpicePlaybackCompressionTypeToString;
 virDomainGraphicsSpiceZlibCompressionTypeFromString;
 virDomainGraphicsSpiceZlibCompressionTypeToString;
+virDomainGraphicsSpiceStreamingModeTypeFromString;
+virDomainGraphicsSpiceStreamingModeTypeToString;
 virDomainGraphicsTypeFromString;
 virDomainGraphicsTypeToString;
 virDomainHostdevDefFree;
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 2205ed1..8036f0c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4037,6 +4037,9 @@ qemuBuildCommandLine(virConnectPtr conn,
         if (def->graphics[0]->data.spice.playback)
             virBufferVSprintf(&opt, ",playback-compression=%s",
                               virDomainGraphicsSpicePlaybackCompressionTypeToString(def->graphics[0]->data.spice.playback));
+        if (def->graphics[0]->data.spice.streaming)
+            virBufferVSprintf(&opt, ",streaming-video=%s",
+                              virDomainGraphicsSpiceStreamingModeTypeToString(def->graphics[0]->data.spice.streaming));
 
         virCommandAddArg(cmd, "-spice");
         virCommandAddArgBuffer(cmd, &opt);
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
index 70cd35b..084a100 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.args
@@ -4,6 +4,6 @@ unix:/tmp/test-monitor,server,nowait -no-acpi -boot c -hda \
 /dev/HostVG/QEMUGuest1 -usb -spice port=5903,tls-port=5904,addr=127.0.0.1,\
 x509-dir=/etc/pki/libvirt-spice,tls-channel=main,plaintext-channel=inputs,\
 image-compression=auto_glz,jpeg-wan-compression=auto,zlib-glz-wan-compression=auto,\
-playback-compression=on -vga \
+playback-compression=on,streaming-video=filter -vga \
 qxl -global qxl.vram_size=18874368 -device qxl,id=video1,vram_size=33554432,bus=pci.0,addr=0x4 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
index a29f50d..0d3dd48 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice.xml
@@ -28,6 +28,7 @@
       <jpeg compression='auto'/>
       <zlib compression='auto'/>
       <playback compression='on'/>
+      <streaming mode='filter'/>
     </graphics>
     <video>
       <model type='qxl' vram='18432' heads='1'/>
-- 
1.7.5.1




More information about the libvir-list mailing list