From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMLGJ-0005Z2-Cl for qemu-devel@nongnu.org; Thu, 11 Oct 2012 12:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMLGD-0000M6-DM for qemu-devel@nongnu.org; Thu, 11 Oct 2012 12:05:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65422) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMLGD-0000Ln-4g for qemu-devel@nongnu.org; Thu, 11 Oct 2012 12:05:21 -0400 Message-ID: <5076EDF4.1010301@redhat.com> Date: Thu, 11 Oct 2012 10:04:04 -0600 From: Eric Blake MIME-Version: 1.0 References: <1349878805-16352-1-git-send-email-coreyb@linux.vnet.ibm.com> <1349878805-16352-4-git-send-email-coreyb@linux.vnet.ibm.com> <5075F727.1060608@redhat.com> In-Reply-To: <5075F727.1060608@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig9E091C8131C3F2527D752D62" Subject: Re: [Qemu-devel] [libvirt] [PATCH v2 3/3] qemu-config: Add new -add-fd command line option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, libvir-list@redhat.com, Corey Bryant , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9E091C8131C3F2527D752D62 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/10/2012 04:31 PM, Eric Blake wrote: > Another missing validation check is for duplicate use. With the monito= r > command, you ALWAYS have a unique fd (thanks to SCM_RIGHTS). But with > the command line, I can type 'qemu -add-fd fd=3D4,set=3D1 -add-fd > fd=3D4,set=3D2'. Oops - I've now corrupted your set layout, unless you= > validate that every fd requested in -add-fd does not already reside in > any existing set. >=20 > Thinking aloud: > On the other hand, being able to pass in one fd to multiple sets MIGHT > be useful; in the SCM_RIGHTS monitor command case, I can pass the same > fd from the management perspective into multiple sets, even though in > qemu's perspective, there will be multiple fds created (one per call). > Perhaps instead of directly adding the inherited fd to a set, and havin= g > to then sweep all sets to check for duplicates, it might make sense to > add dup(fd) to a set, so that if I call: >=20 > qemu -add-fd fd=3D4,set=3D1 -add-fd fd=3D4,set=3D2 -add-fd fd=3D5,set=3D= 2 >=20 > what REALLY happens is that qemu adds dup(4)=3D=3D6 to set 1, dup(4)=3D= =3D7 to > set 2, and dup(5)=3D=3D8 to set 3. Then, after all ALL -add-fd have be= en > processed, qemu then does another pass through them calling close(4) an= d > close(5) (to avoid holding the original fds open indefinitely if the > corresponding sets are discarded). Another idea: a hybrid approach - the _first_ -add-fd 4 directly adds 4 to the set, all other -add-fd 4 end up adding dup(4) instead (well, fcntl(F_DUPFD_CLOEXEC), but you get the picture). That is, do the duplicate scanning, and if there is no duplicate, use the fd directly; if there IS a duplicate, then put a unique fd number as a copy into the remaining sets. That way, you don't have to do a final close() sweep across the -add-fd arguments passed on the command line, and you still don't have to worry about duplicated fds across multiple sets causing mayhem in qemu_close(). --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig9E091C8131C3F2527D752D62 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://www.enigmail.net/ iQEcBAEBCAAGBQJQdu30AAoJEKeha0olJ0Nq0dsH/2Y1PQpJIBhsXumMi6sthKYY 5AvpypeplzF3otEDZnv2hEMNu+a0yxmEv/CLmtJAadhBevTu4Xki2kJf7t4C1G7X xMr6XiqQBf/Lfvn5jiqIZ/D+kYxSowAAYk6Tjb1wB6GKYVCUz4XbtXf6Btj+UyxY jwP1ckvhee2Cbv6iBek7t6O/TbApsF1SUTiErbDNx4qtiH2tVBFsfX3GaclgEEBi /KsOOvuzZocVPcAoBBXMicPrk0+v2pwNb0PdFCSjfhFBsTqhDjCh1/4s8f2iiqS+ YEiwNQ0tFSPtW8Vp+yXCrzw+6OhwmaKDLlR4sSedM5hzMdy0AdQYrWuF4yVdrsY= =0vHt -----END PGP SIGNATURE----- --------------enig9E091C8131C3F2527D752D62--