Skip to contentSkip to conversation

Strip brackets from vnc host

PATCH In review Ján Tomko 2 participants 2 messages Apr 27, 2015 – Apr 28, 2015

lore
Share & tools
lore

Ján Tomko

author
#0 lore raw

PATCH v2 1/1 Strip brackets from vnc host

Commit v2.2.0-1530-ge556032 vnc: switch to inet_listen_opts bypassed the use of inet_parse in inet_listen, making literal IPv6 addresses enclosed in brackets fail:

qemu-kvm: -vnc [::1]:0: Failed to start VNC server on `(null)': address resolution failed for [::1]:5900: Name or service not known

Strip the brackets to make it work again.

---
v2: Fixed spacing around operators
cc'd qemu-stable

 ui/vnc.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
ui/vnc.c +8 -1
index cffb5b7..f989dfb 100644
@@ -3482,7 +3482,14 @@ void vnc_display_open(const char *id, Error **errp)
 
     h = strrchr(vnc, ':');
     if (h) {
-        char *host = g_strndup(vnc, h - vnc);
+        char *host;
+        size_t hlen = h - vnc;
+
+        if (vnc[0] == '[' && vnc[hlen - 1] == ']') {
+            host = g_strndup(vnc + 1, hlen - 2);
+        } else {
+            host = g_strndup(vnc, hlen);
+        }
         qemu_opt_set(sopts, "host", host, &error_abort);
         qemu_opt_set(wsopts, "host", host, &error_abort);
         qemu_opt_set(sopts, "port", h+1, &error_abort);
Signature · 1 line
2.0.5
#1 lore raw
Quoted 9 lines · Ján Tomko

Commit v2.2.0-1530-ge556032 vnc: switch to inet_listen_opts bypassed the use of inet_parse in inet_listen, making literal IPv6 addresses enclosed in brackets fail:

qemu-kvm: -vnc [::1]:0: Failed to start VNC server on `(null)':
address
resolution failed for [::1]:5900: Name or service not known

Strip the brackets to make it work again.

added to vnc queue.

thanks,
Gerd