From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYMD2-0004Hm-WA for qemu-devel@nongnu.org; Mon, 21 Oct 2013 16:36:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VYMCy-0007AT-4M for qemu-devel@nongnu.org; Mon, 21 Oct 2013 16:36:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VYMCx-0007AE-Sk for qemu-devel@nongnu.org; Mon, 21 Oct 2013 16:36:12 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9LKa9nb005520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 21 Oct 2013 16:36:09 -0400 Message-ID: <52659031.7010106@redhat.com> Date: Mon, 21 Oct 2013 21:36:01 +0100 From: Eric Blake MIME-Version: 1.0 References: <1382293700-20192-1-git-send-email-mreitz@redhat.com> In-Reply-To: <1382293700-20192-1-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="jjMrMNwFdu5xiQDjtMI9AtUelCxO6fenO" 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: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jjMrMNwFdu5xiQDjtMI9AtUelCxO6fenO Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/20/2013 07:28 PM, Max Reitz wrote: > Since df2a6f29a5, bdrv_co_do_writev increases the total_sectors value o= f > a growable block devices on writes after the current end. This leads to= > the virtual disk apparently growing in qcow2_save_vmstate, which in tur= n > 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). >=20 > Fix this by restoring total_sectors at the end of qcow2_save_vmstate. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2.c | 5 +++++ > 1 file changed, 5 insertions(+) >=20 > @@ -1946,6 +1947,10 @@ static int qcow2_save_vmstate(BlockDriverState *= bs, QEMUIOVector *qiov, > bs->growable =3D 1; > ret =3D bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov); > bs->growable =3D growable; > + // bdrv_co_do_writev will have increased the total_sectors value t= o include > + // the VM state - the VM state is however not an actual part of th= e block > + // device, therefore, we need to restore the old value. > + bs->total_sectors =3D 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 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --jjMrMNwFdu5xiQDjtMI9AtUelCxO6fenO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSZZAxAAoJEKeha0olJ0NqU1wIAJxtlRkhzTLDUpsKfF8SEKwi AF7OocasgaoCUlrZWTsHWKKLEUNCs3vN9nlE2h7zCB32Iu461u3LqY0xVFBmq0Yg W50EqrfECJxXlATBayxwb88eL5MLq9pHz5ihpR8cGJh4x7XSK4CKkFXg7gc6AGss iULUfDoYVfTYy94ZqG5366uHmVduRuC50UcRY9mcKtTUT19aYe5jkpuLdeODaGN/ tkKLnrmbzs2jOwawgJFuGxM5GJEjl3zzXd11vy0gquOvXbRI1tw2BRs0xqDWC4iC nxgjYF7IZEOHnKn6V9zm44suVRv8KdoyHzSKk4kLnd5HjQDMGBZH71/hoqKtNZU= =G4hq -----END PGP SIGNATURE----- --jjMrMNwFdu5xiQDjtMI9AtUelCxO6fenO--