From patchwork Mon Jan 11 13:17:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 565819 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 DA4B7140BEA for ; Tue, 12 Jan 2016 00:18:04 +1100 (AEDT) Received: from localhost ([::1]:54000 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIcME-0006do-Es for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2016 08:18:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIcLY-0005Wt-4N for qemu-devel@nongnu.org; Mon, 11 Jan 2016 08:17:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIcLX-0000jQ-4t for qemu-devel@nongnu.org; Mon, 11 Jan 2016 08:17:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIcLW-0000jI-Vz for qemu-devel@nongnu.org; Mon, 11 Jan 2016 08:17:19 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id AD978C0BF2C7 for ; Mon, 11 Jan 2016 13:17:18 +0000 (UTC) Received: from t530wlan.home.berrange.com.com (dhcp-1-180.lcy.redhat.com [10.32.224.180]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0BDHAxV001746; Mon, 11 Jan 2016 08:17:17 -0500 From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Mon, 11 Jan 2016 13:17:05 +0000 Message-Id: <1452518225-11751-6-git-send-email-berrange@redhat.com> In-Reply-To: <1452518225-11751-1-git-send-email-berrange@redhat.com> References: <1452518225-11751-1-git-send-email-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini Subject: [Qemu-devel] [PATCH v3 5/5] vnc: distiguish between ipv4/ipv6 omitted vs set to off 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 The VNC code for interpreting QemuOpts does not currently distinguish between ipv4/ipv6 being omitted, and being set to 'off', because historically the 'ipv4' and 'ipv6' options were just flags which did not accept a value. The upshot is that if someone runs $QEMU -vnc localhost:1,ipv6=off QEMU still uses PF_UNSPEC and thus may still bind to IPv6, when it should use PF_INET. This is another instance of the problem previously fixed for chardevs in commit b77e7c8e99f9ac726c4eaa2fc3461fd886017dc0 Author: Paolo Bonzini Date: Mon Oct 12 15:35:16 2015 +0200 qemu-sockets: fix conversion of ipv4/ipv6 JSON to QemuOpts Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange --- ui/vnc.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 09756cd..e42560f 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -3501,8 +3501,10 @@ void vnc_display_open(const char *id, Error **errp) const char *websocket = qemu_opt_get(opts, "websocket"); int to = qemu_opt_get_number(opts, "to", 0); - bool has_ipv4 = qemu_opt_get_bool(opts, "ipv4", false); - bool has_ipv6 = qemu_opt_get_bool(opts, "ipv6", false); + bool has_ipv4 = qemu_opt_get(opts, "ipv4"); + bool has_ipv6 = qemu_opt_get(opts, "ipv6"); + bool ipv4 = qemu_opt_get_bool(opts, "ipv4", false); + bool ipv6 = qemu_opt_get_bool(opts, "ipv6", false); saddr = g_new0(SocketAddress, 1); if (websocket) { @@ -3550,8 +3552,10 @@ void vnc_display_open(const char *id, Error **errp) saddr->u.inet->has_to = true; saddr->u.inet->to = to + 5900; } - saddr->u.inet->ipv4 = saddr->u.inet->has_ipv4 = has_ipv4; - saddr->u.inet->ipv6 = saddr->u.inet->has_ipv6 = has_ipv6; + saddr->u.inet->ipv4 = ipv4; + saddr->u.inet->has_ipv4 = has_ipv4; + saddr->u.inet->ipv6 = ipv6; + saddr->u.inet->has_ipv6 = has_ipv6; if (vs->ws_enabled) { wsaddr->type = SOCKET_ADDRESS_KIND_INET; @@ -3563,8 +3567,10 @@ void vnc_display_open(const char *id, Error **errp) wsaddr->u.inet->has_to = true; wsaddr->u.inet->to = to; } - wsaddr->u.inet->ipv4 = wsaddr->u.inet->has_ipv4 = has_ipv4; - wsaddr->u.inet->ipv6 = wsaddr->u.inet->has_ipv6 = has_ipv6; + wsaddr->u.inet->ipv4 = ipv4; + wsaddr->u.inet->has_ipv4 = has_ipv4; + wsaddr->u.inet->ipv6 = ipv6; + wsaddr->u.inet->has_ipv6 = has_ipv6; } } } else {