diff options
author | Daniel P. Berrange <berrange@redhat.com> | 2011-09-19 16:37:57 +0100 |
---|---|---|
committer | Daniel P. Berrange <berrange@redhat.com> | 2011-09-19 16:37:57 +0100 |
commit | 41703dd4581c064a110ee3b4371920cbc9356613 (patch) | |
tree | 1e063ef55566de37466605ce5e87b10e5eb0efb3 /src/virt-viewer.c | |
parent | fe8551efbaa1425e7db4d59e10a25fa94788e949 (diff) | |
download | virt-viewer-41703dd4581c064a110ee3b4371920cbc9356613.tar.gz virt-viewer-41703dd4581c064a110ee3b4371920cbc9356613.tar.xz virt-viewer-41703dd4581c064a110ee3b4371920cbc9356613.zip |
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.
Diffstat (limited to 'src/virt-viewer.c')
-rw-r--r-- | src/virt-viewer.c | 13 |
1 files changed, 13 insertions, 0 deletions
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; |