All of lore.kernel.org
 help / color / mirror / Atom feed
From: Corey Bryant <coreyb@linux.vnet.ibm.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: 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: Thu, 18 Oct 2012 10:29:48 -0400	[thread overview]
Message-ID: <5080125C.5070107@linux.vnet.ibm.com> (raw)
In-Reply-To: <507EBA60.9000000@redhat.com>



On 10/17/2012 10:02 AM, Kevin Wolf wrote:
> Am 17.10.2012 06:16, schrieb Eric Blake:
>> 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).
>
> If you specify an FD number that isn't actually open when qemu is
> stared, you can get any FD that qemu opens internally. I think the
> correct answer to this problem is "then don't do that".
>

I'd also say "then don't do that".  Or maybe "why are you doing that?". 
But I'm not opposed to closing a corner case if it's not cluttering the 
code base.

>> 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?
>
> I think so. At least on my side it was intended to allow this.
>
>> And what if so, what then
>> happens on that monitor if I request that fdset 1 be removed?
>
> The same as with block devices: The fd stays open until the monitor
> connection is closed. A closed monitor also triggers fd garbage
> collection, so at this point the original fd would be closed (well,
> assuming that you had only one monitor).
>
> Kevin
>

True, but I think in this case we care more about the dup'd fd staying 
open than the fd in the fdset.  Remember that qemu_open() dups the fd 
from the fd set.  So assuming the open/close of the QMP fd occurs in 
qemu_open()/qemu_close(), the QMP fd would be a dup of the fd that was 
added to the fd set.  So if remove-fd removed the fd from the fdset, or 
it removed the entire fdset, the QMP fd would remain open until 
qemu_close() was called.  I'll try this out today to make sure but I 
don't think this is an issue.

-- 
Regards,
Corey Bryant

  parent reply	other threads:[~2012-10-18 14:35 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
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 [this message]
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=5080125C.5070107@linux.vnet.ibm.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.