From nobody Tue Feb 10 04:13:41 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 1486658994057193.82355152522223; Thu, 9 Feb 2017 08:49:54 -0800 (PST) Received: from localhost ([::1]:38914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbruq-0005FV-OQ for importer@patchew.org; Thu, 09 Feb 2017 11:49:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cbrsl-0003mV-UD for qemu-devel@nongnu.org; Thu, 09 Feb 2017 11:47:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cbrsk-0003H1-NR for qemu-devel@nongnu.org; Thu, 09 Feb 2017 11:47:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cbrsk-0003G7-FU for qemu-devel@nongnu.org; Thu, 09 Feb 2017 11:47:42 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D0E26711C3 for ; Thu, 9 Feb 2017 16:47:39 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-117-196.ams2.redhat.com [10.36.117.196]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v19Gla3q021783; Thu, 9 Feb 2017 11:47:38 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id A86F7809D5; Thu, 9 Feb 2017 17:47:24 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 9 Feb 2017 17:47:20 +0100 Message-Id: <1486658842-7143-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1486658842-7143-1-git-send-email-kraxel@redhat.com> References: <1486658842-7143-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 09 Feb 2017 16:47:39 +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 v2 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 02c0b89..5c11c2d 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