[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] qcow2: Restore total_sectors value in save_vmst
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH] qcow2: Restore total_sectors value in save_vmstate |
Date: |
Mon, 21 Oct 2013 21:36:01 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
On 10/20/2013 07:28 PM, Max Reitz wrote:
> Since df2a6f29a5, bdrv_co_do_writev increases the total_sectors value of
> a growable block devices on writes after the current end. This leads to
> the virtual disk apparently growing in qcow2_save_vmstate, which in turn
> affects the disk size captured by the internal snapshot taken directly
> afterwards through e.g. the HMP savevm command. Such a "grown" snapshot
> cannot be loaded after reopening the qcow2 image, since its disk size
> differs from the actual virtual disk size (writing a VM state does not
> actually increase the virtual disk size).
>
> Fix this by restoring total_sectors at the end of qcow2_save_vmstate.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qcow2.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> @@ -1946,6 +1947,10 @@ static int qcow2_save_vmstate(BlockDriverState *bs,
> QEMUIOVector *qiov,
> bs->growable = 1;
> ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov);
> bs->growable = growable;
> + // bdrv_co_do_writev will have increased the total_sectors value to
> include
> + // the VM state - the VM state is however not an actual part of the block
> + // device, therefore, we need to restore the old value.
> + bs->total_sectors = total_sectors;
It looks like // comments aren't forbidden, but also uncommon; I don't
know if /**/ would be better. At any rate:
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature