From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsDBQ-0002ww-Sp for qemu-devel@nongnu.org; Thu, 06 Oct 2016 14:14:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bsDBK-0005XK-Qw for qemu-devel@nongnu.org; Thu, 06 Oct 2016 14:14:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48672) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bsDBK-0005X7-Gd for qemu-devel@nongnu.org; Thu, 06 Oct 2016 14:14:10 -0400 References: <1475772018-27484-1-git-send-email-stefanha@redhat.com> <1475772018-27484-4-git-send-email-stefanha@redhat.com> From: Eric Blake Message-ID: <96805a9d-3211-51fa-b0f3-677fb3905696@redhat.com> Date: Thu, 6 Oct 2016 13:14:08 -0500 MIME-Version: 1.0 In-Reply-To: <1475772018-27484-4-git-send-email-stefanha@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AwAgF47PCdnEaq1PJshenF3Jc0rBRWkq7" Subject: Re: [Qemu-devel] [PATCH 3/4] sockets: add AF_VSOCK support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --AwAgF47PCdnEaq1PJshenF3Jc0rBRWkq7 From: Eric Blake To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Michael Roth Message-ID: <96805a9d-3211-51fa-b0f3-677fb3905696@redhat.com> Subject: Re: [Qemu-devel] [PATCH 3/4] sockets: add AF_VSOCK support References: <1475772018-27484-1-git-send-email-stefanha@redhat.com> <1475772018-27484-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1475772018-27484-4-git-send-email-stefanha@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/06/2016 11:40 AM, Stefan Hajnoczi wrote: > Add the AF_VSOCK address family so that qemu-ga will be able to use > virtio-vsock. >=20 > The AF_VSOCK address family uses address tuples. The cid i= s > the unique identifier comparable to an IP address. AF_VSOCK does not > use name resolution so it's seasy to convert between struct sockaddr_vm= s/seasy/easy/ > and strings. >=20 > This patch defines a VsockSocketAddress instead of trying to piggy-back= > on InetSocketAddress. This is cleaner in the long run since it avoids > lots of IPv4 vs IPv6 vs vsock special casing. At any rate, it seems like SocketAddress would be a better fit for a tri-state union between InetSocketAddress, UnixSocketAddress, and VnetSocketAddress. >=20 > Signed-off-by: Stefan Hajnoczi > --- > qapi-schema.json | 23 +++++- > util/qemu-sockets.c | 222 ++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 2 files changed, 244 insertions(+), 1 deletion(-) >=20 > +## > # @SocketAddress > # > # Captures the address of a socket, which could also be a named file d= escriptor > @@ -3027,6 +3047,7 @@ > 'data': { > 'inet': 'InetSocketAddress', > 'unix': 'UnixSocketAddress', > + 'vsock': 'VsockSocketAddress', > 'fd': 'String' } } Which is in fact what you did. > +static int vsock_connect_addr(const struct sockaddr_vm *svm, bool *in_= progress, > + ConnectState *connect_state, Error **err= p) > +{ > + int sock, rc; > + > + *in_progress =3D false; > + > + sock =3D qemu_socket(AF_VSOCK, SOCK_STREAM, 0); > + if (sock < 0) { > + error_setg_errno(errp, errno, "Failed to create socket"); > + return -1; > + } > + if (connect_state !=3D NULL) { > + qemu_set_nonblock(sock); Isn't the presence of vsock support sufficient to prove that we have SOCK_NONBLOCK support as part of our socket() call? In which case, wouldn't it be better to pass that option up front to atomically get a non-blocking socket, rather than having to change its state after the fac= t? > +static VsockSocketAddress *vsock_parse(const char *str, Error **errp) > +{ > + VsockSocketAddress *addr =3D NULL; > + char cid[33]; > + char port[33]; > + > + if (sscanf(str, "%32[^:]:%32[^,]", cid, port) !=3D 2) { Would it be a wise idea to also use %n to ensure that you aren't ignoring trailing garbage? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --AwAgF47PCdnEaq1PJshenF3Jc0rBRWkq7 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/ iQEcBAEBCAAGBQJX9pRwAAoJEKeha0olJ0NqiMwH/0Pf4Op05OEA3axA8dCyK1ui zAvsb7imHxm7Lwu+lzfUtk1n4rLE4S/fgazdB4+jtq8mPhYGgDJCq1wHBxczk6nt v7E5E+PdRCPDHT0KW/OVYgioQicf4jhIbGqmYztsC887Mairl9kLC5Sz+HL1J5EN EMBq4cfjDRRyY9mNbA9N1yNUmRgEtSPH6iwClcH9v8JlEohtquSV3ZfN4qkdrGCp tSBjjJwEoSnl/h8KR2HqeOjzFpAm9zA9hFgszkXRVsOU3M0JASOAZ0ci6ZKtFpJF aGc1h42PgqS/HHqMA/9t58gW6zu7vbPxUMvJqtxMF/C2L6KQjogkPiSpZixrn4w= =e9do -----END PGP SIGNATURE----- --AwAgF47PCdnEaq1PJshenF3Jc0rBRWkq7--