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

Snir Sheriber ssheribe at redhat.com
Sun May 29 14:30:18 UTC 2016


From: Frediano Ziglio <fziglio at redhat.com>

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 28ea8e9..19ce4c6 100644
--- a/server/spicevmc.c
+++ b/server/spicevmc.c
@@ -462,27 +462,19 @@ static void spicevmc_red_channel_send_data(RedChannelClient *rcc,
 {
     RedVmcPipeItem *i = SPICE_UPCAST(RedVmcPipeItem, item);
 
-    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.5.5



More information about the Spice-devel mailing list