File virtview-git-ssh-localhost-connect.patch of Package virt-viewer

Subject: Connect to localhost for display when transport is ssh
From: Dave Allan dallan@redhat.com Thu Nov 8 17:44:01 2012 +0100
Date: Thu Nov 8 17:44:18 2012 +0100:
Git: 74b1b62510d93903dbabdb95262f4ab4cd718520

When connecting to a VM that does not have a 'listen' tag in its
graphcs element, we have to guess where to try to connect to the VM's
display.  The current default is the host specified in the connection
URI which is correct for most transports, however, the SSH transport
makes the display connection from the remote end, so in that case,
attempt to connect to localhost.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Index: virt-viewer-0.5.4/src/virt-viewer.c
===================================================================
--- virt-viewer-0.5.4.orig/src/virt-viewer.c
+++ virt-viewer-0.5.4/src/virt-viewer.c
@@ -370,13 +370,21 @@ virt_viewer_extract_connect_info(VirtVie
     /* If the XML listen attribute shows a wildcard address, we need to
      * throw that away since you obviously can't 'connect(2)' to that
      * from a remote host. Instead we fallback to the hostname used in
-     * the libvirt URI. This isn't perfect but it is better than nothing
+     * the libvirt URI. This isn't perfect but it is better than nothing.
+     * If the transport is SSH, fallback to localhost as the connection
+     * will be made from the remote end of the ssh connection.
      */
     if (virt_viewer_replace_host(ghost)) {
+        gchar *replacement_host = NULL;
+        if (g_str_equal(transport, "ssh")) {
+            replacement_host = g_strdup("localhost");
+        } else {
+            replacement_host = g_strdup(host);
+        }
         DEBUG_LOG("Guest graphics listen '%s' is NULL or a wildcard, replacing with '%s'",
-                  ghost ? ghost : "", host);
+                  ghost ? ghost : "", replacement_host);
         g_free(ghost);
-        ghost = g_strdup(host);
+        ghost = replacement_host;
     }
 
     virt_viewer_app_set_connect_info(app, host, ghost, gport, gtlsport,transport, unixsock, user, port, NULL);
openSUSE Build Service is sponsored by