From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOaNn-0007K7-Ai for qemu-devel@nongnu.org; Thu, 19 Feb 2015 18:19:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YOaNi-0001d7-CZ for qemu-devel@nongnu.org; Thu, 19 Feb 2015 18:19:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YOaNi-0001d2-4t for qemu-devel@nongnu.org; Thu, 19 Feb 2015 18:19:42 -0500 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 t1JNJfRv024992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Thu, 19 Feb 2015 18:19:41 -0500 Message-ID: <54E66F8C.7080505@redhat.com> Date: Thu, 19 Feb 2015 16:19:40 -0700 From: Eric Blake MIME-Version: 1.0 References: <1424299260-1763-1-git-send-email-mreitz@redhat.com> <1424299260-1763-5-git-send-email-mreitz@redhat.com> In-Reply-To: <1424299260-1763-5-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="3Hp3lnikrDTKbiec5fPNgXVcpRuoqXLaW" Subject: Re: [Qemu-devel] [PATCH v7 14/25] qcow2: Allow creation with refcount order != 4 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) --3Hp3lnikrDTKbiec5fPNgXVcpRuoqXLaW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/18/2015 03:40 PM, Max Reitz wrote: > Add a creation option to qcow2 for setting the refcount order of images= > to be created, and respect that option's value. >=20 > This breaks some test outputs, fix them. >=20 > Signed-off-by: Max Reitz > --- > block/qcow2.c | 18 ++++++++ > include/block/block_int.h | 1 + > tests/qemu-iotests/049.out | 108 ++++++++++++++++++++++---------------= -------- > tests/qemu-iotests/082.out | 41 ++++++++++++++--- > tests/qemu-iotests/085.out | 38 ++++++++-------- > 5 files changed, 126 insertions(+), 80 deletions(-) >=20 > diff --git a/block/qcow2.c b/block/qcow2.c > index a07f134..4cdbd7e 100644 > --- a/block/qcow2.c > +++ b/block/qcow2.c > @@ -2078,6 +2078,15 @@ static int qcow2_create(const char *filename, Qe= muOpts *opts, Error **errp) > goto finish; > } > =20 > + refcount_bits =3D qemu_opt_get_number_del(opts, BLOCK_OPT_REFCOUNT= _BITS, > + refcount_bits); > + if (refcount_bits > 64 || !is_power_of_2(refcount_bits)) { > + error_setg(errp, "Refcount width must be a power of two and ma= y not " > + "exceed 64 bits"); > + ret =3D -EINVAL; > + goto finish; > + } > + > if (version < 3 && refcount_bits !=3D 16) { The ffs() I complained about in 11/25 occurs shortly after this point, and is therefore safe even though it is called on a 64-bit number, because we have capped the number to be in range even after truncation to int. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --3Hp3lnikrDTKbiec5fPNgXVcpRuoqXLaW 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 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU5m+MAAoJEKeha0olJ0NqF/8H/itJ4F2ynoF1ATE0I4/moNUn IoixoT7UxG3ryTvP6Op3ojj4V+4BIS97phvKvJBwUrJwZDR0XuMxmZ3z8JnSl1Fd SZ1i4iEOPpID7jqVP2SQymPY1OXCvt3ozknGj48Vu0RWrMnn6eBuSzCmX/CwObbn GxvLvmyI9BAG2gPtuo880OsxiZjUMxEtTeFmndATovf/hc00R9T6fhWiU+zMV0d9 z/ABnzGc3809HV7nMn/iDO3wWiyQUs6qCk4BtAWpQThsXy3c6yJSHNROVVVW9v9F LbieiJrMN1JzGzaDhFrQZ9bvq5BKi957lmvS6hQl0VDt4JBS2YiAU4E8VnIvMH8= =iMOG -----END PGP SIGNATURE----- --3Hp3lnikrDTKbiec5fPNgXVcpRuoqXLaW--