[Spice-commits] 2 commits - server/reds.c server/tests
Pavel Grunt
pgrunt at kemper.freedesktop.org
Wed Sep 7 12:19:47 UTC 2016
server/reds.c | 20 +++++++++++---
server/tests/Makefile.am | 1
server/tests/spice-options-test.c | 54 ++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 4 deletions(-)
New commits:
commit 179616009596a4f540c6c7308ef465145035eecb
Author: Pavel Grunt <pgrunt at redhat.com>
Date: Wed Sep 7 09:26:23 2016 +0200
tests: Check setting of agent properties
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/tests/Makefile.am b/server/tests/Makefile.am
index 91edd7c..59a1fac 100644
--- a/server/tests/Makefile.am
+++ b/server/tests/Makefile.am
@@ -37,6 +37,7 @@ LDADD = \
$(NULL)
TESTS = \
+ spice-options-test \
stat_test \
stream-test \
test-loop \
diff --git a/server/tests/spice-options-test.c b/server/tests/spice-options-test.c
new file mode 100644
index 0000000..e762461
--- /dev/null
+++ b/server/tests/spice-options-test.c
@@ -0,0 +1,54 @@
+/* -*- Mode: C; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ Copyright (C) 2016 Red Hat, Inc.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+#include <config.h>
+#include <glib.h>
+#include <spice.h>
+
+#include "basic_event_loop.h"
+
+/* GLIB_CHECK_VERSION(2, 40, 0) */
+#ifndef g_assert_nonnull
+#define g_assert_nonnull g_assert
+#endif
+
+int main(int argc, char *argv[])
+{
+ SpiceCoreInterface *core ;
+ SpiceServer *server = spice_server_new();
+
+ g_assert_nonnull(server);
+
+ core = basic_event_loop_init();
+ g_assert_nonnull(core);
+
+ /* test before init */
+ spice_server_set_agent_mouse(server, 0);
+ spice_server_set_agent_copypaste(server, 0);
+ spice_server_set_agent_file_xfer(server, 0);
+
+ g_assert_cmpint(spice_server_init(server, core), ==, 0);
+
+ /* test after init */
+ spice_server_set_agent_mouse(server, 0);
+ spice_server_set_agent_copypaste(server, 0);
+ spice_server_set_agent_file_xfer(server, 0);
+
+ spice_server_destroy(server);
+
+ return 0;
+}
commit bf68b73ba6ef9045da05dfa4957d54d8434653a4
Author: Pavel Grunt <pgrunt at redhat.com>
Date: Wed Sep 7 09:36:43 2016 +0200
reds: Do not crash when setting agent property
Agent properties like file transfer or copy & paste can be disabled by
calling spice_server_set_agent_{copypaste, file_xfer} before the spice
server is initialized. In that case the call crashes the server because
the agent device is created after the initialization.
To avoid the crash this commit introduce a helper function for setting
the agent properties after the server is initialized.
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/server/reds.c b/server/reds.c
index 74f7727..f95af14 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -730,6 +730,19 @@ static void reds_update_mouse_mode(RedsState *reds)
}
}
+static void reds_update_agent_properties(RedsState *reds)
+{
+ if (reds->agent_dev == NULL || reds->config == NULL) {
+ return;
+ }
+ /* copy & paste */
+ reds->agent_dev->priv->write_filter.copy_paste_enabled = reds->config->agent_copypaste;
+ reds->agent_dev->priv->read_filter.copy_paste_enabled = reds->config->agent_copypaste;
+ /* file transfer */
+ reds->agent_dev->priv->write_filter.file_xfer_enabled = reds->config->agent_file_xfer;
+ reds->agent_dev->priv->read_filter.file_xfer_enabled = reds->config->agent_file_xfer;
+}
+
static void reds_agent_remove(RedsState *reds)
{
// TODO: agent is broken with multiple clients. also need to figure out what to do when
@@ -3438,6 +3451,7 @@ static int do_spice_init(RedsState *reds, SpiceCoreInterface *core_interface)
reds->listen_socket = -1;
reds->secure_listen_socket = -1;
reds->agent_dev = red_char_device_vdi_port_new(reds);
+ reds_update_agent_properties(reds);
ring_init(&reds->clients);
reds->num_clients = 0;
reds->main_dispatcher = main_dispatcher_new(reds, reds->core);
@@ -4030,16 +4044,14 @@ SPICE_GNUC_VISIBLE int spice_server_set_agent_mouse(SpiceServer *reds, int enabl
SPICE_GNUC_VISIBLE int spice_server_set_agent_copypaste(SpiceServer *reds, int enable)
{
reds->config->agent_copypaste = enable;
- reds->agent_dev->priv->write_filter.copy_paste_enabled = reds->config->agent_copypaste;
- reds->agent_dev->priv->read_filter.copy_paste_enabled = reds->config->agent_copypaste;
+ reds_update_agent_properties(reds);
return 0;
}
SPICE_GNUC_VISIBLE int spice_server_set_agent_file_xfer(SpiceServer *reds, int enable)
{
reds->config->agent_file_xfer = enable;
- reds->agent_dev->priv->write_filter.file_xfer_enabled = reds->config->agent_file_xfer;
- reds->agent_dev->priv->read_filter.file_xfer_enabled = reds->config->agent_file_xfer;
+ reds_update_agent_properties(reds);
return 0;
}
More information about the Spice-commits
mailing list