[Spice-devel] [PATCH 6/6] spicevmc: handle any possible future compression sending compressed data

Frediano Ziglio fziglio at redhat.com
Tue May 17 10:04:32 UTC 2016


Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 server/spicevmc.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/server/spicevmc.c b/server/spicevmc.c
index 0c8ba51..512c4eb 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -469,27 +469,19 @@ static void spicevmc_red_channel_send_data(RedChannelClient *rcc,
 {
     RedVmcPipeItem *i = SPICE_CONTAINEROF(item, RedVmcPipeItem, base);
 
-    switch (i->type) {
-    case SPICE_DATA_COMPRESSION_TYPE_NONE:
+    /* for compatibility send using not compressed data message */
+    if (i->type == SPICE_DATA_COMPRESSION_TYPE_NONE) {
         red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_DATA, item);
-        spice_marshaller_add_ref(m, i->buf, i->buf_used);
-        break;
-    case SPICE_DATA_COMPRESSION_TYPE_LZ4: {
-        SpiceMsgCompressedData compressed_msg;
-
+    } else {
+        /* send as compressed */
         red_channel_client_init_send_data(rcc, SPICE_MSG_SPICEVMC_COMPRESSED_DATA, item);
-        compressed_msg.type = SPICE_DATA_COMPRESSION_TYPE_LZ4;
-        compressed_msg.uncompressed_size = i->uncompressed_data_size;
-        compressed_msg.compressed_size = i->buf_used;
-
+        SpiceMsgCompressedData compressed_msg = {
+            .type = i->type,
+            .uncompressed_size = i->uncompressed_data_size
+        };
         spice_marshall_SpiceMsgCompressedData(m, &compressed_msg);
-        spice_marshaller_add_ref(m, i->buf, i->buf_used);
-        break;
-     }
-     default:
-         g_assert_not_reached();
     }
-
+    spice_marshaller_add_ref(m, i->buf, i->buf_used);
 }
 
 static void spicevmc_red_channel_send_migrate_data(RedChannelClient *rcc,
-- 
2.7.4



More information about the Spice-devel mailing list