From patchwork Mon Apr 27 12:06:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=A1n_Tomko?= X-Patchwork-Id: 464970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id CC67C140082 for ; Mon, 27 Apr 2015 22:06:42 +1000 (AEST) Received: from localhost ([::1]:54650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymho8-0000Mw-Li for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 08:06:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymhnh-00084M-16 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 08:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ymhnd-0000oJ-Gz for qemu-devel@nongnu.org; Mon, 27 Apr 2015 08:06:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ymhnd-0000no-C0 for qemu-devel@nongnu.org; Mon, 27 Apr 2015 08:06:09 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id A2CD82BB395 for ; Mon, 27 Apr 2015 12:06:08 +0000 (UTC) Received: from snc.brq.redhat.com (dhcp129-98.brq.redhat.com [10.34.129.98]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RC6741003856; Mon, 27 Apr 2015 08:06:07 -0400 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: qemu-devel@nongnu.org Date: Mon, 27 Apr 2015 14:06:00 +0200 Message-Id: MIME-Version: 1.0 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kraxel@redhat.com Subject: [Qemu-devel] [PATCH] Strip brackets from vnc host X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. Signed-off-by: Ján Tomko Reviewed-by: Eric Blake --- ui/vnc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui/vnc.c b/ui/vnc.c index cffb5b7..49af7c7 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);