Blame SOURCES/0032-app-Allow-to-connect-to-channel-using-unix-socket.patch

140d58
From b22ebc15e9b2d08663e3105ca12c8cc5de3971ab Mon Sep 17 00:00:00 2001
140d58
From: Pavel Grunt <pgrunt@redhat.com>
140d58
Date: Fri, 7 Apr 2017 12:05:18 +0200
140d58
Subject: [PATCH virt-viewer 32/32] app: Allow to connect to channel using unix
140d58
 socket
140d58
To: virt-tools-list@redhat.com
140d58
140d58
Only method for connecting to channel opened later was ssh, however
140d58
this method failes when unix socket is used:
140d58
140d58
    <graphics type='spice'>
140d58
      <listen type='socket' socket='/tmp/spice.sock'/>
140d58
    </graphics>
140d58
140d58
Related: rhbz#1335832, rhbz#1411765
140d58
140d58
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
140d58
(cherry picked from commit fe538a9296925c919d4b80698147e4a1b56ba7fd)
140d58
---
140d58
 src/virt-viewer-app.c | 29 +++++++++++++++++++++++------
140d58
 1 file changed, 23 insertions(+), 6 deletions(-)
140d58
140d58
diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
140d58
index 2e7e193..2b74a9f 100644
140d58
--- a/src/virt-viewer-app.c
140d58
+++ b/src/virt-viewer-app.c
140d58
@@ -1129,6 +1129,7 @@ virt_viewer_app_channel_open(VirtViewerSession *session,
140d58
 {
140d58
     VirtViewerAppPrivate *priv;
140d58
     int fd = -1;
140d58
+    gchar *error_message = NULL;
140d58
 
140d58
     g_return_if_fail(self != NULL);
140d58
 
140d58
@@ -1141,14 +1142,30 @@ virt_viewer_app_channel_open(VirtViewerSession *session,
140d58
     if (priv->transport && g_ascii_strcasecmp(priv->transport, "ssh") == 0 &&
140d58
         !priv->direct && fd == -1) {
140d58
         if ((fd = virt_viewer_app_open_tunnel_ssh(priv->host, priv->port, priv->user,
140d58
-                                                  priv->ghost, priv->gport, NULL)) < 0)
140d58
-            virt_viewer_app_simple_message_dialog(self, _("Connect to ssh failed."));
140d58
-    } else if (fd == -1) {
140d58
-        virt_viewer_app_simple_message_dialog(self, _("Can't connect to channel, SSH only supported."));
140d58
+                                                  priv->ghost, priv->gport, priv->unixsock)) < 0) {
140d58
+            error_message = g_strdup(_("Connect to ssh failed."));
140d58
+            g_debug("channel open ssh tunnel: %s", error_message);
140d58
+        }
140d58
+    }
140d58
+    if (fd < 0 && priv->unixsock) {
140d58
+        GError *error = NULL;
140d58
+        if ((fd = virt_viewer_app_open_unix_sock(priv->unixsock, &error)) < 0) {
140d58
+            g_free(error_message);
140d58
+            error_message = g_strdup(error->message);
140d58
+            g_debug("channel open unix socket: %s", error_message);
140d58
+        }
140d58
+        g_clear_error(&error);
140d58
+    }
140d58
+
140d58
+    if (fd < 0) {
140d58
+        virt_viewer_app_simple_message_dialog(self, _("Can't connect to channel: %s"),
140d58
+                                              (error_message != NULL) ? error_message :
140d58
+                                              _("only SSH or unix socket connection supported."));
140d58
+        g_free(error_message);
140d58
+        return;
140d58
     }
140d58
 
140d58
-    if (fd >= 0)
140d58
-        virt_viewer_session_channel_open_fd(session, channel, fd);
140d58
+    virt_viewer_session_channel_open_fd(session, channel, fd);
140d58
 }
140d58
 #else
140d58
 static void
140d58
-- 
140d58
2.12.2
140d58