qemu-devel
[Top][All Lists]
Advanced

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

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


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH RFC 1/2] block: Limit opening of encrypted images to qemu-img
Date: Wed, 11 Mar 2015 12:59:24 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Kevin Wolf <address@hidden> writes:

> 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?

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?



reply via email to

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