qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] No change in userland tools after resizing qcow2 image


From: Paolo Bonzini
Subject: Re: [Qemu-block] No change in userland tools after resizing qcow2 image
Date: Sun, 19 Jul 2015 19:48:36 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1


On 19/07/2015 11:15, Taeha Kim wrote:
> However, the "ls", “stat”, and “du” utility still don't know how many
> change size of image is changed.

That's not a bug.  qcow2 images only need as much space as required,
plus some for the metadata.  This lets you use small files, and copy
them around without relying on the filesystem's support for sparse files.

> In addtion, "file" utility sometimes don't know qcow2 image format's
> version as follows.
> 
> $ file 100G.qcow2
> 100G.qcow2: QEMU QCOW Image (Unknown)

Use qemu-img info instead, or report a bug for the file utility.

The patch below does not work correctly because:

1) bs->filename is not always valid;

2) even if bs->filename is valid, truncate() does not apply to all
backends, for example it cannot be applied to the backends where
bs->filename is a URL;

3) it can corrupt the image if it is larger than the requested size (for
example because of the metadata).

Paolo

> diff --git a/block.c b/block.c
> index d088ee0..93427f8 100644
> --- a/block.c
> +++ b/block.c
> @@ -2529,6 +2529,9 @@ int bdrv_truncate(BlockDriverState *bs, int64_t offset)
>         if (bs->blk) {
>             blk_dev_resize_cb(bs->blk);
>         }
> +       if (ret == 0) {
> +           ret = truncate(bs->filename, offset);
> +       }
>     }
>     return ret;
> }



reply via email to

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