From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQk35-0005Ao-1o for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:54:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQk30-0004wW-9K for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:54:15 -0400 Received: from nodalink.pck.nerim.net ([62.212.105.220]:43741 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQk2z-0004vV-Vd for qemu-devel@nongnu.org; Fri, 12 Apr 2013 15:54:10 -0400 Date: Fri, 12 Apr 2013 21:55:14 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20130412195513.GA4510@irqsave.net> References: <1365788268-24787-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1365788268-24787-1-git-send-email-stefanha@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] qemu-img: refuse to compress files with invalid size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , qemu-devel@nongnu.org Le Friday 12 Apr 2013 =E0 19:37:48 (+0200), Stefan Hajnoczi a =E9crit : > Image file compression works at cluster granularity. It is not possibl= e > to compress less than a cluster of data at a time. >=20 > Print an error when attempting qemu-img convert -c with an input file > that is not a multiple of the cluster size. >=20 > I considered automatically adjusting the output file size but think it'= s > better to be explicit. This avoids confusion when users notice that > image file size changed after conversion. >=20 > Signed-off-by: Stefan Hajnoczi > --- > qemu-img.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/qemu-img.c b/qemu-img.c > index 31627b0..2273851 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -1370,6 +1370,13 @@ static int img_convert(int argc, char **argv) > goto out; > } > cluster_sectors =3D cluster_size >> 9; > + if (total_sectors % cluster_sectors) { > + error_report("compression requires that input file size is= a " > + "multiple of %d bytes", > + cluster_size); > + ret =3D -1; > + goto out; > + } > sector_num =3D 0; > =20 > nb_sectors =3D total_sectors; > --=20 > 1.8.1.4 >=20 >=20 Reviewed-by: Benoit Canet