From 41703dd4581c064a110ee3b4371920cbc9356613 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Mon, 19 Sep 2011 16:37:57 +0100 Subject: Fix hostname when XML gives a wildcard address 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. --- src/virt-viewer.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/virt-viewer.c') diff --git a/src/virt-viewer.c b/src/virt-viewer.c index f2f9ef6..99149d2 100644 --- a/src/virt-viewer.c +++ b/src/virt-viewer.c @@ -325,6 +325,19 @@ virt_viewer_extract_connect_info(VirtViewer *self, 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; -- cgit