[Spice-devel] [PATCH spice-streaming-agent 5/6] Handle capabilities

Frediano Ziglio fziglio at redhat.com
Mon Feb 19 15:52:42 UTC 2018


Do not bail if the server is attempting to communicate some extensions
but just ignore as at the moment we support none.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 src/spice-streaming-agent.cpp | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/spice-streaming-agent.cpp b/src/spice-streaming-agent.cpp
index 41b4d3d..5813fba 100644
--- a/src/spice-streaming-agent.cpp
+++ b/src/spice-streaming-agent.cpp
@@ -41,6 +41,8 @@
 
 using namespace spice::streaming_agent;
 
+static size_t write_all(int fd, const void *buf, const size_t len);
+
 static ConcreteAgent agent;
 
 struct SpiceStreamFormatMessage
@@ -78,6 +80,7 @@ static int have_something_to_read(int timeout)
     return 0;
 }
 
+static int read_stream_capabilities(uint32_t len);
 static int read_stream_start_stop(uint32_t len);
 
 static int read_command_from_device(void)
@@ -96,6 +99,8 @@ static int read_command_from_device(void)
     }
 
     switch (hdr.type) {
+    case STREAM_TYPE_CAPABILITIES:
+        return read_stream_capabilities(hdr.size);
     case STREAM_TYPE_START_STOP:
         return read_stream_start_stop(hdr.size);
     }
@@ -122,6 +127,31 @@ static int read_stream_start_stop(uint32_t len)
     return 1;
 }
 
+static int read_stream_capabilities(uint32_t len)
+{
+    uint8_t caps[STREAM_MSG_CAPABILITIES_MAX_BYTES];
+
+    if (len > sizeof(caps)) {
+        ERROR("capability message too long");
+    }
+    int n = read(streamfd, caps, len);
+    if (n != len) {
+        ERROR("read command from device FAILED -- read " << n << " expected " << len);
+    }
+
+    // we currently do not suppor extensions so just reply so
+    StreamDevHeader hdr = {
+        STREAM_DEVICE_PROTOCOL,
+        0,
+        STREAM_TYPE_CAPABILITIES,
+        0
+    };
+    if (write_all(streamfd, &hdr, sizeof(hdr)) != sizeof(hdr)) {
+        ERROR("error writing capabilities");
+    }
+    return 1;
+}
+
 static int read_command(bool blocking)
 {
     int timeout = blocking?-1:0;
-- 
2.14.3



More information about the Spice-devel mailing list