[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 23/54] vhdx: correctly propagate errors
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 23/54] vhdx: correctly propagate errors |
Date: |
Fri, 21 Feb 2014 23:12:20 +0100 |
From: Paolo Bonzini <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vhdx.c | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/block/vhdx.c b/block/vhdx.c
index 366ff2e..5390ba6 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.1.4
- [Qemu-devel] [PULL 13/54] nbd: inline tcp_socket_incoming_spec into sole caller, (continued)
- [Qemu-devel] [PULL 13/54] nbd: inline tcp_socket_incoming_spec into sole caller, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 14/54] nbd: move socket wrappers to qemu-nbd, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 15/54] iscsi: fix indentation, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 16/54] iscsi: correctly propagate errors in iscsi_open, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 17/54] gluster: default scheme to gluster:// and host to localhost., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 19/54] cow: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 18/54] gluster: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 20/54] curl: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 21/54] qcow: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 22/54] qed: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 23/54] vhdx: correctly propagate errors,
Kevin Wolf <=
- [Qemu-devel] [PULL 25/54] vmdk: extract vmdk_read_desc, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 26/54] vmdk: push vmdk_read_desc up to caller, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 24/54] vvfat: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 27/54] vmdk: do not try opening a file as both image and descriptor, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 28/54] vmdk: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 29/54] block: do not abuse EMEDIUMTYPE, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 30/54] vdi: say why an image is bad, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 31/54] qemu-option: has_help_option() and is_valid_option_list(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 32/54] qemu-img create: Support multiple -o options, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 33/54] qemu-img convert: Support multiple -o options, Kevin Wolf, 2014/02/21