[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [RFC PATCH 08/16] qmp: Add optional parameter "persistent"
From: |
Fam Zheng |
Subject: |
[Qemu-block] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add |
Date: |
Tue, 26 Jan 2016 18:38:17 +0800 |
When omitted it defaults to false with unchanged behavior.
When set to true, the created dirty bitmap is made persistent if supported, it
requires support from the active image format. Otherwise an error is returned.
Signed-off-by: Fam Zheng <address@hidden>
---
blockdev.c | 8 +++++++-
qapi/block-core.json | 6 +++++-
qmp-commands.hx | 3 ++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 07cfe25..08236f2 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1997,6 +1997,7 @@ static void block_dirty_bitmap_add_prepare(BlkActionState
*common,
/* AIO context taken and released within qmp_block_dirty_bitmap_add */
qmp_block_dirty_bitmap_add(action->node, action->name,
action->has_granularity, action->granularity,
+ action->has_persistent, action->persistent,
&local_err);
if (!local_err) {
@@ -2640,10 +2641,12 @@ out:
void qmp_block_dirty_bitmap_add(const char *node, const char *name,
bool has_granularity, uint32_t granularity,
+ bool has_persistent, bool persistent,
Error **errp)
{
AioContext *aio_context;
BlockDriverState *bs;
+ BdrvDirtyBitmap *bitmap;
if (!name || name[0] == '\0') {
error_setg(errp, "Bitmap name cannot be empty");
@@ -2669,7 +2672,10 @@ void qmp_block_dirty_bitmap_add(const char *node, const
char *name,
granularity = bdrv_get_default_bitmap_granularity(bs);
}
- bdrv_create_dirty_bitmap(bs, granularity, name, errp);
+ bitmap = bdrv_create_dirty_bitmap(bs, granularity, name, errp);
+ if (bitmap && has_persistent && persistent) {
+ bdrv_dirty_bitmap_set_persistent(bs, bitmap, true, false, errp);
+ }
out:
aio_context_release(aio_context);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 30c2e5f..0ac107c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1162,10 +1162,14 @@
# @granularity: #optional the bitmap granularity, default is 64k for
# block-dirty-bitmap-add
#
+# @persistent: #optinal whether to make the bitmap persistent, default is
false.
+# (Since 2.6)
+#
# Since 2.4
##
{ 'struct': 'BlockDirtyBitmapAdd',
- 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32' } }
+ 'data': { 'node': 'str', 'name': 'str', '*granularity': 'uint32',
+ '*persistent': 'bool' } }
##
# @block-dirty-bitmap-add
diff --git a/qmp-commands.hx b/qmp-commands.hx
index db072a6..bd4428e 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -1373,7 +1373,7 @@ EQMP
{
.name = "block-dirty-bitmap-add",
- .args_type = "node:B,name:s,granularity:i?",
+ .args_type = "node:B,name:s,granularity:i?,persistent:b?",
.mhandler.cmd_new = qmp_marshal_block_dirty_bitmap_add,
},
@@ -1390,6 +1390,7 @@ Arguments:
- "node": device/node on which to create dirty bitmap (json-string)
- "name": name of the new dirty bitmap (json-string)
- "granularity": granularity to track writes with (int, optional)
+- "persistent": whether the bitmap is persistent (bool, optional, default to
no)
Example:
--
2.4.3
- [Qemu-block] [RFC PATCH 00/16] Qemu Bit Map (QBM) - an overlay format for persistent dirty bitmap, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 01/16] doc: Add QBM format specification, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 02/16] block: Set dirty before doing write, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 03/16] block: Allow .bdrv_close callback to release dirty bitmaps, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 04/16] block: Move filename_decompose to block.c, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 05/16] block: Make bdrv_get_cluster_size public, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 06/16] block: Introduce bdrv_dirty_bitmap_set_persistent, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 07/16] block: Only swap non-persistent dirty bitmaps, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 08/16] qmp: Add optional parameter "persistent" in block-dirty-bitmap-add,
Fam Zheng <=
- [Qemu-block] [RFC PATCH 09/16] qmp: Add block-dirty-bitmap-set-persistent, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 10/16] qbm: Implement format driver, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 11/16] qapi: Add "qbm" as a generic cow format driver, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 12/16] iotests: Add qbm format to 041, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 13/16] iotests: Add qbm to case 097, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 14/16] iotests: Add qbm to applicable test cases, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 15/16] iotests: Add qbm specific test case 140, Fam Zheng, 2016/01/26
- [Qemu-block] [RFC PATCH 16/16] iotests: Add persistent bitmap test case 141, Fam Zheng, 2016/01/26