From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8Ty-0002Qj-D5 for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:39:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xl8Tr-0007N5-Re for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:39:06 -0500 Received: from ozlabs.org ([103.22.144.67]:46375) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xl8Tr-0007MY-Fg for qemu-devel@nongnu.org; Sun, 02 Nov 2014 22:38:59 -0500 Date: Mon, 3 Nov 2014 14:12:44 +1100 From: David Gibson Message-ID: <20141103031244.GH8949@voom.redhat.com> References: <1412358473-31398-1-git-send-email-dgilbert@redhat.com> <1412358473-31398-13-git-send-email-dgilbert@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="JI+G0+mN8WmwPnOn" Content-Disposition: inline In-Reply-To: <1412358473-31398-13-git-send-email-dgilbert@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 12/47] Handle bi-directional communication for fd migration List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Dr. David Alan Gilbert (git)" Cc: aarcange@redhat.com, yamahata@private.email.ne.jp, lilei@linux.vnet.ibm.com, quintela@redhat.com, cristian.klein@cs.umu.se, qemu-devel@nongnu.org, amit.shah@redhat.com, yanghy@cn.fujitsu.com --JI+G0+mN8WmwPnOn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Oct 03, 2014 at 06:47:18PM +0100, Dr. David Alan Gilbert (git) wrot= e: > From: Cristian Klein This patch really, really requires a rationale in the commit message. The reason it's necessary is certainly not obvious. >=20 > Signed-off-by: Cristian Klein > --- > migration-fd.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) >=20 > diff --git a/migration-fd.c b/migration-fd.c > index d2e523a..129da99 100644 > --- a/migration-fd.c > +++ b/migration-fd.c > @@ -31,13 +31,29 @@ > do { } while (0) > #endif > =20 > +static bool fd_is_socket(int fd) > +{ > + struct stat stat; > + int ret =3D fstat(fd, &stat); > + if (ret =3D=3D -1) { > + /* When in doubt say no */ > + return false; > + } > + return S_ISSOCK(stat.st_mode); > +} > + > void fd_start_outgoing_migration(MigrationState *s, const char *fdname, = Error **errp) > { > int fd =3D monitor_get_fd(cur_mon, fdname, errp); > if (fd =3D=3D -1) { > return; > } > - s->file =3D qemu_fdopen(fd, "wb"); > + > + if (fd_is_socket(fd)) { > + s->file =3D qemu_fopen_socket(fd, "wb"); > + } else { > + s->file =3D qemu_fdopen(fd, "wb"); > + } > =20 > migrate_fd_connect(s); > } > @@ -58,7 +74,11 @@ void fd_start_incoming_migration(const char *infd, Err= or **errp) > DPRINTF("Attempting to start an incoming migration via fd\n"); > =20 > fd =3D strtol(infd, NULL, 0); > - f =3D qemu_fdopen(fd, "rb"); > + if (fd_is_socket(fd)) { > + f =3D qemu_fopen_socket(fd, "rb"); > + } else { > + f =3D qemu_fdopen(fd, "rb"); > + } > if(f =3D=3D NULL) { > error_setg_errno(errp, errno, "failed to open the source descrip= tor"); > return; --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --JI+G0+mN8WmwPnOn Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJUVvKsAAoJEGw4ysog2bOSlRkP/AzOfLjlJsUTvNkXFA4B9/z5 jivDaRhXEtZBi90TH9DLtbVYozdEIJw40x8XKSylYDbHU6infoROCdn8YtONdOav 5dUksAHLhpV0dOx+0QfLsM+NNhgeMThF/EM5Ebj1xrsFDIsub8G/XnNVmRbT8HrD X/PaZy42MHriAyiQDclN2Uo8uWsG60g2a6JYmYPLN+UMa7X83rFNMfA9xS3f6Zcy pxrjDVfuQwiDpUXj5xRR00a9ml0tDpGzKZCEKMijmRHsOtJszKmuNRJ19scDPrYe B/oLVJdRkuuDO/II5IezVw29BtJj9OdphrhGLslZnKM6MiWWnr1/ojec4e/wnIOr /2ZNNGAeOlg3H/YapJ1BDgw7Y7Zy1x5ZyYcvx73RV+4nKosbJCTc10nHkq6fGSQb iddJqrhdNmsxSCLm/nWnH0P0VlO1PzdrZqgOe6Lei1DHu2fdtONTYMKfMPhkWwSj DX2V60GxCH3bD/lEJaR1tnxtDQmN55x7bJGEEzkSt9sM2l4c4dUAVUctOCZkSu12 i1ANo4bMl0SNFvI2PXQgtPa/K+BYIUHMqyz2xauQMS9+3O3kCeUnq2ya13k4vF3V y3sKD992wBOfJjZ/vsHvPK66cKDx+peiSJpB0Mnec9LsDWMzzchfMmo5OGWP7YPZ E8y+3H1Zr3ztQiW8gG/4 =F23S -----END PGP SIGNATURE----- --JI+G0+mN8WmwPnOn--