[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/13] block: bdrv_insert_node(): fix and improve error handling
From: |
Kevin Wolf |
Subject: |
[PULL 04/13] block: bdrv_insert_node(): fix and improve error handling |
Date: |
Wed, 6 Oct 2021 12:59:14 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
- 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>
---
block.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index 917fb7faca..5d49188073 100644
--- a/block.c
+++ b/block.c
@@ -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;
}
--
2.31.1
- [PULL 00/13] Block layer patches, Kevin Wolf, 2021/10/06
- [PULL 02/13] qemu-storage-daemon: Only display FUSE help when FUSE is built-in, Kevin Wolf, 2021/10/06
- [PULL 01/13] include/block.h: remove outdated comment, Kevin Wolf, 2021/10/06
- [PULL 03/13] block: implement bdrv_new_open_driver_opts(), Kevin Wolf, 2021/10/06
- [PULL 04/13] block: bdrv_insert_node(): fix and improve error handling,
Kevin Wolf <=
- [PULL 05/13] block: bdrv_insert_node(): doc and style, Kevin Wolf, 2021/10/06
- [PULL 06/13] block: bdrv_insert_node(): don't use bdrv_open(), Kevin Wolf, 2021/10/06
- [PULL 07/13] iotests/image-fleecing: declare requirement of copy-before-write, Kevin Wolf, 2021/10/06
- [PULL 08/13] block: introduce max_hw_iov for use in scsi-generic, Kevin Wolf, 2021/10/06
- [PULL 10/13] iotests/linters: check mypy files all at once, Kevin Wolf, 2021/10/06
- [PULL 09/13] iotests: add 'qemu' package location to PYTHONPATH in testenv, Kevin Wolf, 2021/10/06
- [PULL 11/13] iotests/mirror-top-perms: Adjust imports, Kevin Wolf, 2021/10/06
- [PULL 12/13] iotests/migrate-bitmaps-test: delint, Kevin Wolf, 2021/10/06
- [PULL 13/13] iotests: Update for pylint 2.11.1, Kevin Wolf, 2021/10/06
- Re: [PULL 00/13] Block layer patches, Richard Henderson, 2021/10/06