From: Kevin Wolf <kwolf@redhat.com>
To: Corey Bryant <coreyb@linux.vnet.ibm.com>
Cc: aliguori@us.ibm.com, eblake@redhat.com, qemu-devel@nongnu.org,
stefanha@linux.vnet.ibm.com
Subject: Re: [Qemu-devel] [PATCH 2/3] block: Add support to "open" /dev/fd/X filenames
Date: Mon, 04 Jun 2012 16:54:26 +0200 [thread overview]
Message-ID: <4FCCCC22.2050000@redhat.com> (raw)
In-Reply-To: <1338815410-24890-3-git-send-email-coreyb@linux.vnet.ibm.com>
Am 04.06.2012 15:10, schrieb Corey Bryant:
> The main goal of this patch series is to enable isolation of guest
> images that are stored on the same NFS mount. This can be achieved
> if the management application opens files for QEMU, and QEMU is
> restricted from opening files.
>
> This patch adds support to the block layer open paths to dup(X) a
> pre-opened file descriptor if the filename is of the format
> /dev/fd/X.
>
> One nice thing about this approach is that no new SELinux policy is
> required to prevent open of NFS files (files with type nfs_t). The
> virt_use_nfs boolean type simply needs to be set to false, and open
> will be prevented (yet dup will be allowed). For example:
>
> # setsebool virt_use_nfs 0
> # getsebool virt_use_nfs
> virt_use_nfs --> off
>
> Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>
> ---
> block.c | 15 +++++++++++++++
> block/raw-posix.c | 20 ++++++++++----------
> block/raw-win32.c | 4 ++--
> block/vdi.c | 5 +++--
> block/vmdk.c | 21 +++++++++------------
> block/vpc.c | 2 +-
> block/vvfat.c | 21 +++++++++++----------
> block_int.h | 13 +++++++++++++
> 8 files changed, 64 insertions(+), 37 deletions(-)
>
> diff --git a/block.c b/block.c
> index af2ab4f..8416313 100644
> --- a/block.c
> +++ b/block.c
> @@ -102,6 +102,21 @@ static BlockDriverState *bs_snapshots;
> /* If non-zero, use only whitelisted block drivers */
> static int use_bdrv_whitelist;
>
> +int file_open(const char *filename, int flags, mode_t mode)
> +{
> +#ifndef _WIN32
> + int fd;
> + const char *p;
> +
> + if (strstart(filename, "/dev/fd/", &p)) {
> + fd = atoi(p);
> + return dup(fd);
> + }
> +#endif
> +
> + return qemu_open(filename, flags, mode);
> +}
What's the reason for having separate file_open() and qemu_open()
functions? Are there places where you don't want allow to use /dev/fd?
Otherwise I would have expected that we just extend qemu_open().
I'd have the remaining open -> qemu_open conversions as a separate patch
then. They do not only add fd support as advertised in the commit
message, but also add O_CLOEXEC. I don't think that's bad, these are
likely bonus bug fixes, but they should be mentioned in the commit message.
Kevin
next prev parent reply other threads:[~2012-06-04 14:54 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-04 13:10 [Qemu-devel] [PATCH 0/3] file descriptor passing using getfd over QMP Corey Bryant
2012-06-04 13:10 ` [Qemu-devel] [PATCH 1/3] qmp/hmp: Add QMP getfd command that returns fd Corey Bryant
2012-06-04 14:45 ` Kevin Wolf
2012-06-04 15:57 ` Corey Bryant
2012-06-05 18:30 ` Luiz Capitulino
2012-06-06 14:04 ` Corey Bryant
2012-06-06 17:50 ` Luiz Capitulino
2012-06-06 19:42 ` Corey Bryant
2012-06-08 10:46 ` Daniel P. Berrange
2012-06-08 13:17 ` Corey Bryant
2012-06-04 13:10 ` [Qemu-devel] [PATCH 2/3] block: Add support to "open" /dev/fd/X filenames Corey Bryant
2012-06-04 14:32 ` Eric Blake
2012-06-04 15:51 ` Corey Bryant
2012-06-04 16:03 ` Eric Blake
2012-06-04 16:28 ` Corey Bryant
2012-06-04 16:36 ` Eric Blake
2012-06-04 16:40 ` Corey Bryant
2012-06-04 14:54 ` Kevin Wolf [this message]
2012-06-04 16:07 ` Corey Bryant
2012-06-04 13:10 ` [Qemu-devel] [PATCH 3/3] Sample server that opens image files for QEMU Corey Bryant
2012-06-04 15:01 ` Kevin Wolf
2012-06-04 16:15 ` 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=4FCCCC22.2050000@redhat.com \
--to=kwolf@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=coreyb@linux.vnet.ibm.com \
--cc=eblake@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@linux.vnet.ibm.com \
/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).