All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrey Shinkevich via <qemu-devel@nongnu.org>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, kwolf@redhat.com, mreitz@redhat.com,
	stefanha@redhat.com, fam@euphon.net, armbru@redhat.com,
	jsnow@redhat.com, eblake@redhat.com, den@openvz.org,
	vsementsov@virtuozzo.com, andrey.shinkevich@virtuozzo.com
Subject: [PATCH v13 02/10] block: add API function to insert a node
Date: Wed,  2 Dec 2020 21:30:53 +0300	[thread overview]
Message-ID: <1606933861-297777-3-git-send-email-andrey.shinkevich@virtuozzo.com> (raw)
In-Reply-To: <1606933861-297777-1-git-send-email-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>
---
 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



  parent reply	other threads:[~2020-12-02 18:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02 18:30 [PATCH v13 00/10] Apply COR-filter to the block-stream permanently Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 01/10] copy-on-read: support preadv/pwritev_part functions Andrey Shinkevich via
2020-12-02 18:30 ` Andrey Shinkevich via [this message]
2020-12-02 18:30 ` [PATCH v13 03/10] copy-on-read: add filter drop function Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 04/10] qapi: add filter-node-name to block-stream Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 05/10] qapi: create BlockdevOptionsCor structure for COR driver Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 06/10] iotests: add #310 to test bottom node in " Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 07/10] block: include supported_read_flags into BDS structure Andrey Shinkevich via
2020-12-02 18:30 ` [PATCH v13 08/10] copy-on-read: skip non-guest reads if no copy needed Andrey Shinkevich via
2020-12-03 12:53   ` Vladimir Sementsov-Ogievskiy
2020-12-02 18:31 ` [PATCH v13 09/10] stream: skip filters when writing backing file name to QCOW2 header Andrey Shinkevich via
2020-12-03 19:11   ` Vladimir Sementsov-Ogievskiy
2020-12-02 18:31 ` [PATCH v13 10/10] block: apply COR-filter to block-stream jobs Andrey Shinkevich via
2020-12-04 21:36 ` [PATCH v13 00/10] Apply COR-filter to the block-stream permanently Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1606933861-297777-3-git-send-email-andrey.shinkevich@virtuozzo.com \
    --to=qemu-devel@nongnu.org \
    --cc=andrey.shinkevich@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=fam@euphon.net \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.