[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v13 02/10] block: add API function to insert a node
From: |
Andrey Shinkevich |
Subject: |
[PATCH v13 02/10] block: add API function to insert a node |
Date: |
Wed, 2 Dec 2020 21:30:53 +0300 |
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>
---
block.c | 25 +++++++++++++++++++++++++
include/block/block.h | 2 ++
2 files changed, 27 insertions(+)
diff --git a/block.c b/block.c
index f1cedac..b71c39f 100644
--- a/block.c
+++ b/block.c
@@ -4698,6 +4698,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
*
diff --git a/include/block/block.h b/include/block/block.h
index c9d7c58..81a3894 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -350,6 +350,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);
--
1.8.3.1
- [PATCH v13 00/10] Apply COR-filter to the block-stream permanently, Andrey Shinkevich, 2020/12/02
- [PATCH v13 08/10] copy-on-read: skip non-guest reads if no copy needed, Andrey Shinkevich, 2020/12/02
- [PATCH v13 06/10] iotests: add #310 to test bottom node in COR driver, Andrey Shinkevich, 2020/12/02
- [PATCH v13 01/10] copy-on-read: support preadv/pwritev_part functions, Andrey Shinkevich, 2020/12/02
- [PATCH v13 07/10] block: include supported_read_flags into BDS structure, Andrey Shinkevich, 2020/12/02
- [PATCH v13 04/10] qapi: add filter-node-name to block-stream, Andrey Shinkevich, 2020/12/02
- [PATCH v13 05/10] qapi: create BlockdevOptionsCor structure for COR driver, Andrey Shinkevich, 2020/12/02
- [PATCH v13 02/10] block: add API function to insert a node,
Andrey Shinkevich <=
- [PATCH v13 03/10] copy-on-read: add filter drop function, Andrey Shinkevich, 2020/12/02
- [PATCH v13 10/10] block: apply COR-filter to block-stream jobs, Andrey Shinkevich, 2020/12/02
- [PATCH v13 09/10] stream: skip filters when writing backing file name to QCOW2 header, Andrey Shinkevich, 2020/12/02
- Re: [PATCH v13 00/10] Apply COR-filter to the block-stream permanently, Vladimir Sementsov-Ogievskiy, 2020/12/04