Blame 0026-spice-enabling-disabling-jpeg-and-zlib-over-glz-via-.patch

Justin M. Forbes a81953
From 0045574847883167f5c2b569811e049616ee611d Mon Sep 17 00:00:00 2001
Justin M. Forbes a81953
From: Yonit Halperin <yhalperi@redhat.com>
Justin M. Forbes a81953
Date: Wed, 14 Jul 2010 13:26:34 +0300
Justin M. Forbes a81953
Subject: [PATCH 26/39] spice: enabling/disabling jpeg and zlib-over-glz via spice command line args
Justin M. Forbes a81953
Justin M. Forbes a81953
---
Justin M. Forbes a81953
 qemu-config.c |    6 ++++++
Justin M. Forbes a81953
 spice.c       |   29 +++++++++++++++++++++++++++++
Justin M. Forbes a81953
 2 files changed, 35 insertions(+), 0 deletions(-)
Justin M. Forbes a81953
Justin M. Forbes a81953
diff --git a/qemu-config.c b/qemu-config.c
Justin M. Forbes a81953
index 74bfc62..3e4fcf9 100644
Justin M. Forbes a81953
--- a/qemu-config.c
Justin M. Forbes a81953
+++ b/qemu-config.c
Justin M. Forbes a81953
@@ -384,6 +384,12 @@ QemuOptsList qemu_spice_opts = {
Justin M. Forbes a81953
         },{
Justin M. Forbes a81953
             .name = "tls-ciphers",
Justin M. Forbes a81953
             .type = QEMU_OPT_STRING,
Justin M. Forbes a81953
+        },{
Justin M. Forbes a81953
+            .name = "jpeg",
Justin M. Forbes a81953
+            .type = QEMU_OPT_STRING,
Justin M. Forbes a81953
+        },{
Justin M. Forbes a81953
+            .name = "zlib-glz",
Justin M. Forbes a81953
+            .type = QEMU_OPT_STRING,
Justin M. Forbes a81953
         },
Justin M. Forbes a81953
         { /* end if list */ }
Justin M. Forbes a81953
     },
Justin M. Forbes a81953
diff --git a/spice.c b/spice.c
Justin M. Forbes a81953
index 1109b4f..201e53c 100644
Justin M. Forbes a81953
--- a/spice.c
Justin M. Forbes a81953
+++ b/spice.c
Justin M. Forbes a81953
@@ -207,6 +207,23 @@ int mon_spice_migrate(Monitor *mon, const QDict *qdict, QObject **ret_data)
Justin M. Forbes a81953
                                      port, tls_port, subject);
Justin M. Forbes a81953
 }
Justin M. Forbes a81953
Justin M. Forbes a81953
+static inline spice_wan_compression_t get_wan_compression_value(const char *str)
Justin M. Forbes a81953
+{
Justin M. Forbes a81953
+    if (!strcmp(str, "wan")) {
Justin M. Forbes a81953
+        return SPICE_WAN_COMPRESSION_AUTO;
Justin M. Forbes a81953
+    }
Justin M. Forbes a81953
+
Justin M. Forbes a81953
+    if (!strcmp(str, "never")) {
Justin M. Forbes a81953
+        return SPICE_WAN_COMPRESSION_NEVER;
Justin M. Forbes a81953
+    }
Justin M. Forbes a81953
+
Justin M. Forbes a81953
+    if (!strcmp(str, "always")) {
Justin M. Forbes a81953
+        return SPICE_WAN_COMPRESSION_ALWAYS;
Justin M. Forbes a81953
+    }
Justin M. Forbes a81953
+
Justin M. Forbes a81953
+    return SPICE_WAN_COMPRESSION_INVALID;
Justin M. Forbes a81953
+}
Justin M. Forbes a81953
+
Justin M. Forbes a81953
 void qemu_spice_init(void)
Justin M. Forbes a81953
 {
Justin M. Forbes a81953
     QemuOpts *opts = QTAILQ_FIRST(&qemu_spice_opts.head);
Justin M. Forbes a81953
@@ -218,6 +235,7 @@ void qemu_spice_init(void)
Justin M. Forbes a81953
         *x509_cert_file = NULL,
Justin M. Forbes a81953
         *x509_cacert_file = NULL;
Justin M. Forbes a81953
     int port, tls_port, len;
Justin M. Forbes a81953
+    const char *jpeg, *zlib_glz;
Justin M. Forbes a81953
Justin M. Forbes a81953
     if (!opts)
Justin M. Forbes a81953
         return;
Justin M. Forbes a81953
@@ -283,6 +301,17 @@ void qemu_spice_init(void)
Justin M. Forbes a81953
     /* TODO: make configurable via cmdline */
Justin M. Forbes a81953
     spice_server_set_image_compression(spice_server, SPICE_IMAGE_COMPRESS_AUTO_GLZ);
Justin M. Forbes a81953
Justin M. Forbes a81953
+    jpeg = qemu_opt_get(opts, "jpeg");
Justin M. Forbes a81953
+    zlib_glz = qemu_opt_get(opts, "zlib-glz");
Justin M. Forbes a81953
+
Justin M. Forbes a81953
+    if (jpeg) {
Justin M. Forbes a81953
+        spice_server_set_jpeg_compression(spice_server, get_wan_compression_value(jpeg));
Justin M. Forbes a81953
+    }
Justin M. Forbes a81953
+
Justin M. Forbes a81953
+    if (zlib_glz) {
Justin M. Forbes a81953
+        spice_server_set_zlib_glz_compression(spice_server, get_wan_compression_value(zlib_glz));
Justin M. Forbes a81953
+    }
Justin M. Forbes a81953
+
Justin M. Forbes a81953
     spice_server_init(spice_server, &core_interface);
Justin M. Forbes a81953
     using_spice = 1;
Justin M. Forbes a81953
Justin M. Forbes a81953
-- 
Justin M. Forbes a81953
1.7.2.3
Justin M. Forbes a81953