From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43316) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFPKq-0008Qn-Lr for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:38:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFPKk-0002mC-Du for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:38:16 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFPKk-0002m7-63 for qemu-devel@nongnu.org; Mon, 17 Feb 2014 09:38:10 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s1HEc9mO022435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 17 Feb 2014 09:38:09 -0500 Date: Mon, 17 Feb 2014 09:38:06 -0500 From: Jeff Cody Message-ID: <20140217143806.GA4059@localhost.localdomain> References: <1392644647-9897-1-git-send-email-pbonzini@redhat.com> <1392644647-9897-14-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1392644647-9897-14-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 13/20] vhdx: correctly propagate errors List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On Mon, Feb 17, 2014 at 02:44:00PM +0100, Paolo Bonzini wrote: > Signed-off-by: Paolo Bonzini > --- > block/vhdx.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/block/vhdx.c b/block/vhdx.c > index 55689cf..bd3081b 100644 > --- a/block/vhdx.c > +++ b/block/vhdx.c > @@ -402,9 +402,10 @@ int vhdx_update_headers(BlockDriverState *bs, BDRVVHDXState *s, > } > > /* opens the specified header block from the VHDX file header section */ > -static int vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s) > +static void vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s, > + Error **errp) > { > - int ret = 0; > + int ret; > VHDXHeader *header1; > VHDXHeader *header2; > bool h1_valid = false; > @@ -462,7 +463,6 @@ static int vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s) > } else if (!h1_valid && h2_valid) { > s->curr_header = 1; > } else if (!h1_valid && !h2_valid) { > - ret = -EINVAL; > goto fail; > } else { > /* If both headers are valid, then we choose the active one by the > @@ -473,27 +473,22 @@ static int vhdx_parse_header(BlockDriverState *bs, BDRVVHDXState *s) > } else if (h2_seq > h1_seq) { > s->curr_header = 1; > } else { > - ret = -EINVAL; > goto fail; > } > } > > vhdx_region_register(s, s->headers[s->curr_header]->log_offset, > s->headers[s->curr_header]->log_length); > - > - ret = 0; > - > goto exit; > > fail: > - qerror_report(ERROR_CLASS_GENERIC_ERROR, "No valid VHDX header found"); > + error_setg_errno(errp, -ret, "No valid VHDX header found"); > qemu_vfree(header1); > qemu_vfree(header2); > s->headers[0] = NULL; > s->headers[1] = NULL; > exit: > qemu_vfree(buffer); > - return ret; > } > > > @@ -878,7 +873,7 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, > int ret = 0; > uint32_t i; > uint64_t signature; > - > + Error *local_err = NULL; > > s->bat = NULL; > s->first_visible_write = true; > @@ -901,8 +896,10 @@ static int vhdx_open(BlockDriverState *bs, QDict *options, int flags, > * header update */ > vhdx_guid_generate(&s->session_guid); > > - ret = vhdx_parse_header(bs, s); > - if (ret < 0) { > + vhdx_parse_header(bs, s, &local_err); > + if (local_err != NULL) { > + error_propagate(errp, local_err); > + ret = -EINVAL; > goto fail; > } > > -- > 1.8.5.3 > > Reviewed-by: Jeff Cody