On 03.02.2017 10:40, Vladimir Sementsov-Ogievskiy wrote:
> Add bitmap extension as specified in docs/specs/qcow2.txt.
> For now, just mirror extension header into Qcow2 state and check
> constraints.
> 
> For now, disable image resize if it has bitmaps. It will be fixed later.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsement...@virtuozzo.com>
> ---
>  block/qcow2.c | 127 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++---
>  block/qcow2.h |  24 +++++++++++
>  2 files changed, 145 insertions(+), 6 deletions(-)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 96fb8a8f16..d263ab1ed7 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c

[...]

> @@ -1151,9 +1237,13 @@ static int qcow2_open(BlockDriverState *bs, QDict 
> *options, int flags,
>          goto fail;
>      }
>  
> -    /* Clear unknown autoclear feature bits */
> -    if (!bs->read_only && !(flags & BDRV_O_INACTIVE) && 
> s->autoclear_features) {
> -        s->autoclear_features = 0;
> +    if (!need_update_header) {
> +        /* Clear unknown autoclear feature bits */
> +        need_update_header = s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK;
> +    }

Alternatively,

need_update_header |= s->autoclear_features & ~QCOW2_AUTOCLEAR_MASK;

would have worked just as well and might have been a bit easier to read.

Anyway:

Reviewed-by: Max Reitz <mre...@redhat.com>

> +
> +    if (need_update_header && !bs->read_only && !(flags & BDRV_O_INACTIVE)) {
> +        s->autoclear_features &= QCOW2_AUTOCLEAR_MASK;
>          ret = qcow2_update_header(bs);
>          if (ret < 0) {
>              error_setg_errno(errp, -ret, "Could not update qcow2 header");

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to