Received: from eggs.gnu.org ([2001:4830:134:3::10]:34580) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c8wA9-0003YN-V5 for qemu-devel@nongnu.org; Mon, 21 Nov 2016 16:30:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c8wA6-00057O-2a for qemu-devel@nongnu.org; Mon, 21 Nov 2016 16:30:05 -0500 References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-9-git-send-email-eblake@redhat.com> <3ae2a9aa-df53-fab2-aa98-a87787d5853e@redhat.com> <52021069-625d-6712-cc7c-1c1b26673bbe@redhat.com> From: Eric Blake Message-ID: Date: Mon, 21 Nov 2016 15:29:51 -0600 MIME-Version: 1.0 In-Reply-To: <52021069-625d-6712-cc7c-1c1b26673bbe@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="vpxBIfjvGr4Sxg9fki60An39LpMTMjrRG" Subject: Re: [Qemu-devel] [PATCH v2 8/9] blkdebug: Add ability to override unmap geometries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, Markus Armbruster , qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --vpxBIfjvGr4Sxg9fki60An39LpMTMjrRG From: Eric Blake To: Max Reitz , qemu-devel@nongnu.org Cc: kwolf@redhat.com, pbonzini@redhat.com, Markus Armbruster , qemu-block@nongnu.org Message-ID: Subject: Re: [Qemu-devel] [PATCH v2 8/9] blkdebug: Add ability to override unmap geometries References: <1479413642-22463-1-git-send-email-eblake@redhat.com> <1479413642-22463-9-git-send-email-eblake@redhat.com> <3ae2a9aa-df53-fab2-aa98-a87787d5853e@redhat.com> <52021069-625d-6712-cc7c-1c1b26673bbe@redhat.com> In-Reply-To: <52021069-625d-6712-cc7c-1c1b26673bbe@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/21/2016 03:11 PM, Eric Blake wrote: >>> @@ -398,6 +429,53 @@ static int blkdebug_open(BlockDriverState *bs, Q= Dict *options, int flags, >>> ret =3D -EINVAL; >>> goto fail_unref; >>> } >>> + max_transfer =3D qemu_opt_get_size(opts, "max-transfer", 0); >>> + if (max_transfer < INT_MAX && >>> + QEMU_IS_ALIGNED(max_transfer, MAX(align, BDRV_SECTOR_SIZE)))= { >>> + s->max_transfer =3D max_transfer; >>> + } else if (max_transfer) { >>> + error_setg(errp, "Invalid argument"); >> >> Could you be more specific? Same in all of the error_setg() calls belo= w. >> >>> + ret =3D -EINVAL; >>> + goto fail_unref; >>> + } >> >> Also, the way this is formatted seems not intuitive to me. I know it's= >> the same as it's been done for "align", but normally I'd use the follo= wing: >> >> s->value =3D qemu_opt_get_size(...); >> if (s->value is set and invalid) { >> /* error out */ >> } >=20 > I'll see what I can do. Unfortunately, part of the problem is type casting. qemu_opt_get_size() returns a 64-bit number, but s->align is 'int'. You can't detect wraparound unless you store into a temporary and check bounds prior to assigning to the narrower type. I guess I could always change the struct to store 64-bit values that have been validated to fit within 32 bits. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --vpxBIfjvGr4Sxg9fki60An39LpMTMjrRG Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYM2dPAAoJEKeha0olJ0NqdDMH/3KiJNpVFVERkLM7M+mxbINV LBSu6ZcGpqBpaNp7Wd/dWlvNlemKGeQZBuB9RzQMf2tYLhtq0gwAa7LlfPOPU0N6 z/Yf22Ngv8yPFMR7frL4Owi/4d1/7YvCxEmriQSIBz+/vGTu0FOBh+/2N9I7zIXH JxgolIaPOof9QhE3TZ936Ab7rlpBJ+7M60Nuu/Ja6EL9S7+kIu9IbGlVr76ehKiQ 1/GGrV8Q3qJ0eR+vQKLaIoMEJlFTKRe4J26FpfuC8NQI/n/1QCHItqjD1fr9Mk3f cfI4O7CSGS6bJNLjDaRid2eKI6IjFo2umvqUow6C38aE/ELfbsb/NQbQUwNjigE= =cP/K -----END PGP SIGNATURE----- --vpxBIfjvGr4Sxg9fki60An39LpMTMjrRG--