Compare commits

...

No commits in common. "imports/c8-beta/spice-vdagent-0.20.0-3.el8" and "c8" have entirely different histories.

5 changed files with 254 additions and 1 deletions

View File

@ -0,0 +1,62 @@
From 1aa2c06015e15f707ba9f874d5a5ea49fd450745 Mon Sep 17 00:00:00 2001
From: Victor Toso <victortoso@redhat.com>
Date: Wed, 1 Dec 2021 20:07:22 +0100
Subject: [PATCH 20/21] vdagent: udscs: limit retry to connect to vdagentd
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2005802
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2028013
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
src/vdagent/vdagent.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index fd08522..0d3945e 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -42,11 +42,14 @@
#include "clipboard.h"
#include "display.h"
+#define MAX_RETRY_CONNECT_SYSTEM_AGENT 60
+
typedef struct VDAgent {
VDAgentClipboards *clipboards;
VDAgentDisplay *display;
struct vdagent_file_xfers *xfers;
UdscsConnection *conn;
+ gint udscs_num_retry;
GMainLoop *loop;
} VDAgent;
@@ -378,9 +381,27 @@ static gboolean vdagent_init_async_cb(gpointer user_data)
daemon_read_complete, daemon_error_cb,
debug);
if (agent->conn == NULL) {
+ if (agent->udscs_num_retry == MAX_RETRY_CONNECT_SYSTEM_AGENT) {
+ syslog(LOG_WARNING,
+ "Failed to connect to spice-vdagentd at %s (tried %d times)",
+ vdagentd_socket, agent->udscs_num_retry);
+ goto err_init;
+ }
+ if (agent->udscs_num_retry == 0) {
+ /* Log only when it fails and at the end */
+ syslog(LOG_DEBUG,
+ "Failed to connect with spice-vdagentd. Trying again in 1s");
+ }
+ agent->udscs_num_retry++;
g_timeout_add_seconds(1, vdagent_init_async_cb, agent);
return G_SOURCE_REMOVE;
}
+ if (agent->udscs_num_retry != 0) {
+ syslog(LOG_DEBUG,
+ "Connected with spice-vdagentd after %d attempts",
+ agent->udscs_num_retry);
+ }
+ agent->udscs_num_retry = 0;
g_object_set_data(G_OBJECT(agent->conn), "agent", agent);
agent->display = vdagent_display_create(agent->conn, debug, x11_sync);
--
2.33.1

View File

