From: Kevin Wolf <kwolf@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org,
stefanha@redhat.com, kraxel@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC 1/2] block: Limit opening of encrypted images to qemu-img
Date: Wed, 11 Mar 2015 13:22:10 +0100 [thread overview]
Message-ID: <20150311122210.GG6628@noname.str.redhat.com> (raw)
In-Reply-To: <87a8zjn3s3.fsf@blackfin.pond.sub.org>
Am 11.03.2015 um 12:59 hat Markus Armbruster geschrieben:
> Kevin Wolf <kwolf@redhat.com> writes:
>
> > Am 10.03.2015 um 18:26 hat Markus Armbruster geschrieben:
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >> block/qcow.c | 5 +++++
> >> block/qcow2.c | 5 +++++
> >> include/block/block.h | 3 +--
> >> qemu-img.c | 1 +
> >> 4 files changed, 12 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/block/qcow.c b/block/qcow.c
> >> index 0558969..f54fc86 100644
> >> --- a/block/qcow.c
> >> +++ b/block/qcow.c
> >> @@ -155,6 +155,11 @@ static int qcow_open(BlockDriverState *bs, QDict *options, int flags,
> >> }
> >> s->crypt_method_header = header.crypt_method;
> >> if (s->crypt_method_header) {
> >> + if (!(flags & BDRV_O_CRYPT_OK)) {
> >> + error_setg(errp, "image is encrypted, use qemu-img to decrypt it");
> >> + ret = -EINVAL;
> >> + goto fail;
> >> + }
> >> bs->encrypted = 1;
> >> }
> >> s->cluster_bits = header.cluster_bits;
> >> diff --git a/block/qcow2.c b/block/qcow2.c
> >> index 50e0a94..b12c67a 100644
> >> --- a/block/qcow2.c
> >> +++ b/block/qcow2.c
> >> @@ -693,6 +693,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, int flags,
> >> }
> >> s->crypt_method_header = header.crypt_method;
> >> if (s->crypt_method_header) {
> >> + if (!(flags & BDRV_O_CRYPT_OK)) {
> >> + error_setg(errp, "image is encrypted, use qemu-img to decrypt it");
> >> + ret = -EINVAL;
> >> + goto fail;
> >> + }
> >> bs->encrypted = 1;
> >> }
> >
> > Can we do this in bdrv_open_common() instead of duplicating the code in
> > two drivers?
>
> I looked for a better place to do this, but couldn't find one that
> *obviously* dominates the bdrv_open() methods, so I put it into the
> block drivers.
>
> Can you explain why bdrv_open_common() cannot be bypassed?
Because it's the only place in qemu that calls drv->bdrv_open() and
drv->bdrv_file_open(). (Except for bdrv_snapshot_goto(), which does a
close/open on an already opened image.)
Everything else is just a - potentially indirect - caller of
bdrv_open_common().
Kevin
next prev parent reply other threads:[~2015-03-11 12:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-10 17:26 [Qemu-devel] [PATCH RFC 0/2] Limit support for encrypted images to qemu-img Markus Armbruster
2015-03-10 17:26 ` [Qemu-devel] [PATCH RFC 1/2] block: Limit opening of " Markus Armbruster
2015-03-10 18:15 ` Daniel P. Berrange
2015-03-11 8:57 ` Markus Armbruster
2015-03-10 18:21 ` Eric Blake
2015-03-11 10:14 ` Kevin Wolf
2015-03-11 11:59 ` Markus Armbruster
2015-03-11 12:22 ` Kevin Wolf [this message]
2015-03-10 17:26 ` [Qemu-devel] [PATCH RFC 2/2] block: Drop code supporting encryption outside qemu-img Markus Armbruster
2015-03-10 18:25 ` Eric Blake
2015-03-10 18:13 ` [Qemu-devel] [PATCH RFC 0/2] Limit support for encrypted images to qemu-img Daniel P. Berrange
2015-03-11 8:55 ` Markus Armbruster
2015-03-11 9:59 ` Daniel P. Berrange
2015-03-11 10:10 ` Kevin Wolf
2015-03-11 12:05 ` Markus Armbruster
2015-03-12 16:58 ` Paolo Bonzini
2015-03-13 8:26 ` Kevin Wolf
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=20150311122210.GG6628@noname.str.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=kraxel@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).