diff options
author | Andrey Shinkevich <andrey.shinkevich@virtuozzo.com> | 2020-12-16 09:16:52 +0300 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2021-01-26 11:26:54 +0100 |
commit | 8872ef78ab6d9cadfc9223bc3f3b8a1b86939bbc (patch) | |
tree | efdbc1448165e71f0a762ba9f44ca4b0db82f516 /block.c | |
parent | 1252e03b8e6ff56f53bd826e1ceeb21ab4858a92 (diff) | |
download | qemu-8872ef78ab6d9cadfc9223bc3f3b8a1b86939bbc.zip qemu-8872ef78ab6d9cadfc9223bc3f3b8a1b86939bbc.tar.gz qemu-8872ef78ab6d9cadfc9223bc3f3b8a1b86939bbc.tar.bz2 |
block: add API function to insert a node
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>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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 * |