Am 10.02.2015 um 21:28 hat Max Reitz geschrieben:
> Add a creation option to qcow2 for setting the refcount order of images
> to be created, and respect that option's value.
> 
> This breaks some test outputs, fix them.
> 
> Signed-off-by: Max Reitz <mre...@redhat.com>
> Reviewed-by: Eric Blake <ebl...@redhat.com>
> Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
> ---
>  block/qcow2.c              |  20 +++++++++
>  include/block/block_int.h  |   1 +
>  tests/qemu-iotests/049.out | 108 
> ++++++++++++++++++++++-----------------------
>  tests/qemu-iotests/082.out |  41 ++++++++++++++---
>  tests/qemu-iotests/085.out |  38 ++++++++--------
>  5 files changed, 128 insertions(+), 80 deletions(-)
> 
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 65f7e91..99f6604 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -2077,6 +2077,17 @@ static int qcow2_create(const char *filename, QemuOpts 
> *opts, Error **errp)
>          goto finish;
>      }
>  
> +    refcount_bits = qemu_opt_get_number_del(opts, BLOCK_OPT_REFCOUNT_BITS,
> +                                            refcount_bits);

This truncates the uint64_t result to an int, so the code accepts inputs
like refcount_bits=4294967297 (treating it as refcount_bits=1).

> +    if (refcount_bits <= 0 || refcount_bits > 64 ||

Should we have a constant MAX_REFCOUNT_ORDER that is shared between
qcow2_open() and qcow2_create()?

> +        !is_power_of_2(refcount_bits))
> +    {
> +        error_setg(errp, "Refcount width must be a power of two and may not "
> +                   "exceed 64 bits");
> +        ret = -EINVAL;
> +        goto finish;
> +    }
> +

Kevin

Reply via email to