From: Jeff Cody <jcody@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, famz@redhat.com, qemu-devel@nongnu.org,
stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 13/20] vhdx: correctly propagate errors
Date: Mon, 17 Feb 2014 09:38:06 -0500 [thread overview]
Message-ID: <20140217143806.GA4059@localhost.localdomain> (raw)
In-Reply-To: <1392644647-9897-14-git-send-email-pbonzini@redhat.com>
On Mon, Feb 17, 2014 at 02:44:00PM +0100, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> 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 <jcody@redhat.com>
next prev parent reply other threads:[~2014-02-17 14:38 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 13:43 [Qemu-devel] [PATCH v3 00/20] Improve bdrv_open error messages Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 01/20] nbd: produce a better error if neither host nor port is passed Paolo Bonzini
2014-02-17 18:48 ` Eric Blake
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 02/20] nbd: correctly propagate errors Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 03/20] nbd: inline tcp_socket_incoming_spec into sole caller Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 04/20] nbd: move socket wrappers to qemu-nbd Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 05/20] iscsi: fix indentation Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 06/20] iscsi: correctly propagate errors in iscsi_open Paolo Bonzini
2014-02-19 9:34 ` Stefan Hajnoczi
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 07/20] gluster: default scheme to gluster:// and host to localhost Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 08/20] gluster: correctly propagate errors Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 09/20] cow: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 10/20] curl: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 11/20] qcow: " Paolo Bonzini
2014-02-17 13:43 ` [Qemu-devel] [PATCH v3 12/20] qed: " Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 13/20] vhdx: " Paolo Bonzini
2014-02-17 14:38 ` Jeff Cody [this message]
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 14/20] vvfat: " Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 15/20] vmdk: extract vmdk_read_desc Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 16/20] vmdk: push vmdk_read_desc up to caller Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 17/20] vmdk: do not try opening a file as both image and descriptor Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 18/20] vmdk: correctly propagate errors Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 19/20] block: do not abuse EMEDIUMTYPE Paolo Bonzini
2014-02-17 13:44 ` [Qemu-devel] [PATCH v3 20/20] vdi: say why an image is bad Paolo Bonzini
2014-02-18 6:32 ` [Qemu-devel] [PATCH v3 00/20] Improve bdrv_open error messages Fam Zheng
2014-02-19 14:06 ` Kevin Wolf
2014-02-20 17:29 ` Paolo Bonzini
2014-02-21 11:08 ` Kevin Wolf
2014-02-21 11:37 ` Paolo Bonzini
2014-02-21 11:47 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140217143806.GA4059@localhost.localdomain \
--to=jcody@redhat.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.