[spice-server 2/3] agent: Sync AgentMsgFilter state upon agent connection

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

 



AgentMsgFilter needs to know whether monitors config messages need to be
filtered or not. This used to be done from within
agent_msg_filter_config() using the global RedsState, but this got more
tricky as it was removed.
A first attempt a1e62fa5ae9 caused crashes on qemu startup with
"qemu-system-x86_64 -spice port=5900" (without -vga qxl). A second
attempt added a RedsState* argument to agent_msg_filter_config() which
in my opinion is not really nice from a layering point of view.

This new attempt makes sure AgentMsgFilter state is correct when the
filter is set to stop discarding all data, which allows to remove direct
use of RedsState from within AgentMsgFilter.
---
 server/agent-msg-filter.c | 14 +++++++++++---
 server/agent-msg-filter.h |  3 +++
 server/reds.c             | 10 ++++++++--
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/server/agent-msg-filter.c b/server/agent-msg-filter.c
index db8526e..498864c 100644
--- a/server/agent-msg-filter.c
+++ b/server/agent-msg-filter.c
@@ -27,15 +27,23 @@
 #include "reds.h"
 #include "red-qxl.h"
 
+void agent_msg_filter_config(struct AgentMsgFilter *filter,
+                             gboolean copy_paste, gboolean file_xfer,
+                             gboolean use_client_monitors_config)
+{
+    filter->copy_paste_enabled = copy_paste;
+    filter->file_xfer_enabled = file_xfer;
+    filter->use_client_monitors_config = use_client_monitors_config;
+}
+
 void agent_msg_filter_init(struct AgentMsgFilter *filter,
                            gboolean copy_paste, gboolean file_xfer,
                            gboolean use_client_monitors_config,
                            int discard_all)
 {
     memset(filter, 0, sizeof(*filter));
-    filter->copy_paste_enabled = copy_paste;
-    filter->file_xfer_enabled = file_xfer;
-    filter->use_client_monitors_config = use_client_monitors_config;
+    agent_msg_filter_config(filter, copy_paste, file_xfer,
+                            use_client_monitors_config);
     filter->discard_all = discard_all;
 }
 
diff --git a/server/agent-msg-filter.h b/server/agent-msg-filter.h
index c04face..2ee055c 100644
--- a/server/agent-msg-filter.h
+++ b/server/agent-msg-filter.h
@@ -45,6 +45,9 @@ void agent_msg_filter_init(struct AgentMsgFilter *filter,
                            gboolean copy_paste, gboolean file_xfer,
                            gboolean use_client_monitors_config,
                            gboolean discard_all);
+void agent_msg_filter_config(struct AgentMsgFilter *filter,
+                             gboolean copy_paste, gboolean file_xfer,
+                             gboolean use_client_monitors_config);
 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 7fd80a8..82e6da4 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -951,6 +951,10 @@ void reds_on_main_agent_start(RedsState *reds, MainChannelClient *mcc, uint32_t
                                                     rcc->client,
                                                     num_tokens);
     }
+
+    agent_msg_filter_config(&reds->agent_state.write_filter, reds->agent_copypaste,
+                            reds->agent_file_xfer,
+                            reds_use_client_monitors_config(reds));
     reds->agent_state.write_filter.discard_all = FALSE;
 }
 
@@ -1678,6 +1682,10 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
         if (mig_target) {
             spice_warning("unexpected: vdagent attached to destination during migration");
         }
+        agent_msg_filter_config(&reds->agent_state.read_filter,
+                                reds->agent_copypaste,
+                                reds->agent_file_xfer,
+                                reds_use_client_monitors_config(reds));
         reds->agent_state.read_filter.discard_all = FALSE;
         reds->agent_state.plug_generation++;
     }
@@ -3190,8 +3198,6 @@ SPICE_GNUC_VISIBLE int spice_server_add_interface(SpiceServer *s,
         red_qxl_init(reds, qxl);
         qxl_state = qxl->st;
         reds->qxl_states = g_list_prepend(reds->qxl_states, qxl_state);
-        reds->agent_state.write_filter.use_client_monitors_config = reds_use_client_monitors_config(reds);
-        reds->agent_state.read_filter.use_client_monitors_config = reds_use_client_monitors_config(reds);
 
         /* this function has to be called after the qxl is on the list
          * as QXLInstance clients expect the qxl to be on the list when
-- 
2.5.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://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]