[Spice-commits] server/reds.c

Frediano Ziglio fziglio at kemper.freedesktop.org
Tue Jun 6 16:54:34 UTC 2017


 server/reds.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

New commits:
commit 366b5b96c21579156b6ef5601d6d458899269d99
Author: Pavel Grunt <pgrunt at redhat.com>
Date:   Mon Jun 5 09:29:35 2017 +0200

    reds: Adjust agent capabilites to disabled features
    
    File transfer and Copy & Paste can be disabled on the server even when
    they're supported by the guest agent. Tell it the client by adjusting
    the agent capabilities.
    
    Related: rhbz#1373725
    
    Acked-by: Jonathon Jongsma <jjongsma at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index bafd04ba..09b674d7 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -745,6 +745,27 @@ static void vdi_port_read_buf_free(RedPipeItem *base)
     }
 }
 
+static void agent_adjust_capabilities(VDAgentMessage *message,
+                                      bool clipboard_enabled, bool xfer_enabled)
+{
+    VDAgentAnnounceCapabilities *capabilities;
+
+    if (message->type != VD_AGENT_ANNOUNCE_CAPABILITIES) {
+        return;
+    }
+    capabilities = (VDAgentAnnounceCapabilities *) message->data;
+
+    if (!clipboard_enabled) {
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD);
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND);
+        VD_AGENT_CLEAR_CAPABILITY(capabilities->caps, VD_AGENT_CAP_CLIPBOARD_SELECTION);
+    }
+
+    if (!xfer_enabled) {
+        VD_AGENT_SET_CAPABILITY(capabilities->caps, VD_AGENT_CAP_FILE_XFER_DISABLED);
+    }
+}
+
 /* reads from the device till completes reading a message that is addressed to the client,
  * or otherwise, when reading from the device fails */
 static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
@@ -810,6 +831,9 @@ static RedPipeItem *vdi_port_read_one_msg_from_device(RedCharDevice *self,
             }
             switch (vdi_port_read_buf_process(reds->agent_dev, dispatch_buf)) {
             case AGENT_MSG_FILTER_OK:
+                agent_adjust_capabilities((VDAgentMessage *) dispatch_buf->data,
+                                          reds->config->agent_copypaste,
+                                          reds->config->agent_file_xfer);
                 return &dispatch_buf->base;
             case AGENT_MSG_FILTER_PROTO_ERROR:
                 reds_agent_remove(reds);
@@ -1199,6 +1223,9 @@ void reds_on_main_channel_migrate(RedsState *reds, MainChannelClient *mcc)
         read_buf->len = read_data_len;
         switch (vdi_port_read_buf_process(reds->agent_dev, read_buf)) {
         case AGENT_MSG_FILTER_OK:
+            agent_adjust_capabilities((VDAgentMessage *)read_buf->data,
+                                      reds->config->agent_copypaste,
+                                      reds->config->agent_file_xfer);
             main_channel_client_push_agent_data(mcc,
                                                 read_buf->data,
                                                 read_buf->len,


More information about the Spice-commits mailing list