From: Eric Blake <eblake@redhat.com>
To: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: libvir-list@redhat.com, kwolf@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/4] monitor: Less restrictive fd matching for fd sets
Date: Fri, 05 Oct 2012 12:35:11 -0600 [thread overview]
Message-ID: <506F285F.1000405@redhat.com> (raw)
In-Reply-To: <1349460425-30601-2-git-send-email-coreyb@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]
On 10/05/2012 12:07 PM, Corey Bryant wrote:
> Currently, in order to use a file descriptor that resides in an
> fd set, the access mode flag of the qemu_open() call has to be
> an exact match of the access mode flag of an fd in the requested
> fd set.
>
> This patch lightens up that restriction. For example, if QEMU
> attempts to qemu_open() "/dev/fdset/2" with O_RDONLY or O_WRONLY,
> and an fd in fd set 2 has O_RDWR, the call will now be successful.
I was right for wondering if we'd need this, back when fdsets were first
implemented. :)
However...
>
> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
> ---
> monitor.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/monitor.c b/monitor.c
> index a0e3ffb..34a968c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -2304,7 +2304,8 @@ int monitor_fdset_get_fd(int64_t fdset_id, int flags)
> return -1;
> }
>
> - if ((flags & O_ACCMODE) == (mon_fd_flags & O_ACCMODE)) {
> + if ((mon_fd_flags & O_ACCMODE) == O_RDWR ||
> + (mon_fd_flags & O_ACCMODE) == (flags & O_ACCMODE)) {
> return mon_fdset_fd->fd;
> }
Is this always the right fd to return? Suppose I create a set that
contains two fds, one O_RDONLY and another O_RDWR; and that the current
qemu_open() is requesting O_RDONLY. It feels like we would want to get
the O_RDONLY fd returned, even if it comes later in the set, since it is
nominally safer.
That is, I wonder if this should really be implemented as an iteration
over the set that selects the best possible match, where more than one
fd can match, but at the end of the iteration, we have the closest match
possible, rather than the first (possibly inexact) match.
--
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 --]
next prev parent reply other threads:[~2012-10-05 18:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 18:07 [Qemu-devel] [PATCH 0/4] command line fd passing using fd sets Corey Bryant
2012-10-05 18:07 ` [Qemu-devel] [PATCH 1/4] monitor: Less restrictive fd matching for " Corey Bryant
2012-10-05 18:35 ` Eric Blake [this message]
2012-10-05 18:50 ` Corey Bryant
2012-10-05 18:07 ` [Qemu-devel] [PATCH 2/4] monitor: Enable adding an inherited fd to an fd set Corey Bryant
2012-10-05 18:07 ` [Qemu-devel] [PATCH 3/4] qemu-config: Add -drive fd and opaque options Corey Bryant
2012-10-05 18:25 ` Blue Swirl
2012-10-05 18:30 ` Eric Blake
2012-10-05 18:44 ` Corey Bryant
2012-10-05 18:51 ` Eric Blake
2012-10-05 18:57 ` Corey Bryant
2012-10-05 18:48 ` Corey Bryant
2012-10-05 18:07 ` [Qemu-devel] [PATCH 4/4] blockdev: Process " Corey Bryant
2012-10-05 18:26 ` [Qemu-devel] [PATCH 0/4] command line fd passing using fd sets Eric Blake
2012-10-05 18:37 ` 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=506F285F.1000405@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).