[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/36] block: return value from bdrv_replace_node()
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 09/36] block: return value from bdrv_replace_node() |
Date: |
Fri, 27 Nov 2020 17:44:55 +0300 |
Functions with errp argument are not recommened to be void-functions.
Improve bdrv_replace_node().
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
include/block/block.h | 4 ++--
block.c | 14 ++++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index 5d59984ad4..8f6100dad7 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -346,8 +346,8 @@ int bdrv_create_file(const char *filename, QemuOpts *opts,
Error **errp);
BlockDriverState *bdrv_new(void);
int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
Error **errp);
-void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
- Error **errp);
+int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
+ Error **errp);
int bdrv_parse_aio(const char *mode, int *flags);
int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough);
diff --git a/block.c b/block.c
index 3765c7caed..29082c6d47 100644
--- a/block.c
+++ b/block.c
@@ -4537,14 +4537,14 @@ static bool should_update_child(BdrvChild *c,
BlockDriverState *to)
* With auto_skip=false the error is returned if from has a parent which should
* not be updated.
*/
-static void bdrv_replace_node_common(BlockDriverState *from,
- BlockDriverState *to,
- bool auto_skip, Error **errp)
+static int bdrv_replace_node_common(BlockDriverState *from,
+ BlockDriverState *to,
+ bool auto_skip, Error **errp)
{
+ int ret = -EPERM;
BdrvChild *c, *next;
GSList *list = NULL, *p;
uint64_t perm = 0, shared = BLK_PERM_ALL;
- int ret;
/* Make sure that @from doesn't go away until we have successfully attached
* all of its parents to @to. */
@@ -4600,10 +4600,12 @@ out:
g_slist_free(list);
bdrv_drained_end(from);
bdrv_unref(from);
+
+ return ret;
}
-void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
- Error **errp)
+int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
+ Error **errp)
{
return bdrv_replace_node_common(from, to, true, errp);
}
--
2.21.3
- [PATCH v2 00/36] block: update graph permissions update, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 01/36] tests/test-bdrv-graph-mod: add test_parallel_exclusive_write, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 07/36] block: drop ctx argument from bdrv_root_attach_child, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 06/36] block: BdrvChildClass: add .get_parent_aio_context handler, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 08/36] block: make bdrv_reopen_{prepare, commit, abort} private, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 09/36] block: return value from bdrv_replace_node(),
Vladimir Sementsov-Ogievskiy <=
- [PATCH v2 12/36] block: refactor bdrv_child* permission functions, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 16/36] block: add bdrv_drv_set_perm transaction action, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 13/36] block: rewrite bdrv_child_try_set_perm() using bdrv_refresh_perms(), Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 10/36] util: add transactions.c, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 11/36] block: bdrv_refresh_perms: check parents compliance, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 19/36] block: fix bdrv_replace_node_common, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 15/36] block: use topological sort for permission update, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 18/36] block: add bdrv_replace_child_safe() transaction action, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 20/36] block: add bdrv_attach_child_common() transaction action, Vladimir Sementsov-Ogievskiy, 2020/11/27
- [PATCH v2 24/36] block: add bdrv_remove_backing transaction action, Vladimir Sementsov-Ogievskiy, 2020/11/27