qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH RFC 1/2] block: Limit opening of encrypted image


From: Kevin Wolf
Subject: Re: [Qemu-block] [PATCH RFC 1/2] block: Limit opening of encrypted images to qemu-img
Date: Wed, 11 Mar 2015 11:14:46 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Am 10.03.2015 um 18:26 hat Markus Armbruster geschrieben:
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  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?

Kevin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]