From d8475ccac4e7b22b301153eed4aae4d2ba0724d3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sep 29 2020 07:07:17 +0000 Subject: import virt-viewer-5.0-18.el7 --- diff --git a/SOURCES/0071-remote-viewer-add-handler-for-SIGINT-signal.patch b/SOURCES/0071-remote-viewer-add-handler-for-SIGINT-signal.patch new file mode 100644 index 0000000..b03bfe0 --- /dev/null +++ b/SOURCES/0071-remote-viewer-add-handler-for-SIGINT-signal.patch @@ -0,0 +1,98 @@ +From a724dff8a3ba6d5e8d3baf79b0041b1b73bd190d Mon Sep 17 00:00:00 2001 +From: Francesco Giudici +Date: Fri, 17 Jan 2020 16:06:13 +0100 +Subject: [PATCH] remote-viewer: add handler for SIGINT signal +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When remote-viewer is started from terminal, CTRL-C sends a SIGINT +signal to the program causing immediate termination. On linux clients +usb redirected devices are left without any kernel driver attached, +causing them to appear as no more available to the host. +Add a SIGINT handler to allow a clean exit, in particular to allow +the kernel to attach back the host driver. +The issue is present on linux only. + +To perform usb device redirection, virt-viewer leverages spice-gtk +library, which in turn relies on usbredir library, which uses libusb. +In order to take control of the usb device the auto-loaded kernel +driver must be detached. This is achieved (in the very end) with +libusb_detach_kernel_driver(). Then the device interfaces can be claimed +with libusb_claim_interface() and get in control to the application. +During normal application termination, the usb channel is teared down, +performing a reset of the usb device and giving back the control of the +device to the kernel (libusb_attach_kernel_driver()). +If the application quits without doing this, the device interfaces will +end up with no driver attached, making them not usable in the host +system. + +Note that enabling libusb_set_auto_detach_kernel_driver() does not solve +the issue, as this is just a convenient API from libusb: libusb will +take care of detaching/attaching the driver to the interfaces of the usb +device each time a call to libusb_release_interface() and +libusb_claim_interface() is performed. An unexpected quit of the +application will skip the libusb_release_interface() call too, leaving +the interfaces without any driver attached. + +Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1713311 + +Reviewed-by: Daniel P. Berrangé +Signed-off-by: Francesco Giudici +--- + src/virt-viewer-app.c | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c +index da8cfa9..343b1af 100644 +--- a/src/virt-viewer-app.c ++++ b/src/virt-viewer-app.c +@@ -37,6 +37,10 @@ + #include + #include + ++#ifndef G_OS_WIN32 ++#include ++#endif ++ + #ifdef HAVE_SYS_SOCKET_H + #include + #endif +@@ -1756,6 +1760,23 @@ static gboolean opt_fullscreen = FALSE; + static gboolean opt_kiosk = FALSE; + static gboolean opt_kiosk_quit = FALSE; + ++#ifndef G_OS_WIN32 ++static gboolean ++sigint_cb(gpointer data) ++{ ++ VirtViewerApp *self = VIRT_VIEWER_APP(data); ++ VirtViewerAppPrivate *priv = self->priv; ++ ++ g_debug("got SIGINT, quitting\n"); ++ if (priv->started) ++ virt_viewer_app_quit(self); ++ else ++ exit(EXIT_SUCCESS); ++ ++ return G_SOURCE_CONTINUE; ++} ++#endif ++ + static void + title_maybe_changed(VirtViewerApp *self, GParamSpec* pspec G_GNUC_UNUSED, gpointer user_data G_GNUC_UNUSED) + { +@@ -1770,6 +1791,10 @@ virt_viewer_app_init(VirtViewerApp *self) + + gtk_window_set_default_icon_name("virt-viewer"); + ++#ifndef G_OS_WIN32 ++ g_unix_signal_add (SIGINT, sigint_cb, self); ++#endif ++ + self->priv->displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref); + self->priv->config = g_key_file_new(); + self->priv->config_file = g_build_filename(g_get_user_config_dir(), +-- +2.26.0 + diff --git a/SPECS/virt-viewer.spec b/SPECS/virt-viewer.spec index 2a14eef..ac16cc3 100644 --- a/SPECS/virt-viewer.spec +++ b/SPECS/virt-viewer.spec @@ -24,7 +24,7 @@ Name: virt-viewer Version: 5.0 -Release: 17%{?dist}%{?extra_release} +Release: 18%{?dist}%{?extra_release} Summary: Virtual Machine Viewer Group: Applications/System License: GPLv2+ @@ -100,6 +100,7 @@ Patch0067: 0067-Workaround-inconsistency-with-REST-API.patch Patch0068: 0068-remote-viewer-Set-admin-privileges-when-connecting-t.patch Patch0069: 0069-remote-viewer-fix-free-on-dangling-pointer.patch Patch0070: 0070-remote-viewer-Prefer-ca-cert-from-display-instead-of.patch +Patch0071: 0071-remote-viewer-add-handler-for-SIGINT-signal.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) @@ -213,6 +214,7 @@ the display, and libvirt for looking up VNC/SPICE server details. %patch0068 -p1 %patch0069 -p1 %patch0070 -p1 +%patch0071 -p1 %build @@ -278,6 +280,10 @@ fi %{_mandir}/man1/remote-viewer.1* %changelog +* Mon Apr 20 2020 Victor Toso - 5.0-18 +- add handler for SIGINT signal + Resolves: rhbz#1713311 + * Fri Oct 4 2019 Victor Toso - 5.0-17 - Fix double free on migration Resolves: rhbz#1713600