qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Re: [Qemu-devel] [Qemu-block][PATCH]block/truncate: qcow2’s  resize status is not showed to
       [not found] <1310916852.125556.1436925467887.JavaMail.weblogic@mdmob08>
@ 2015-07-15  8:50 ` Kevin Wolf
  0 siblings, 0 replies; only message in thread
From: Kevin Wolf @ 2015-07-15  8:50 UTC (permalink / raw)
  To: 김태하; +Cc: kthguru, qemu-devel, qemu-block

Am 15.07.2015 um 03:57 hat 김태하 geschrieben:
> To put it briefly, when resize qcow2 image, the "file" tool detected increased
> size. However, the "ls", “stat”, and “du” utility still don't know increased
> size. The following patch enables to let userland tools - ls, du, stat - know
> and apply changed size after resizing qcow2 image created by the qemu-img tool.
> Currently, can know only using “file” utility without this patch.

Even your goal is already wrong. For any image format other than raw,
the file size doesn't represent the virtual disk size. It's just the
size that the image file actually takes on the host, and that's
something entirely different.

The correct way to check the virtual disk size is 'qemu-img info'.

> ======================
> 
> Signed-off-by: Taeha Kim <thlab.kim@samsung.com>
> 
> diff --git a/block.c b/block.c
> index 5e80336..277adf3 100644
> --- a/block.c
> +++ b/block.c
> @@ -2473,6 +2473,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;
> }

Even if your goal were right, this wouldn't work because images don't
have to be local files.

And to be clear: Truncating the image file is not only misguided and
unnecessary, but it will actively corrupt image files, because qcow2
images can be larger than the virtual disk size (e.g. if you have taken
some snapshots). In this case you would destroy the image by throwing
away part of it.

Kevin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-07-15  8:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1310916852.125556.1436925467887.JavaMail.weblogic@mdmob08>
2015-07-15  8:50 ` [Qemu-devel] [Qemu-block][PATCH]block/truncate: qcow2’s resize status is not showed to Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).