From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNUnZ-0005UP-UP for qemu-devel@nongnu.org; Fri, 29 Aug 2014 18:37:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XNUnU-0005Kh-Vk for qemu-devel@nongnu.org; Fri, 29 Aug 2014 18:37:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:26338) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XNUnU-0005KS-MN for qemu-devel@nongnu.org; Fri, 29 Aug 2014 18:37:32 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7TMbWlZ007006 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 29 Aug 2014 18:37:32 -0400 Message-ID: <540100AB.4090004@redhat.com> Date: Fri, 29 Aug 2014 16:37:31 -0600 From: Eric Blake MIME-Version: 1.0 References: <1409348727-17183-1-git-send-email-mreitz@redhat.com> <1409348727-17183-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1409348727-17183-3-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="C6TJiD4q4d1hkMPQ7FQPgED5AXmgcF7ap" Subject: Re: [Qemu-devel] [PATCH 2/2] docs/qcow2: Correct refcount_block_entries 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) --C6TJiD4q4d1hkMPQ7FQPgED5AXmgcF7ap Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 08/29/2014 03:45 PM, Max Reitz wrote: > A refblock entry may have a different size than 16 bits, it may even be= > smaller than a byte. Correct the refcount_block_entries calculation > accordingly. >=20 > Signed-off-by: Max Reitz > --- > docs/specs/qcow2.txt | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/docs/specs/qcow2.txt b/docs/specs/qcow2.txt > index cfbc8b0..531c478 100644 > --- a/docs/specs/qcow2.txt > +++ b/docs/specs/qcow2.txt > @@ -183,7 +183,7 @@ blocks and are exactly one cluster in size. > Given a offset into the image file, the refcount of its cluster can be= obtained > as follows: > =20 > - refcount_block_entries =3D (cluster_size / sizeof(uint16_t)) > + refcount_block_entries =3D (cluster_size / (refcount_bits / 8)) > =20 Consider refcount_order =3D=3D 0 (that is, no shared blocks, ALL blocks h= ave at most refcount 1). Then, refcount_bits is (1 << 0) =3D=3D 1. But 1/8 = in integer math truncates to 0 (oops, division by zero is undefined); when in reality, the expression you want here is (cluster_size * 8 / refcount_bits). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --C6TJiD4q4d1hkMPQ7FQPgED5AXmgcF7ap 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 iQEcBAEBCAAGBQJUAQCrAAoJEKeha0olJ0NqFD0H+gIq1Ub7XSEE11WEt9oHWaBd 8rmgy+mfjp0D4VYN36+NLBUhdn1CMqzdr7j9MUeP5DZv+XEx6GXZEEbSqZXDTaLK Me2petgYmdr3EGsH3sKUp7KANPArA0GlQC/Z4BOV6wjeQNYdCDOuFxdVn3lRihd0 ETo2nYxmwOTW8v+oLcAGc8k/Z8I/2MD6ue6ovZt7TZnDenij3O37liydbHiYL8bc oSc8IgjBbWF04vJT9FnJh1gX2ijUQPGZHvmKAXW60q9KWWM+tdPMyFklQaprFyJo XzDds8no9R4yr2vAKasX+7/XlRmAf2Y1GNLoa3rbQM/ApX93oaDbG2NUZ+PnQl8= =Bhna -----END PGP SIGNATURE----- --C6TJiD4q4d1hkMPQ7FQPgED5AXmgcF7ap--