From be5118cf8121e4d4dc4bc745bfa738cb931965b3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Jan 11 2022 17:20:04 +0000 Subject: import spice-vdagent-0.21.0-4.el9 --- diff --git a/SOURCES/0002-vdagent-udscs-limit-retry-to-connect-to-vdagentd.patch b/SOURCES/0002-vdagent-udscs-limit-retry-to-connect-to-vdagentd.patch new file mode 100644 index 0000000..0c6581b --- /dev/null +++ b/SOURCES/0002-vdagent-udscs-limit-retry-to-connect-to-vdagentd.patch @@ -0,0 +1,62 @@ +From 1aa2c06015e15f707ba9f874d5a5ea49fd450745 Mon Sep 17 00:00:00 2001 +From: Victor Toso +Date: Wed, 1 Dec 2021 20:07:22 +0100 +Subject: [PATCH 2/3] 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 +--- + 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 + diff --git a/SOURCES/0003-udscs-udscs_connect-return-error-to-caller.patch b/SOURCES/0003-udscs-udscs_connect-return-error-to-caller.patch new file mode 100644 index 0000000..8c4aa17 --- /dev/null +++ b/SOURCES/0003-udscs-udscs_connect-return-error-to-caller.patch @@ -0,0 +1,98 @@ +From 09de02fd5cb12fcda3326e243981750c5358b7b6 Mon Sep 17 00:00:00 2001 +From: Victor Toso +Date: Mon, 20 Dec 2021 19:09:37 +0100 +Subject: [PATCH 3/3] 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 +--- + 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 + diff --git a/SPECS/spice-vdagent.spec b/SPECS/spice-vdagent.spec index 33efa59..3c5459e 100644 --- a/SPECS/spice-vdagent.spec +++ b/SPECS/spice-vdagent.spec @@ -1,6 +1,6 @@ Name: spice-vdagent Version: 0.21.0 -Release: 3%{?dist} +Release: 4%{?dist} Summary: Agent for Spice guests License: GPLv3+ URL: https://spice-space.org/ @@ -9,6 +9,8 @@ Source1: https://spice-space.org/download/releases/%{name}-%{version}.tar Source2: jrope-7FDAB9AF.keyring Patch0001: 0001-Fix-g_memdup-deprecation-warning-with-glib-2.68.patch +Patch0002: 0002-vdagent-udscs-limit-retry-to-connect-to-vdagentd.patch +Patch0003: 0003-udscs-udscs_connect-return-error-to-caller.patch BuildRequires: make BuildRequires: systemd-devel @@ -81,6 +83,10 @@ make install DESTDIR=$RPM_BUILD_ROOT V=2 %changelog +* Tue Dec 21 2021 Victor Toso 0.21.0-4 +- Limit session agent to (re)connect to system agent to a minute + Related: rhbz#2028013 + * Tue Aug 10 2021 Mohan Boddu - 0.21.0-3 - Rebuilt for IMA sigs, glibc 2.34, aarch64 flags Related: rhbz#1991688