From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55329) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vgli3-0007sO-0X for qemu-devel@nongnu.org; Wed, 13 Nov 2013 20:27:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Vglhg-000691-Ev for qemu-devel@nongnu.org; Wed, 13 Nov 2013 20:27:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38805) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Vglhg-00068j-75 for qemu-devel@nongnu.org; Wed, 13 Nov 2013 20:26:40 -0500 Message-ID: <528426CA.8060600@redhat.com> Date: Thu, 14 Nov 2013 09:26:34 +0800 From: Fam Zheng MIME-Version: 1.0 References: <1384303994-26796-1-git-send-email-famz@redhat.com> <1384303994-26796-6-git-send-email-famz@redhat.com> <20131113153451.GB22807@localhost.localdomain> In-Reply-To: <20131113153451.GB22807@localhost.localdomain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 5/5] mirror: Check for bdrv_get_info result List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, Paolo Bonzini , gentoo.integer@gmail.com, qemu-devel@nongnu.org, stefanha@redhat.com On 2013=E5=B9=B411=E6=9C=8813=E6=97=A5 23:34, Jeff Cody wrote: > On Wed, Nov 13, 2013 at 08:53:14AM +0800, Fam Zheng wrote: >> bdrv_get_info could fail. Add check before using the returned value. >> >> Signed-off-by: Fam Zheng >> --- >> block/mirror.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/block/mirror.c b/block/mirror.c >> index 7b95acf..c0c321b 100644 >> --- a/block/mirror.c >> +++ b/block/mirror.c >> @@ -320,8 +320,8 @@ static void coroutine_fn mirror_run(void *opaque) >> bdrv_get_backing_filename(s->target, backing_filename, >> sizeof(backing_filename)); >> if (backing_filename[0] && !s->target->backing_hd) { >> - bdrv_get_info(s->target, &bdi); >> - if (s->granularity < bdi.cluster_size) { >> + ret =3D bdrv_get_info(s->target, &bdi); >> + if (ret =3D=3D 0 && s->granularity < bdi.cluster_size) { > > For ret < 0, I think we should exit on error (at least in cases where > ret < 0 && ret !=3D -ENOTSUP). > We only need the cluster_size here, which is optional to set up=20 operation granularity. Exiting the block job because bdrv_get_info fails=20 (which is not a critical error) is worse in fault tolerance sense, so=20 I'd like to keep this way. Paolo, any ideas? Fam