From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56748) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6iqm-0001e3-PJ for qemu-devel@nongnu.org; Fri, 24 Jan 2014 10:39:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6iqh-0007qA-B4 for qemu-devel@nongnu.org; Fri, 24 Jan 2014 10:39:20 -0500 Received: from paradis.irqsave.net ([62.212.105.220]:48257) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6iqh-0007q4-0j for qemu-devel@nongnu.org; Fri, 24 Jan 2014 10:39:15 -0500 Date: Fri, 24 Jan 2014 16:39:11 +0100 From: =?iso-8859-1?Q?Beno=EEt?= Canet Message-ID: <20140124153911.GC3087@irqsave.net> References: <1390568901-25060-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1390568901-25060-1-git-send-email-kwolf@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] block: Fix bdrv_commit return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Le Friday 24 Jan 2014 =E0 14:08:21 (+0100), Kevin Wolf a =E9crit : > bdrv_commit() could return 0 or 1 on success, depending on whether or > now the last sector was allocated in the overlay and whether the overla= y > format had a .bdrv_make_empty callback. >=20 > Most callers ignored it, but qemu-img commit would print an error > message while the operation actually succeeded. >=20 > Also clean up the handling of I/O errors to return the real error code > instead of -EIO. >=20 > Signed-off-by: Kevin Wolf > --- > block.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) >=20 > diff --git a/block.c b/block.c > index 3e0994b..7d22ca9 100644 > --- a/block.c > +++ b/block.c > @@ -2061,13 +2061,13 @@ int bdrv_commit(BlockDriverState *bs) > goto ro_cleanup; > } > if (ret) { > - if (bdrv_read(bs, sector, buf, n) !=3D 0) { > - ret =3D -EIO; > + ret =3D bdrv_read(bs, sector, buf, n); > + if (ret < 0) { > goto ro_cleanup; > } > =20 > - if (bdrv_write(bs->backing_hd, sector, buf, n) !=3D 0) { > - ret =3D -EIO; > + ret =3D bdrv_write(bs->backing_hd, sector, buf, n); > + if (ret < 0) { > goto ro_cleanup; > } > } > @@ -2075,6 +2075,9 @@ int bdrv_commit(BlockDriverState *bs) > =20 > if (drv->bdrv_make_empty) { > ret =3D drv->bdrv_make_empty(bs); > + if (ret < 0) { > + goto ro_cleanup; > + } > bdrv_flush(bs); > } > =20 > @@ -2082,9 +2085,11 @@ int bdrv_commit(BlockDriverState *bs) > * Make sure all data we wrote to the backing device is actually > * stable on disk. > */ > - if (bs->backing_hd) > + if (bs->backing_hd) { > bdrv_flush(bs->backing_hd); > + } > =20 > + ret =3D 0; > ro_cleanup: > g_free(buf); > =20 > --=20 > 1.8.1.4 >=20 >=20 the !=3D 0 in "if (bdrv_read(bs, sector, buf, n) !=3D 0) {" was really od= d. Reviewed-by: Benoit Canet