From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiAPV-0005as-4i for qemu-devel@nongnu.org; Fri, 22 Jun 2012 16:24:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SiAPT-0002fg-72 for qemu-devel@nongnu.org; Fri, 22 Jun 2012 16:24:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SiAPS-0002ZI-OO for qemu-devel@nongnu.org; Fri, 22 Jun 2012 16:24:51 -0400 Message-ID: <4FE4D488.5040604@redhat.com> Date: Fri, 22 Jun 2012 14:24:40 -0600 From: Eric Blake MIME-Version: 1.0 References: <1340390174-7493-1-git-send-email-coreyb@linux.vnet.ibm.com> <1340390174-7493-4-git-send-email-coreyb@linux.vnet.ibm.com> In-Reply-To: <1340390174-7493-4-git-send-email-coreyb@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig25DBA97550973999777A772B" Subject: Re: [Qemu-devel] [PATCH v4 3/7] qapi: Add pass-fd QMP command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corey Bryant Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig25DBA97550973999777A772B Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/22/2012 12:36 PM, Corey Bryant wrote: > This patch adds the pass-fd QMP command using the QAPI framework. > Like the getfd command, it is used to pass a file descriptor via > SCM_RIGHTS and associate it with a name. However, the pass-fd > command also returns the received file descriptor, which is a > difference in behavior from the getfd command, which returns > nothing. pass-fd also supports a boolean "force" argument that > can be used to specify that an existing file descriptor is > associated with the specified name, and that it should become a > copy of the newly passed file descriptor. > + if (replace) { > + /* the existing fd is replaced with the new fd */ > + close(monfd->fd); > + monfd->fd =3D fd; > + return fd; > + } > + > + if (copy) { Since 'replace' and 'copy' are never both true, should this instead be a tri-state enum argument instead of two independent bool arguments? > + /* the existing fd becomes a copy of the new fd */ > + if (dup2(fd, monfd->fd) =3D=3D -1) { Broken - you want to use dup3(fd, monfd->fd, O_CLOEXEC) (and fall back to dup2()+fcntl(F_GETFD/F_SETFD) on platforms where dup3 is not available; it has been proposed for the next revision of POSIX but right now is pretty much limited to Linux and Cygwin). Otherwise, you are undoing the fact that patch 1/7 just changed the 'getfd' list to always keep all its fds marked cloexec. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig25DBA97550973999777A772B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP5NSIAAoJEKeha0olJ0Nqp7cIAKpYP1KBfKn9IHbQ6kOFrsIh zMtGQhS3F310z7lSXUHnVqfQImyVTg0BJPEG8Dg32v0QFsZF6SDkaQkoBqaJPY2N 2IrWb8aCoZtoLXcFeslQIAVsonuWZ9eaG4DWHbItgaEGU00ohKQbq9kbAgu+FCHD RHt1vKMqptwILY3eSgtgCxjg5lpAotpmlqmuhe5ASfIwDLUUDuXfe4GWt5UHI3KQ U/Q8gH8BaPcGaa+fangTo3ImIh6dUqQN3P1EbSHFS+RAFfkEpeEgbX79RsF0u7Mm KtMwTBjbaliqXvE8dCsH0f8pH8brtGya+rzNjfD5MPz/AuX+PI1Gs1aeO9BFWVc= =VC0N -----END PGP SIGNATURE----- --------------enig25DBA97550973999777A772B--