From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55618) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOL3G-0003PU-Li for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:16:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOL3F-0000fD-4z for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:16:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33801) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOL3E-0000f3-SX for qemu-devel@nongnu.org; Wed, 17 Oct 2012 00:16:13 -0400 Message-ID: <507E3103.1020202@redhat.com> Date: Tue, 16 Oct 2012 22:16:03 -0600 From: Eric Blake MIME-Version: 1.0 References: <1350411046-2453-1-git-send-email-coreyb@linux.vnet.ibm.com> In-Reply-To: <1350411046-2453-1-git-send-email-coreyb@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigDE3AE30C7C7F9329F02D13D8" Subject: Re: [Qemu-devel] [PATCH v3 4/4] qemu-config: Add new -add-fd command line option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Corey Bryant Cc: kwolf@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDE3AE30C7C7F9329F02D13D8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/16/2012 12:10 PM, Corey Bryant wrote: > This option can be used for passing file descriptors on the > command line. It mirrors the existing add-fd QMP command which > allows an fd to be passed to QEMU via SCM_RIGHTS and added to an > fd set. >=20 > This can be combined with commands such as -drive to link file > descriptors in an fd set to a drive: >=20 > qemu-kvm -add-fd fd=3D3,set=3D2,opaque=3D"rdwr:/path/to/file" > -add-fd fd=3D4,set=3D2,opaque=3D"rdonly:/path/to/file" > -drive file=3D/dev/fdset/2,index=3D0,media=3Ddisk >=20 > This example adds dups of fds 4 and 5, and the accompanying opaque s/4 and 5/3 and 4/ > strings to the fd set with ID=3D2. qemu_open() already knows how > to handle a filename of this format. qemu_open() searches the > corresponding fd set for an fd and when it finds a match, QEMU > goes on to use a dup of that fd just like it would have used an > fd that it opened itself. >=20 > Signed-off-by: Corey Bryant > --- > v2: > - The -add-fd option is new in v2 (eblake@redhat.com) >=20 > v3: > - Require passed fd to be > stderr (eblake@redhat.com) > - Changed fds in examples to fd=3D3 and fd=3D4 > - Add dup of passed fd to fd set and close passed fds after > processing all -add-fd commands (eblake@redhat.com) I'm still seeing the corner case of: qemu-kvm -add-fd fd=3D3,set=3D1 -add-fd fd=3D4,set=3D2 4<&- where the dup(3) will populate fd 4 prior to the point where we get to process the -add-fd fd=3D4 command to notice that the user started qemu-kvm with fd 4 closed, and thus qemu will silently proceed to use the wrong fd. On the other hand, I'm not sure if that corner case is worth worrying about, or if we just chalk it up to user stupidity (aka libvirt programmer stupidity) if they did something like that (most likely, because the management app forgot to clear FD_CLOEXEC before exec()ing qemu-kvm). Hmm, this makes me wonder if I can do something crazy like: qemu-kvm -add-fd fd=3D4,set=3D1 -qmp /dev/fdset/1 to open a monitor on the fd I just passed in? And what if so, what then happens on that monitor if I request that fdset 1 be removed? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigDE3AE30C7C7F9329F02D13D8 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/ iQEcBAEBCAAGBQJQfjEDAAoJEKeha0olJ0NqJHYH/REwjr7uorVgk3ckJzsruIHl xzl5IVMiDSs4XZBUev5JGxVuVeXmFBvUJ3Mx6X0jI1J//7B7y5O0groMGMMG65M3 bY/Am7IRrAQFyKtUD7fHMZR+F0+OGA/EAy28lOVrDuBCNpyTbw5HAEEHV9tfOfJQ hjOc39OblW+rTSdDCTntAMBKYYZD/qTwJb9w7FmkfaX8yRsev4loFh4dp1IlcrAl xzenbe+RjGK1Tcuk28jfiHjm1TZbagNOwbDiS8iwYprJ1tA0IJX9Cd3ZRk06mIrF lP+t+5Vs0Ihege94/G5Y7DQbTBaIAxvN08MpYU3mnEIZPDDN5sNH95AVMZbkO84= =8T7F -----END PGP SIGNATURE----- --------------enigDE3AE30C7C7F9329F02D13D8--