[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v3 15/18] qapi: add x-drop-fleecing qmp command
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v3 15/18] qapi: add x-drop-fleecing qmp command |
Date: |
Mon, 1 Oct 2018 13:29:25 +0300 |
To insert fleecing-hook, it should be just created (blockdev-add) with
corresponding parameters. But it can't be properly removed by
blockdev-del (we can't restore backing chain in fleecing-hook .close),
So, let's add this expiremental api to drop the hook.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
qapi/block-core.json | 17 +++++++++++++++++
blockdev.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 13cf90eab6..eda6fb6b7e 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -3856,6 +3856,23 @@
##
{ 'command': 'blockdev-del', 'data': { 'node-name': 'str' } }
+##
+# @x-drop-fleecing:
+#
+# Deletes fleecing-hook filter from the top of the backing chain.
+#
+# @node-name: Name of the fleecing-hook node name.
+#
+# Since: 3.1
+#
+# -> { "execute": "x-drop-fleecing",
+# "arguments": { "node-name": "fleece0" }
+# }
+# <- { "return": {} }
+#
+##
+{ 'command': 'x-drop-fleecing', 'data': { 'node-name': 'str' } }
+
##
# @BlockdevCreateOptionsFile:
#
diff --git a/blockdev.c b/blockdev.c
index 407e03d22a..90c09d5cee 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -4250,6 +4250,43 @@ out:
aio_context_release(aio_context);
}
+void qmp_x_drop_fleecing(const char *node_name, Error **errp)
+{
+ AioContext *aio_context;
+ BlockDriverState *bs;
+
+ bs = bdrv_find_node(node_name);
+ if (!bs) {
+ error_setg(errp, "Cannot find node %s", node_name);
+ return;
+ }
+
+ if (!bdrv_has_blk(bs)) {
+ error_setg(errp, "Node %s is not inserted", node_name);
+ return;
+ }
+
+ if (!bs->backing) {
+ error_setg(errp, "'%s' has no backing", node_name);
+ return;
+ }
+
+ aio_context = bdrv_get_aio_context(bs);
+ aio_context_acquire(aio_context);
+
+ bdrv_drained_begin(bs);
+
+ bdrv_child_try_set_perm(bs->backing, 0, BLK_PERM_ALL, &error_abort);
+ bdrv_replace_node(bs, backing_bs(bs), &error_abort);
+ bdrv_set_backing_hd(bs, NULL, &error_abort);
+
+ bdrv_drained_end(bs);
+
+ qmp_blockdev_del(node_name, &error_abort);
+
+ aio_context_release(aio_context);
+}
+
static BdrvChild *bdrv_find_child(BlockDriverState *parent_bs,
const char *child_name)
{
--
2.18.0
- Re: [Qemu-block] [PATCH v3 13/18] block: introduce new filter driver: fleecing-hook, (continued)
[Qemu-block] [PATCH v3 16/18] iotests: test new fleecing-hook driver in context of 222 iotest, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 11/18] iotests: allow resume_drive by node name, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 07/18] block/backup: allow use existent copy-bitmap, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 17/18] block/backup: tiny refactor backup_job_create, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 18/18] block/backup: use fleecing-hook instead of write notifiers, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 09/18] block: improve should_update_child, Vladimir Sementsov-Ogievskiy, 2018/10/01
[Qemu-block] [PATCH v3 15/18] qapi: add x-drop-fleecing qmp command,
Vladimir Sementsov-Ogievskiy <=
[Qemu-block] [PATCH v3 12/18] iotests: prepare 055 to graph changes during backup job, Vladimir Sementsov-Ogievskiy, 2018/10/01
Re: [Qemu-block] [PATCH v3 00/18] fleecing-hook driver for backup, Eric Blake, 2018/10/02