summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/vnc.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ui/vnc.c b/ui/vnc.c
index 9f8ecd0c33..2dccae96c6 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -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);