Am 28.08.2013 um 16:55 hat Max Reitz geschrieben:
> This adds an incompatible bit indicating corruption to qcow2. Any image
> with this bit set may not be written to unless for repairing (and
> subsequently clearing the bit if the repair has been successful).
> 
> Signed-off-by: Max Reitz <mre...@redhat.com>
> ---
>  block/qcow2.c              | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  block/qcow2.h              |  7 ++++++-
>  docs/specs/qcow2.txt       |  7 ++++++-
>  tests/qemu-iotests/031.out | 12 ++++++------
>  tests/qemu-iotests/036.out |  2 +-
>  5 files changed, 64 insertions(+), 9 deletions(-)

> @@ -402,6 +433,15 @@ static int qcow2_open(BlockDriverState *bs, QDict 
> *options, int flags)
>          goto fail;
>      }
>  
> +    if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) {
> +        /* Corrupt images may not be written to unless they are being 
> repaired
> +         */
> +        if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) {
> +            ret = -EACCES;

Perhaps a (q)error_report() call would be appropriate so that the user
isn't confused with only the "Permission denied" message (should it be
EPERM rather than EACCES, too? Or maybe EROFS?)

> +            goto fail;
> +        }
> +    }
> +

Kevin

Reply via email to