From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZ1qT-0001yL-6I for qemu-devel@nongnu.org; Wed, 23 Oct 2013 13:03:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VZ1qN-0002Ar-5j for qemu-devel@nongnu.org; Wed, 23 Oct 2013 13:03:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47289) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VZ1qM-0002Ab-U4 for qemu-devel@nongnu.org; Wed, 23 Oct 2013 13:03:39 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9NH3boc016947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 23 Oct 2013 13:03:37 -0400 Message-ID: <52680164.1090708@redhat.com> Date: Wed, 23 Oct 2013 19:03:32 +0200 From: Max Reitz MIME-Version: 1.0 References: <1382293700-20192-1-git-send-email-mreitz@redhat.com> <52659031.7010106@redhat.com> In-Reply-To: <52659031.7010106@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qcow2: Restore total_sectors value in save_vmstate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi On 2013-10-21 22:36, Eric Blake wrote: > 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 >> --- >> 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: Ah, right, sorry, I forgot. Max