From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33402) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoImt-0000HY-DT for qemu-devel@nongnu.org; Mon, 19 Oct 2015 18:20:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZoImp-00019i-Cc for qemu-devel@nongnu.org; Mon, 19 Oct 2015 18:20:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZoImp-00019e-4i for qemu-devel@nongnu.org; Mon, 19 Oct 2015 18:20:11 -0400 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 80BD485544 for ; Mon, 19 Oct 2015 22:20:10 +0000 (UTC) References: <1444648509-29179-1-git-send-email-berrange@redhat.com> <1444648509-29179-5-git-send-email-berrange@redhat.com> From: Eric Blake Message-ID: <56256C99.1000100@redhat.com> Date: Mon, 19 Oct 2015 16:20:09 -0600 MIME-Version: 1.0 In-Reply-To: <1444648509-29179-5-git-send-email-berrange@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vrIvrkNfjISMXRR9fLEtei98KMkJiVLDS" Subject: Re: [Qemu-devel] [PATCH v2 04/16] ui: convert VNC startup code to use SocketAddress List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" , qemu-devel@nongnu.org Cc: Paolo Bonzini , "Dr. David Alan Gilbert" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vrIvrkNfjISMXRR9fLEtei98KMkJiVLDS Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/12/2015 05:14 AM, Daniel P. Berrange wrote: > The VNC code is currently using QemuOpts to configure the > sockets connections / listeners it needs. Convert it to > use SocketAddress to bring it in line with modern QAPI > based code elsewhere in QEMU. >=20 > Signed-off-by: Daniel P. Berrange > --- > ui/vnc.c | 161 ++++++++++++++++++++++++++++++++++++-------------------= -------- > 1 file changed, 91 insertions(+), 70 deletions(-) >=20 > @@ -3539,44 +3535,83 @@ void vnc_display_open(const char *id, Error **e= rrp) > return; > } > =20 > - sopts =3D qemu_opts_create(&socket_optslist, NULL, 0, &error_abort= ); > - wsopts =3D qemu_opts_create(&socket_optslist, NULL, 0, &error_abor= t); > - > h =3D strrchr(vnc, ':'); > if (h) { > - char *host; > size_t hlen =3D h - vnc; > =20 > - if (vnc[0] =3D=3D '[' && vnc[hlen - 1] =3D=3D ']') { > - host =3D g_strndup(vnc + 1, hlen - 2); > + const char *websocket =3D qemu_opt_get(opts, "websocket"); > + int to =3D qemu_opt_get_number(opts, "to", 0); We really ought to improve the qapi notion of InetSocketAddress to allow { 'alternate':'StrOrInt', 'data': { 'i':'int', 's':'str' } } rather than only 'str' for port. But that's a project for another day. I guess things get a bit weird if "to" is present but doesn't parse as a number, but I don't think your patch is making things any worse. > + > + if (strncmp(vnc, "unix:", 5) =3D=3D 0) { > + saddr->kind =3D SOCKET_ADDRESS_KIND_UNIX; > + saddr->q_unix =3D g_new0(UnixSocketAddress, 1); More clashes with my pending qapi patches; rebase fun for one of us :) > + if (to) { > + saddr->inet->has_to =3D true; > + saddr->inet->to =3D to; > + } > + saddr->inet->ipv4 =3D saddr->inet->has_ipv4 =3D has_ipv4; > + saddr->inet->ipv6 =3D saddr->inet->has_ipv6 =3D has_ipv6; Do we want to specify has_ipvX as true even when setting inet->ipvX to false? > @@ -3770,37 +3795,32 @@ void vnc_display_open(const char *id, Error **e= rrp) > int csock; > vs->lsock =3D -1; > vs->lwebsock =3D -1; > - if (strncmp(vnc, "unix:", 5) =3D=3D 0) { > - csock =3D unix_connect(vnc+5, errp); > - } else { > - csock =3D inet_connect(vnc, errp); > + if (vs->ws_enabled) { > + error_setg(errp, "Cannot use websockets in reverse mode");= > + goto fail; > } > + csock =3D socket_connect(saddr, errp, > + NULL, NULL); Looks like the line-wrapping isn't needed here. Overall, looks like a sane conversion. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vrIvrkNfjISMXRR9fLEtei98KMkJiVLDS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWJWyZAAoJEKeha0olJ0Nqq9IH/i8BeesP5VERR43JVCPwdZCg cTTGgsJLnm0EICQZVYTBs3vPjkDixP1iOTuOW7ZTpGBqSDDK7WCs+2OJtBIF5qUY qzZGy0Q0q1k0m8q88AythwlefrXoA7VoR6VX3LJLKjhMDwArksvvEvgZ1O0DazJD +zB+UFl//pMQLm2rEtvJEqUfPrE/QfFe04CC+xq7/17+SK3SpGbBmh+nKD+tnVpn EpPbRqj7BLwBIpEQcI7OUv01Mtggm1c2fTJ3zJm35mbuUlBgEJcoc7HWo1dSBsfP gdAN0ViRo60kT3oZZBBTCYXxzH/tfmgaCP3bp8qRMFUqljPn4WT39P8vbLeeJSo= =ay3B -----END PGP SIGNATURE----- --vrIvrkNfjISMXRR9fLEtei98KMkJiVLDS--