diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-09-20 14:55:35 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2021-10-06 10:25:55 +0200 |
commit | f053b7e8005d7f72c2a8e686c4779f75b0ae631f (patch) | |
tree | 6f02a1143c37f024ba84d8cf1ced3b787a227561 /block.c | |
parent | 621d17378a40509757d5e03eb1c2f5305ff76df3 (diff) |
block: bdrv_insert_node(): fix and improve error handling
- use ERRP_GUARD(): function calls error_prepend(), so it must use
ERRP_GUARD(), otherwise error_prepend() would not be called when
passed errp is error_fatal
- drop error propagation, handle return code instead
- for symmetry, do error_prepend() for the second failure
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210920115538.264372-3-vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -5122,8 +5122,9 @@ static void bdrv_delete(BlockDriverState *bs) BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options, int flags, Error **errp) { + ERRP_GUARD(); + int ret; BlockDriverState *new_node_bs; - Error *local_err = NULL; new_node_bs = bdrv_open(NULL, NULL, node_options, flags, errp); if (new_node_bs == NULL) { @@ -5132,12 +5133,12 @@ BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options, } bdrv_drained_begin(bs); - bdrv_replace_node(bs, new_node_bs, &local_err); + ret = bdrv_replace_node(bs, new_node_bs, errp); bdrv_drained_end(bs); - if (local_err) { + if (ret < 0) { + error_prepend(errp, "Could not replace node: "); bdrv_unref(new_node_bs); - error_propagate(errp, local_err); return NULL; } |