From nobody Mon Feb 9 14:34:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486645706166928.3789687916684; Thu, 9 Feb 2017 05:08:26 -0800 (PST) Received: from localhost ([::1]:37800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cboSX-0005pk-08 for importer@patchew.org; Thu, 09 Feb 2017 08:08:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cboLw-0008UK-R4 for qemu-devel@nongnu.org; Thu, 09 Feb 2017 08:01:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cboLs-00022i-UP for qemu-devel@nongnu.org; Thu, 09 Feb 2017 08:01:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40180) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cboLs-00022L-NE for qemu-devel@nongnu.org; Thu, 09 Feb 2017 08:01:32 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CF989469 for ; Thu, 9 Feb 2017 13:01:32 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-117-196.ams2.redhat.com [10.36.117.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 699006D9A7; Thu, 9 Feb 2017 13:01:31 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id F0FA580FCD; Thu, 9 Feb 2017 14:01:19 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 14:01:15 +0100 Message-Id: <1486645277-4724-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1486645277-4724-1-git-send-email-kraxel@redhat.com> References: <1486645277-4724-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 09 Feb 2017 13:01:32 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 08/10] ui: let VNC server listen on all resolved IP addresses X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Daniel P. Berrange" Remove the limitation that the VNC server can only listen on a single resolved IP address. This uses the new DNS resolver API to resolve a SocketAddress struct into an array of SocketAddress structs containing raw IP addresses. The VNC server will then attempt to listen on all resolved IP addresses. The server must successfully listen on at least one of the resolved IP addresses, otherwise an error will be reported. Reviewed-by: Eric Blake Signed-off-by: Daniel P. Berrange Message-id: 20170203120649.15637-7-berrange@redhat.com Signed-off-by: Gerd Hoffmann --- ui/vnc.c | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/ui/vnc.c b/ui/vnc.c index 49ce19a..36e50e7 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -45,6 +45,7 @@ #include "crypto/tlscredsx509.h" #include "qom/object_interfaces.h" #include "qemu/cutils.h" +#include "io/dns-resolver.h" =20 #define VNC_REFRESH_INTERVAL_BASE GUI_REFRESH_INTERVAL_DEFAULT #define VNC_REFRESH_INTERVAL_INC 50 @@ -3698,19 +3699,52 @@ static int vnc_display_listen_addr(VncDisplay *vd, size_t *nlsock, Error **errp) { - *nlsock =3D 1; - *lsock =3D g_new0(QIOChannelSocket *, 1); - *lsock_tag =3D g_new0(guint, 1); + QIODNSResolver *resolver =3D qio_dns_resolver_get_instance(); + SocketAddress **rawaddrs =3D NULL; + size_t nrawaddrs =3D 0; + Error *listenerr =3D NULL; + size_t i; =20 - (*lsock)[0] =3D qio_channel_socket_new(); - qio_channel_set_name(QIO_CHANNEL((*lsock)[0]), name); - if (qio_channel_socket_listen_sync((*lsock)[0], addr, errp) < 0) { + if (qio_dns_resolver_lookup_sync(resolver, addr, &nrawaddrs, + &rawaddrs, errp) < 0) { return -1; } =20 - (*lsock_tag)[0] =3D qio_channel_add_watch( - QIO_CHANNEL((*lsock)[0]), - G_IO_IN, vnc_listen_io, vd, NULL); + for (i =3D 0; i < nrawaddrs; i++) { + QIOChannelSocket *sioc =3D qio_channel_socket_new(); + + qio_channel_set_name(QIO_CHANNEL(sioc), name); + if (qio_channel_socket_listen_sync( + sioc, rawaddrs[i], listenerr =3D=3D NULL ? &listenerr : NU= LL) < 0) { + continue; + } + (*nlsock)++; + *lsock =3D g_renew(QIOChannelSocket *, *lsock, *nlsock); + *lsock_tag =3D g_renew(guint, *lsock_tag, *nlsock); + + (*lsock)[*nlsock - 1] =3D sioc; + (*lsock_tag)[*nlsock - 1] =3D 0; + } + + for (i =3D 0; i < nrawaddrs; i++) { + qapi_free_SocketAddress(rawaddrs[i]); + } + g_free(rawaddrs); + + if (listenerr) { + if (*nlsock =3D=3D 0) { + error_propagate(errp, listenerr); + return -1; + } else { + error_free(listenerr); + } + } + + for (i =3D 0; i < *nlsock; i++) { + (*lsock_tag)[i] =3D qio_channel_add_watch( + QIO_CHANNEL((*lsock)[i]), + G_IO_IN, vnc_listen_io, vd, NULL); + } =20 return 0; } --=20 1.8.3.1