qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, libvir-list@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 4/4] qemu-config: Add new -add-fd command line option
Date: Tue, 16 Oct 2012 22:16:03 -0600	[thread overview]
Message-ID: <507E3103.1020202@redhat.com> (raw)
In-Reply-To: <1350411046-2453-1-git-send-email-coreyb@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2301 bytes --]

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.
> 
> This can be combined with commands such as -drive to link file
> descriptors in an fd set to a drive:
> 
>     qemu-kvm -add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
>              -add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
>              -drive file=/dev/fdset/2,index=0,media=disk
> 
> 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=2.  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.
> 
> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
> ---
> v2:
>  - The -add-fd option is new in v2 (eblake@redhat.com)
> 
> v3:
>   - Require passed fd to be > stderr (eblake@redhat.com)
>   - Changed fds in examples to fd=3 and fd=4
>   - 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=3,set=1 -add-fd fd=4,set=2 4<&-

where the dup(3) will populate fd 4 prior to the point where we get to
process the -add-fd fd=4 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=4,set=1 -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?

-- 
Eric Blake   eblake@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 617 bytes --]

  reply	other threads:[~2012-10-17  4:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-16 18:10 [Qemu-devel] [PATCH v3 4/4] qemu-config: Add new -add-fd command line option Corey Bryant
2012-10-17  4:16 ` Eric Blake [this message]
2012-10-17 14:02   ` Kevin Wolf
2012-10-17 15:01     ` Eric Blake
2012-10-17 15:03       ` Kevin Wolf
2012-10-18 14:34         ` Corey Bryant
2012-10-18 14:29     ` Corey Bryant
2012-10-18 18:50       ` Corey Bryant
2012-10-18 13:48   ` Corey Bryant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=507E3103.1020202@redhat.com \
    --to=eblake@redhat.com \
    --cc=coreyb@linux.vnet.ibm.com \
    --cc=kwolf@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).