@ -0,0 +1,98 @@
From 09de02fd5cb12fcda3326e243981750c5358b7b6 Mon Sep 17 00:00:00 2001
From: Victor Toso <victortoso@redhat.com>
Date: Mon, 20 Dec 2021 19:09:37 +0100
Subject: [PATCH 21/21] udscs: udscs_connect: return error to caller
This way we can have the log in one place and avoid flooding the journal.
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
src/udscs.c | 10 ++++------
src/udscs.h | 5 ++++-
src/vdagent/vdagent.c | 12 +++++++++---
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/src/udscs.c b/src/udscs.c
index 3df67b3..6c50f76 100644
--- a/src/udscs.c
+++ b/src/udscs.c
@@ -107,16 +107,14 @@ static void udscs_connection_class_init(UdscsConnectionClass *klass)
UdscsConnection *udscs_connect(const char *socketname,
udscs_read_callback read_callback,
VDAgentConnErrorCb error_cb,
- int debug)
+ int debug,
+ GError **err)
{
GIOStream *io_stream;
UdscsConnection *conn;
- GError *err = NULL;
- io_stream = vdagent_socket_connect(socketname, &err);
- if (err) {
- syslog(LOG_ERR, "%s: %s", __func__, err->message);
- g_error_free(err);
+ io_stream = vdagent_socket_connect(socketname, err);
+ if (*err) {
return NULL;
}
diff --git a/src/udscs.h b/src/udscs.h
index 4f7ea36..0d4197b 100644
--- a/src/udscs.h
+++ b/src/udscs.h
@@ -53,11 +53,14 @@ typedef void (*udscs_read_callback)(UdscsConnection *conn,
*
* If debug is true then the events on this connection will be traced.
* This includes the incoming and outgoing message names.
+ *
+ * In case of failure, returns NULL and set @err with reason.
*/
UdscsConnection *udscs_connect(const char *socketname,
udscs_read_callback read_callback,
VDAgentConnErrorCb error_cb,
- int debug);
+ int debug,
+ GError **err);
/* Queue a message for delivery to the client connected through conn.
*/
diff --git a/src/vdagent/vdagent.c b/src/vdagent/vdagent.c
index 0d3945e..05d1a8f 100644
--- a/src/vdagent/vdagent.c
+++ b/src/vdagent/vdagent.c
@@ -376,22 +376,28 @@ static void vdagent_destroy(VDAgent *agent)
static gboolean vdagent_init_async_cb(gpointer user_data)
{
VDAgent *agent = user_data;
+ GError *err = NULL;
agent->conn = udscs_connect(vdagentd_socket,
- daemon_read_complete, daemon_error_cb,
- debug);
+ daemon_read_complete,
+ daemon_error_cb,
+ debug,
+ &err);
if (agent->conn == NULL) {
if (agent->udscs_num_retry == MAX_RETRY_CONNECT_SYSTEM_AGENT) {
syslog(LOG_WARNING,
"Failed to connect to spice-vdagentd at %s (tried %d times)",
vdagentd_socket, agent->udscs_num_retry);
+ g_error_free(err);
goto err_init;
}
if (agent->udscs_num_retry == 0) {
/* Log only when it fails and at the end */
syslog(LOG_DEBUG,
- "Failed to connect with spice-vdagentd. Trying again in 1s");
+ "Failed to connect with spice-vdagentd due '%s'. Trying again in 1s",
+ err->message);
}
+ g_error_free(err);
agent->udscs_num_retry++;
g_timeout_add_seconds(1, vdagent_init_async_cb, agent);
return G_SOURCE_REMOVE;
--
2.33.1

View File

@ -0,0 +1,33 @@
From 0717474feca8753bce7b8933bd10b3bab62a2f14 Mon Sep 17 00:00:00 2001
From: Frediano Ziglio <freddy77@gmail.com>
Date: Sat, 12 Feb 2022 21:12:57 +0000
Subject: [PATCH] Do not process X11 events in vdagent_x11_create
Processing events requires some more initialisation between
VDAgentDisplay and vdagent_x11.
Postpone that after initialisation.
This fix a crash on Fedora 36, see
https://bugzilla.redhat.com/show_bug.cgi?id=2042877.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
---
src/vdagent/x11.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/vdagent/x11.c b/src/vdagent/x11.c
index 05a41d7..4af4bdc 100644
--- a/src/vdagent/x11.c
+++ b/src/vdagent/x11.c
@@ -302,9 +302,6 @@ struct vdagent_x11 *vdagent_x11_create(UdscsConnection *vdagentd,
x11->height[i] = attrib.height;
}
- /* Flush output buffers and consume any pending events */
- vdagent_x11_do_read(x11);
-
return x11;
}
--
2.39.0

View File

@ -0,0 +1,48 @@
From bcbbea34d93d07d33b767f808ff3adf628b1ea0f Mon Sep 17 00:00:00 2001
From: Victor Toso <victortoso@redhat.com>
Date: Fri, 13 Jan 2023 13:54:06 +0100
Subject: [PATCH] vdagent: Remove watch event on vdagent_display_destroy()
To avoid main loop calling it when GIOChannel for x11 was already
destroyed.
Related: https://bugzilla.redhat.com/show_bug.cgi?id=2145004
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
src/vdagent/display.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/vdagent/display.c b/src/vdagent/display.c
index 790d9ad..602ab65 100644
--- a/src/vdagent/display.c
+++ b/src/vdagent/display.c
@@ -60,6 +60,7 @@ struct VDAgentDisplay {
UdscsConnection *vdagentd;
int debug;
GIOChannel *x11_channel;
+ guint io_watch_source_id;
VDAgentMutterDBus *mutter;
};
@@ -296,7 +297,8 @@ VDAgentDisplay* vdagent_display_create(UdscsConnection *vdagentd, int debug, int
return NULL;
}
- g_io_add_watch(display->x11_channel, G_IO_IN, x11_io_channel_cb, display);
+ display->io_watch_source_id =
+ g_io_add_watch(display->x11_channel, G_IO_IN, x11_io_channel_cb, display);
/* Since we are started at the same time as the wm,
@@ -323,7 +325,7 @@ void vdagent_display_destroy(VDAgentDisplay *display, int vdagentd_disconnected)
return;
}
-
+ g_source_remove(display->io_watch_source_id);
g_clear_pointer(&display->x11_channel, g_io_channel_unref);
vdagent_x11_destroy(display->x11, vdagentd_disconnected);
--
2.39.0

View File

@ -1,6 +1,6 @@
Name: spice-vdagent
Version: 0.20.0
Release: 3%{?dist}
Release: 5%{?dist}
Summary: Agent for Spice guests
Group: Applications/System
License: GPLv3+
@ -27,6 +27,10 @@ Patch0016: 0016-cleanup-active_xfers-when-the-client-disconnects.patch
Patch0017: 0017-vdagentd-do-not-allow-to-use-an-already-used-file-xf.patch
Patch0018: 0018-Add-a-test-for-session_info.patch
Patch0019: 0019-wayland-fix-monitor-mapping-issues.patch
Patch0020: 0020-vdagent-udscs-limit-retry-to-connect-to-vdagentd.patch
Patch0021: 0021-udscs-udscs_connect-return-error-to-caller.patch
Patch0022: 0022-Do-not-process-X11-events-in-vdagent_x11_create.patch
Patch0023: 0023-vdagent-Remove-watch-event-on-vdagent_display_destro.patch
BuildRequires: git-core gnupg2
BuildRequires: systemd-devel
@ -92,6 +96,14 @@ make install DESTDIR=$RPM_BUILD_ROOT V=2
%changelog
* Mon Jan 16 2023 Victor Toso <victortoso@redhat.com> 0.20.0-5
- Fix upstream segfault on X11 events
Resolves: rhbz#2145004
* Tue Dec 21 2021 Victor Toso <victortoso@redhat.com> 0.20.0-4
- Do not flood the journal with retry messages.
Resolves: rhbz#2005802
* Wed Jan 20 2021 Julien Ropé <jrope@redhat.com> - 0.20.0-3
- Fix mouse problems in multi-monitor environments under Wayland
Resolves: rhbz#1790904 rhbz#1824610