[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/53] block: add API function to insert a node
From: |
Max Reitz |
Subject: |
[PULL 03/53] block: add API function to insert a node |
Date: |
Tue, 26 Jan 2021 15:19:26 +0100 |
From: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Provide API for insertion a node to backing chain.
Suggested-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20201216061703.70908-3-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/block/block.h | 2 ++
block.c | 25 +++++++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/include/block/block.h b/include/block/block.h
index a193545b6a..127bdf3392 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -358,6 +358,8 @@ void bdrv_append(BlockDriverState *bs_new, BlockDriverState
*bs_top,
Error **errp);
void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
Error **errp);
+BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
+ int flags, 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 8b9d457546..91a66d4f3e 100644
--- a/block.c
+++ b/block.c
@@ -4660,6 +4660,31 @@ static void bdrv_delete(BlockDriverState *bs)
g_free(bs);
}
+BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
+ int flags, Error **errp)
+{
+ BlockDriverState *new_node_bs;
+ Error *local_err = NULL;
+
+ new_node_bs = bdrv_open(NULL, NULL, node_options, flags, errp);
+ if (new_node_bs == NULL) {
+ error_prepend(errp, "Could not create node: ");
+ return NULL;
+ }
+
+ bdrv_drained_begin(bs);
+ bdrv_replace_node(bs, new_node_bs, &local_err);
+ bdrv_drained_end(bs);
+
+ if (local_err) {
+ bdrv_unref(new_node_bs);
+ error_propagate(errp, local_err);
+ return NULL;
+ }
+
+ return new_node_bs;
+}
+
/*
* Run consistency checks on an image
*
--
2.29.2
- [PULL 00/53] Block patches, Max Reitz, 2021/01/26
- [PULL 01/53] iotests: fix _check_o_direct, Max Reitz, 2021/01/26
- [PULL 02/53] copy-on-read: support preadv/pwritev_part functions, Max Reitz, 2021/01/26
- [PULL 03/53] block: add API function to insert a node,
Max Reitz <=
- [PULL 04/53] copy-on-read: add filter drop function, Max Reitz, 2021/01/26
- [PULL 05/53] qapi: add filter-node-name to block-stream, Max Reitz, 2021/01/26
- [PULL 07/53] iotests: add #310 to test bottom node in COR driver, Max Reitz, 2021/01/26
- [PULL 06/53] qapi: copy-on-read filter: add 'bottom' option, Max Reitz, 2021/01/26
- [PULL 08/53] block: include supported_read_flags into BDS structure, Max Reitz, 2021/01/26
- [PULL 11/53] qapi: block-stream: add "bottom" argument, Max Reitz, 2021/01/26
- [PULL 16/53] iotests/297: Rewrite in Python and extend reach, Max Reitz, 2021/01/26
- [PULL 17/53] iotests: Move try_remove to iotests.py, Max Reitz, 2021/01/26
- [PULL 14/53] block: apply COR-filter to block-stream jobs, Max Reitz, 2021/01/26