From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnuCL-000136-RP for qemu-devel@nongnu.org; Mon, 10 Nov 2014 14:00:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XnuCC-00065d-DT for qemu-devel@nongnu.org; Mon, 10 Nov 2014 14:00:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53678) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XnuCC-00065W-4x for qemu-devel@nongnu.org; Mon, 10 Nov 2014 14:00:12 -0500 Message-ID: <54610B33.4080107@redhat.com> Date: Mon, 10 Nov 2014 12:00:03 -0700 From: Eric Blake MIME-Version: 1.0 References: <1415627159-15941-1-git-send-email-mreitz@redhat.com> <1415627159-15941-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1415627159-15941-2-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ruL4AeXHjI58t6SecQL3Gd9gJbhMWMjOw" Subject: Re: [Qemu-devel] [PATCH 01/21] qcow2: Add two new fields to BDRVQcowState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --ruL4AeXHjI58t6SecQL3Gd9gJbhMWMjOw Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/10/2014 06:45 AM, Max Reitz wrote: > Add two new fields regarding refcount information (the bit width of > every entry and the maximum refcount value) to the BDRVQcowState. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2-refcount.c | 2 +- > block/qcow2.c | 9 +++++++++ > block/qcow2.h | 2 ++ > 3 files changed, 12 insertions(+), 1 deletion(-) Reviewed-by: Eric Blake > +++ b/block/qcow2.c > @@ -684,6 +684,15 @@ static int qcow2_open(BlockDriverState *bs, QDict = *options, int flags, > goto fail; > } > s->refcount_order =3D header.refcount_order; > + s->refcount_bits =3D 1 << s->refcount_order; Not shown is the context where a few lines before still enforces refcount_order=3D=3D4, so this doesn't overflow. When later patches rela= x that, I'll make sure we don't overflow here as well. > + if (s->refcount_order < 6) { > + s->refcount_max =3D (UINT64_C(1) << s->refcount_bits) - 1; I don't see the UINT64_C macro get much use, but like it better than casting :) > + } else { I don't know if Coverity might complain about dead code during bisection (since we can't get here until we relax refcount_order to not be forced to 4), but that's a layer beyond making sure 'make check' works so I don't care. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --ruL4AeXHjI58t6SecQL3Gd9gJbhMWMjOw 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUYQszAAoJEKeha0olJ0NqKtoH/i+XCPaQA0bd1WTvmTJ3oJ4V 4pX4VpeV4vS9KBudciBH1+Ygoi2IhXyJD0jQBd+Pe+HGxcKkfvdxDniNCL9I/hZV m+B2BWY1ZJnlLS0XKZ2jIUNGipGHbgle+s/RLX8kwxgLrIDQ2CdtfTG0ZFwxxNVO P+JwZ/fjSJ4bBBIX2Wx2J9vtKMCNdOaPFFpS6fsd6cs/J+POER/fl5tHBAVvr/gr 20MN5qdR5kgSIkuQrTtEdsVm/0FGogQYcMpw/+GLmYizEhhKFinYQXKcwXlPGZsz l6gF0fY3p25KQjEBl/KjaM2luf4Kciwb6/CcEjfu6VFXunHbH2D0X568kSaJI0g= =Cvq8 -----END PGP SIGNATURE----- --ruL4AeXHjI58t6SecQL3Gd9gJbhMWMjOw--