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 v2 3/3] qemu-config: Add new -add-fd	command line option
Date: Thu, 11 Oct 2012 09:55:14 -0600	[thread overview]
Message-ID: <5076EBE2.6090909@redhat.com> (raw)
In-Reply-To: <5076DB6C.7040003@linux.vnet.ibm.com>

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

On 10/11/2012 08:45 AM, Corey Bryant wrote:

>> Another missing validation check is for duplicate use.  With the monitor
>> command, you ALWAYS have a unique fd (thanks to SCM_RIGHTS).  But with
>> the command line, I can type 'qemu -add-fd fd=4,set=1 -add-fd
>> fd=4,set=2'.  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.
>>
> 
> I don't see this validation check for duplicate use of fd's being
> necessary.  Like you say below, in the QMP add-fd case we can add the
> same fd multiple times.  So we should be able to add the same fd
> multiple times via the command line.  The only difference between QMP
> and command line in this case is that the QMP fd is a dup and therefore
> a different number and the command line fd will be the same fd.  I'd
> prefer to leave this alone unless there's a compelling reason to block
> adding of the same fd.

There is a compelling reason to prevent duplicates among your sets:
qemu_close().

Suppose I add fd 4 into set 1 and 2, and then discard set 2 via monitor
commands.  Then, when qemu_close() drops the last reference to set 2, it
steps through and calls close() on all fds in that set, including fd 4.
 Oops - now set 1 is invalid, because it is tracking a closed fd.  And
worse, if qemu then does something else to open a new fd, it will get fd
4 again, and now set 1 will be tracking the WRONG fd.

-- 
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-11 15:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10 14:20 [Qemu-devel] [PATCH v2 0/3] command line fd passing using fd sets Corey Bryant
2012-10-10 14:20 ` [Qemu-devel] [PATCH v2 1/3] monitor: Allow add-fd to any specified fd set Corey Bryant
2012-10-10 21:49   ` Eric Blake
2012-10-11 14:29     ` Corey Bryant
2012-10-10 14:20 ` [Qemu-devel] [PATCH v2 2/3] monitor: Enable adding an inherited fd to an " Corey Bryant
2012-10-10 22:01   ` Eric Blake
2012-10-11 14:30     ` Corey Bryant
2012-10-11 11:25   ` Kevin Wolf
2012-10-11 15:04     ` Corey Bryant
2012-10-12  8:30       ` Kevin Wolf
2012-10-10 14:20 ` [Qemu-devel] [PATCH v2 3/3] qemu-config: Add new -add-fd command line option Corey Bryant
2012-10-10 22:31   ` Eric Blake
2012-10-11 14:45     ` Corey Bryant
2012-10-11 15:55       ` Eric Blake [this message]
2012-10-11 17:36         ` Corey Bryant
2012-10-11 16:04     ` [Qemu-devel] [libvirt] " Eric Blake
2012-10-11 16:11       ` Eric Blake
2012-10-11 17:49       ` 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=5076EBE2.6090909@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).