File virtview-git-wildcard-hostname.patch of Package virt-viewer

Subject: Fix hostname when XML gives a wildcard address
From: Daniel P. Berrange berrange@redhat.com Mon Sep 19 16:37:57 2011 +0100
Date: Mon Sep 19 16:37:57 2011 +0100:
Git: 41703dd4581c064a110ee3b4371920cbc9356613

When the guest XML contains a wildcard address like 0.0.0.0 or ::,
we can't directly use connect() on it. Instead we have to use the
hostname/IP from the libvirt URI.

Index: virt-viewer-0.4.1/src/virt-viewer.c
===================================================================
--- virt-viewer-0.4.1.orig/src/virt-viewer.c
+++ virt-viewer-0.4.1/src/virt-viewer.c
@@ -325,6 +325,19 @@ virt_viewer_extract_connect_info(VirtVie
 		goto cleanup;
 	}
 
+	/* 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
+	 */
+	if (strcmp(ghost, "0.0.0.0") == 0 ||
+	    strcmp(ghost, "::") == 0) {
+		DEBUG_LOG("Guest graphics listen '%s' is a wildcard, replacing with '%s'",
+			  ghost, host);
+		g_free(ghost);
+		ghost = g_strdup(host);
+	}
+
 	virt_viewer_app_set_connect_info(app, host, ghost, gport, transport, unixsock, user, port);
 
 	retval = TRUE;
openSUSE Build Service is sponsored by