From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37998) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve2qm-0006AC-51 for qemu-devel@nongnu.org; Wed, 06 Nov 2013 08:08:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ve2qh-0006Cm-5p for qemu-devel@nongnu.org; Wed, 06 Nov 2013 08:08:48 -0500 Received: from nodalink.pck.nerim.net ([62.212.105.220]:41133 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ve2qg-0006C6-KK for qemu-devel@nongnu.org; Wed, 06 Nov 2013 08:08:43 -0500 Date: Wed, 6 Nov 2013 14:08:39 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20131106130839.GB2981@irqsave.net> References: <1383738486-21045-1-git-send-email-famz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1383738486-21045-1-git-send-email-famz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] block: Round up total_sectors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Le Wednesday 06 Nov 2013 =E0 19:48:06 (+0800), Fam Zheng a =E9crit : > Since b94a2610, bdrv_getlength() is omitted when probing image. VMDK > monolithicFlat is broken by that because a file < 512 bytes can't be > read with its total_sectors truncated to 0. This patch round up the siz= e > to BDRV_SECTOR_SIZE, when a image size is not sector aligned. >=20 > Signed-off-by: Fam Zheng > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/block.c b/block.c > index 58efb5b..f706634 100644 > --- a/block.c > +++ b/block.c > @@ -640,7 +640,7 @@ static int refresh_total_sectors(BlockDriverState *= bs, int64_t hint) > if (length < 0) { > return length; > } > - hint =3D length >> BDRV_SECTOR_BITS; > + hint =3D DIV_ROUND_UP(length, BDRV_SECTOR_SIZE); > } > =20 > bs->total_sectors =3D hint; > --=20 > 1.8.3.1 >=20 >=20 Reviewed-by: Benoit Canet