summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsnir sheriber <ssheribe@redhat.com>2016-06-13 19:54:38 +0300
committerFrediano Ziglio <fziglio@redhat.com>2016-06-13 23:00:28 +0100
commit4284011bdce6dd94301a2c83f4416ed3ad500881 (patch)
tree296470f01ac566c053bae0d5e43cc6cc1b9c9f57
parentd0139f824e50759059ae526e7d1bd9aaca34094a (diff)
Add LZ4 data compression and use it in spicevmc channel
Compressed message type is CompressedData which contains compression type (1 byte) followed by the uncompressed data size (4 bytes-exists only if data was compressed) followed by the compressed data Update the required protocol to 0.12.12: Signed-off-by: Snir Sheriber <ssheribe@redhat.com> Signed-off-by: Frediano Ziglio <fziglio@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
-rw-r--r--common/client_marshallers.h1
-rw-r--r--common/messages.h7
-rw-r--r--configure.ac2
-rw-r--r--spice.proto24
4 files changed, 33 insertions, 1 deletions
diff --git a/common/client_marshallers.h b/common/client_marshallers.h
index 728987e..2074323 100644
--- a/common/client_marshallers.h
+++ b/common/client_marshallers.h
@@ -33,6 +33,7 @@ SPICE_BEGIN_DECLS
typedef struct {
void (*msg_SpiceMsgEmpty)(SpiceMarshaller *m, SpiceMsgEmpty *msg);
void (*msg_SpiceMsgData)(SpiceMarshaller *m, SpiceMsgData *msg);
+ void (*msg_SpiceMsgCompressedData)(SpiceMarshaller *m, SpiceMsgCompressedData *msg);
void (*msgc_ack_sync)(SpiceMarshaller *m, SpiceMsgcAckSync *msg);
void (*msgc_pong)(SpiceMarshaller *m, SpiceMsgPing *msg);
void (*msgc_disconnecting)(SpiceMarshaller *m, SpiceMsgDisconnect *msg);
diff --git a/common/messages.h b/common/messages.h
index f537950..516a345 100644
--- a/common/messages.h
+++ b/common/messages.h
@@ -55,6 +55,13 @@ typedef struct SpiceMsgData {
uint8_t data[0];
} SpiceMsgData;
+typedef struct SpiceMsgCompressedData {
+ uint8_t type;
+ uint32_t uncompressed_size;
+ uint32_t compressed_size;
+ uint8_t *compressed_data;
+} SpiceMsgCompressedData;
+
typedef struct SpiceMsgEmpty {
uint8_t padding;
} SpiceMsgEmpty;
diff --git a/configure.ac b/configure.ac
index f8ff024..c3ad5a4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AM_PROG_CC_C_O
SPICE_CHECK_SYSDEPS
# Checks for libraries
-PKG_CHECK_MODULES([PROTOCOL], [spice-protocol >= 0.12.10])
+PKG_CHECK_MODULES([PROTOCOL], [spice-protocol >= 0.12.12])
SPICE_CHECK_PYTHON_MODULES()
diff --git a/spice.proto b/spice.proto
index d21510d..0bfc515 100644
--- a/spice.proto
+++ b/spice.proto
@@ -120,6 +120,28 @@ message Data {
uint8 data[] @end @ctype(uint8_t);
} @nocopy;
+enum8 data_compression_type {
+ NONE,
+ LZ4,
+};
+
+struct EmptyStructure {
+};
+
+message CompressedData {
+ data_compression_type type;
+ switch (type) {
+ /* we cannot use !NONE (works only with flags) */
+ case NONE:
+ /* due to the way cases are defined after NONE we must have something */
+ /* due to a bug we cannot use @virtual to write 0 to compressed_size */
+ EmptyStructure empty;
+ default:
+ uint32 uncompressed_size;
+ } u @anon;
+ uint8 compressed_data[] @as_ptr(compressed_size);
+} @ctype(SpiceMsgCompressedData);
+
struct ChannelWait {
uint8 channel_type;
uint8 channel_id;
@@ -1373,8 +1395,10 @@ channel SmartcardChannel : BaseChannel {
channel SpicevmcChannel : BaseChannel {
server:
Data data = 101;
+ CompressedData compressed_data = 102;
client:
Data data = 101;
+ CompressedData compressed_data = 102;
};
channel UsbredirChannel : SpicevmcChannel {