Received: from eggs.gnu.org ([2001:4830:134:3::10]:49438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bvXWx-0003V5-W0 for qemu-devel@nongnu.org; Sat, 15 Oct 2016 18:34:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bvXWx-00042m-3A for qemu-devel@nongnu.org; Sat, 15 Oct 2016 18:34:15 -0400 References: <1476522280-23211-1-git-send-email-ashijeetacharya@gmail.com> <1476522280-23211-4-git-send-email-ashijeetacharya@gmail.com> From: Max Reitz Message-ID: <28009132-97be-373e-9582-309fb94653e1@redhat.com> Date: Sun, 16 Oct 2016 00:34:03 +0200 MIME-Version: 1.0 In-Reply-To: <1476522280-23211-4-git-send-email-ashijeetacharya@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pCvLdds8SawWGxSjC1a0goxuELBbMfr2N" Subject: Re: [Qemu-devel] [v2 3/5] block/ssh: Use inet_connect_saddr() to establish socket connection List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Ashijeet Acharya , kwolf@redhat.com Cc: rjones@redhat.com, jcody@redhat.com, eblake@redhat.com, armbru@redhat.com, berrange@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pCvLdds8SawWGxSjC1a0goxuELBbMfr2N From: Max Reitz To: Ashijeet Acharya , kwolf@redhat.com Cc: rjones@redhat.com, jcody@redhat.com, eblake@redhat.com, armbru@redhat.com, berrange@redhat.com, kraxel@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, qemu-block@nongnu.org Message-ID: <28009132-97be-373e-9582-309fb94653e1@redhat.com> Subject: Re: [v2 3/5] block/ssh: Use inet_connect_saddr() to establish socket connection References: <1476522280-23211-1-git-send-email-ashijeetacharya@gmail.com> <1476522280-23211-4-git-send-email-ashijeetacharya@gmail.com> In-Reply-To: <1476522280-23211-4-git-send-email-ashijeetacharya@gmail.com> Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 15.10.2016 11:04, Ashijeet Acharya wrote: > Make inet_connect_saddr() in util/qemu-socktets.c public and use it *util/qemu-sockets.c > instead of inet_connect() because this directly takes the > InetSocketAddress to establish a socket connection for the SSH > block driver. >=20 > Signed-off-by: Ashijeet Acharya > --- > block/ssh.c | 5 +---- > include/qemu/sockets.h | 2 ++ > util/qemu-sockets.c | 2 +- > 3 files changed, 4 insertions(+), 5 deletions(-) As I said for patch 3, I'd split this one and pull the part of it that is making inet_connect_saddr() public in front of patch 2 and squash the rest into patch 2. >=20 > diff --git a/block/ssh.c b/block/ssh.c > index 3b18907..6420359 100644 > --- a/block/ssh.c > +++ b/block/ssh.c > @@ -666,13 +666,10 @@ static int connect_to_ssh(BDRVSSHState *s, QDict = *options, > goto err; > } > =20 > - /* Construct the host:port name for inet_connect. */ > - g_free(s->hostport); > port =3D atoi(s->inet->port); > - s->hostport =3D g_strdup_printf("%s:%d", s->inet->host, port); > =20 > /* Open the socket and connect. */ > - s->sock =3D inet_connect(s->hostport, errp); > + s->sock =3D inet_connect_saddr(s->inet, errp, NULL, NULL); > if (s->sock < 0) { > ret =3D -EIO; > goto err; > diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h > index 9eb2470..5589e68 100644 > --- a/include/qemu/sockets.h > +++ b/include/qemu/sockets.h > @@ -34,6 +34,8 @@ typedef void NonBlockingConnectHandler(int fd, Error = *err, void *opaque); > =20 > InetSocketAddress *inet_parse(const char *str, Error **errp); > int inet_connect(const char *str, Error **errp); > +int inet_connect_saddr(InetSocketAddress *saddr, Error **errp, > + NonBlockingConnectHandler *callback, void *opaq= ue); > =20 > NetworkAddressFamily inet_netfamily(int family); > =20 > diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c > index 4cef549..3411888 100644 > --- a/util/qemu-sockets.c > +++ b/util/qemu-sockets.c > @@ -412,7 +412,7 @@ static struct addrinfo *inet_parse_connect_saddr(In= etSocketAddress *saddr, > * function succeeds, callback will be called when the connection > * completes, with the file descriptor on success, or -1 on error. > */ > -static int inet_connect_saddr(InetSocketAddress *saddr, Error **errp, > +int inet_connect_saddr(InetSocketAddress *saddr, Error **errp, > NonBlockingConnectHandler *callback, voi= d *opaque) You should keep the second line aligned to the opening parenthesis. Max > { > Error *local_err =3D NULL; >=20 --pCvLdds8SawWGxSjC1a0goxuELBbMfr2N Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEvBAEBCAAZBQJYAq7bEhxtcmVpdHpAcmVkaGF0LmNvbQAKCRD0B9sAYdXPQLzp B/4oCEJEK2dVauIpjhe2Ndj/X+vLzi794mu2t4DAN8vf3YjgMbGjl8XqZ/DA9MRg xUSFOcg8FVeh+OGSnn+LeO0bLKWqX2ygcsYN48JN10RBlGjCpncbPjUWlZZK+Vua oaBV/Oj/BjxZozEWsGKjiitl6aeN4K5xlxn2V+x6n16wEQuzYlQX6ZzRnYU300+s Tjm46ZOfXr8xyrTpXhCpSOsCknD7stDQAJpN5W+D9f7BLBzT8jrrrzAeBL09aJAQ JqaVQRf2JK2u1/nPCk+rMVgr7Pq2+7SMqCc0y+v/f3o4+kO51G6o/CQueWBtzE6z WxAqkwJT2naJAKp/+up3TADz =jXnI -----END PGP SIGNATURE----- --pCvLdds8SawWGxSjC1a0goxuELBbMfr2N--