Re: [PATCH spice] server: Add support for filtering out agent file-xfer msgs (rhbz#961848)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks good. Ack.

On 06/06/2013 11:09 AM, Hans de Goede wrote:
Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
  server/agent-msg-filter.c | 12 +++++++++++-
  server/agent-msg-filter.h |  3 ++-
  server/reds.c             | 21 +++++++++++++++++----
  server/spice-server.syms  |  5 +++++
  server/spice.h            |  3 ++-
  5 files changed, 37 insertions(+), 7 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index b48dd76..567e03d 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -27,10 +27,11 @@
  #include "red_dispatcher.h"

  void agent_msg_filter_init(struct AgentMsgFilter *filter,
-    int copy_paste, int discard_all)
+                           int copy_paste, int file_xfer, int discard_all)
  {
      memset(filter, 0, sizeof(*filter));
      filter->copy_paste_enabled = copy_paste;
+    filter->file_xfer_enabled = file_xfer;
      filter->discard_all = discard_all;
  }

@@ -81,6 +82,15 @@ data_to_read:
                  filter->result = AGENT_MSG_FILTER_DISCARD;
              }
              break;
+        case VD_AGENT_FILE_XFER_START:
+        case VD_AGENT_FILE_XFER_STATUS:
+        case VD_AGENT_FILE_XFER_DATA:
+            if (filter->file_xfer_enabled) {
+                filter->result = AGENT_MSG_FILTER_OK;
+            } else {
+                filter->result = AGENT_MSG_FILTER_DISCARD;
+            }
+            break;
          case VD_AGENT_MONITORS_CONFIG:
              if (red_dispatcher_use_client_monitors_config()) {
                  filter->result = AGENT_MSG_FILTER_MONITORS_CONFIG;
diff --git a/server/agent-msg-filter.h b/server/agent-msg-filter.h
index 0132ad7..92aabce 100644
--- a/server/agent-msg-filter.h
+++ b/server/agent-msg-filter.h
@@ -36,11 +36,12 @@ typedef struct AgentMsgFilter {
      int msg_data_to_read;
      int result;
      int copy_paste_enabled;
+    int file_xfer_enabled;
      int discard_all;
  } AgentMsgFilter;

  void agent_msg_filter_init(struct AgentMsgFilter *filter,
-                           int copy_paste, int discard_all);
+                           int copy_paste, int file_xfer, int discard_all);
  int agent_msg_filter_process_data(struct AgentMsgFilter *filter,
                                    uint8_t *data, uint32_t len);

diff --git a/server/reds.c b/server/reds.c
index ae02e09..b3dfb25 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -125,6 +125,7 @@ void *red_tunnel = NULL;
  #endif
  int agent_mouse = TRUE;
  int agent_copypaste = TRUE;
+int agent_file_xfer = TRUE;
  static bool exit_on_disconnect = FALSE;

  static RedsState *reds = NULL;
@@ -483,7 +484,8 @@ static void reds_reset_vdp(void)
          state->current_read_buf = NULL;
      }
      /* Reset read filter to start with clean state when the agent reconnects */
-    agent_msg_filter_init(&state->read_filter, agent_copypaste, TRUE);
+    agent_msg_filter_init(&state->read_filter, agent_copypaste,
+                          agent_file_xfer, TRUE);
      /* Throw away pending chunks from the current (if any) and future
       * messages written by the client.
       * TODO: client should clear its agent messages queue when the agent
@@ -596,7 +598,7 @@ void reds_client_disconnect(RedClient *client)

          /* Reset write filter to start with clean state on client reconnect */
          agent_msg_filter_init(&reds->agent_state.write_filter, agent_copypaste,
-                              TRUE);
+                              agent_file_xfer, TRUE);

          /* Throw away pending chunks from the current (if any) and future
           *  messages read from the agent */
@@ -3880,8 +3882,10 @@ static void init_vd_agent_resources(void)
      int i;

      ring_init(&state->read_bufs);
-    agent_msg_filter_init(&state->write_filter, agent_copypaste, TRUE);
-    agent_msg_filter_init(&state->read_filter, agent_copypaste, TRUE);
+    agent_msg_filter_init(&state->write_filter, agent_copypaste,
+                          agent_file_xfer, TRUE);
+    agent_msg_filter_init(&state->read_filter, agent_copypaste,
+                          agent_file_xfer, TRUE);

      state->read_state = VDI_PORT_READ_STATE_READ_HEADER;
      state->recive_pos = (uint8_t *)&state->vdi_chunk_header;
@@ -4334,6 +4338,15 @@ SPICE_GNUC_VISIBLE int spice_server_set_agent_copypaste(SpiceServer *s, int enab
      return 0;
  }

+SPICE_GNUC_VISIBLE int spice_server_set_agent_file_xfer(SpiceServer *s, int enable)
+{
+    spice_assert(reds == s);
+    agent_file_xfer = enable;
+    reds->agent_state.write_filter.file_xfer_enabled = agent_file_xfer;
+    reds->agent_state.read_filter.file_xfer_enabled = agent_file_xfer;
+    return 0;
+}
+
  /* returns FALSE if info is invalid */
  static int reds_set_migration_dest_info(const char* dest,
                                          int port, int secure_port,
diff --git a/server/spice-server.syms b/server/spice-server.syms
index 53edd17..4f2dc37 100644
--- a/server/spice-server.syms
+++ b/server/spice-server.syms
@@ -140,3 +140,8 @@ SPICE_SERVER_0.12.3 {
  global:
      spice_qxl_driver_unload;
  } SPICE_SERVER_0.12.2;
+
+SPICE_SERVER_0.12.4 {
+global:
+    spice_server_set_agent_file_xfer;
+} SPICE_SERVER_0.12.3;
diff --git a/server/spice.h b/server/spice.h
index 18bd11a..6fbb7b2 100644
--- a/server/spice.h
+++ b/server/spice.h
@@ -23,7 +23,7 @@
  #include <spice/qxl_dev.h>
  #include <spice/vd_agent.h>

-#define SPICE_SERVER_VERSION 0x000c03 /* release 0.12.3 */
+#define SPICE_SERVER_VERSION 0x000c04 /* release 0.12.4 */

  /* interface base type */

@@ -501,6 +501,7 @@ int spice_server_set_streaming_video(SpiceServer *s, int value);
  int spice_server_set_playback_compression(SpiceServer *s, int enable);
  int spice_server_set_agent_mouse(SpiceServer *s, int enable);
  int spice_server_set_agent_copypaste(SpiceServer *s, int enable);
+int spice_server_set_agent_file_xfer(SpiceServer *s, int enable);

  int spice_server_get_sock_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);
  int spice_server_get_peer_info(SpiceServer *s, struct sockaddr *sa, socklen_t *salen);


_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]