On Thu, Dec 19, 2013 at 10:27:41AM +0800, Hu Tao wrote:
> -static int preallocate(BlockDriverState *bs)
> +static int preallocate(BlockDriverState *bs, enum prealloc_mode mode)
> {
> uint64_t nb_sectors;
> uint64_t offset;
> @@ -1395,9 +1395,19 @@ static int preallocate(BlockDriverState *bs)
> int ret;
> QCowL2Meta *meta;
>
> + assert(mode != PREALLOC_OFF);
> +
> nb_sectors = bdrv_getlength(bs) >> 9;
> offset = 0;
>
> + if (mode == PREALLOC_FULL) {
> + ret = bdrv_preallocate(bs->file, 0, bdrv_getlength(bs));
This doesn't make sense since it fails to factor in qcow2 metadata and
the file layout.