From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcYbH-0001Bj-DT for qemu-devel@nongnu.org; Fri, 10 Oct 2014 07:43:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XcYbC-00032b-3y for qemu-devel@nongnu.org; Fri, 10 Oct 2014 07:43:11 -0400 Received: from lputeaux-656-01-25-125.w80-12.abo.wanadoo.fr ([80.12.84.125]:58533 helo=paradis.irqsave.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XcYbB-00030T-Tt for qemu-devel@nongnu.org; Fri, 10 Oct 2014 07:43:06 -0400 Date: Fri, 10 Oct 2014 13:40:35 +0200 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20141010114035.GA10091@irqsave.net> References: <1411399425-23430-1-git-send-email-mreitz@redhat.com> <1411399425-23430-2-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1411399425-23430-2-git-send-email-mreitz@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/2] raw-posix: Fix raw_co_get_block_status() after EOF List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, Stefan Hajnoczi The Monday 22 Sep 2014 =E0 17:23:44 (+0200), Max Reitz wrote : > As its comment states, raw_co_get_block_status() should unconditionally > return 0 and set *pnum to 0 for after EOF. >=20 > An assertion after lseek(..., SEEK_HOLE) tried to catch this case by > asserting that errno !=3D -ENXIO (which would indicate a position after > the EOF); but it should be errno !=3D ENXIO instead. Fix this, too. >=20 > Reported-by: Kevin Wolf > Signed-off-by: Max Reitz > --- > block/raw-posix.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index a253697..de4e3f3 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -1509,9 +1509,9 @@ static int64_t try_seek_hole(BlockDriverState *bs= , off_t start, off_t *data, > =20 > *hole =3D lseek(s->fd, start, SEEK_HOLE); > if (*hole =3D=3D -1) { > - /* -ENXIO indicates that sector_num was past the end of the fi= le. > + /* ENXIO indicates that sector_num was past the end of the fil= e. > * There is a virtual hole there. */ > - assert(errno !=3D -ENXIO); > + assert(errno !=3D ENXIO); > =20 > return -errno; > } > @@ -1560,6 +1560,10 @@ static int64_t coroutine_fn raw_co_get_block_sta= tus(BlockDriverState *bs, > } > =20 > start =3D sector_num * BDRV_SECTOR_SIZE; > + if (start >=3D bdrv_getlength(bs)) { > + *pnum =3D 0; > + return 0; > + } > =20 > ret =3D try_fiemap(bs, start, &data, &hole, nb_sectors, pnum); > if (ret < 0) { > --=20 > 2.1.0 >=20 >=20 Reviewed-by: Beno=EEt Canet