|
|
1bdc94 |
From a2c0037a5871c5982b742f255f6580f30482f1fc Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Date: Wed, 18 Jul 2018 22:54:39 +0200
|
|
|
1bdc94 |
Subject: [PATCH 54/89] qmp: transaction support for
|
|
|
1bdc94 |
x-block-dirty-bitmap-enable/disable
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180718225511.14878-4-jsnow@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 81410
|
|
|
1bdc94 |
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 03/35] qmp: transaction support for x-block-dirty-bitmap-enable/disable
|
|
|
1bdc94 |
Bugzilla: 1207657
|
|
|
1bdc94 |
RH-Acked-by: Eric Blake <eblake@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
|
|
|
1bdc94 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
Reviewed-by: Jeff Cody <jcody@redhat.com>
|
|
|
1bdc94 |
Message-id: 20180606182449.1607-4-jsnow@redhat.com
|
|
|
1bdc94 |
[Added x- prefix. --js]
|
|
|
1bdc94 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit c6490447402f574bbe45f45c318e0bdd19121baf)
|
|
|
1bdc94 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
blockdev.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
1bdc94 |
qapi/transaction.json | 4 +++
|
|
|
1bdc94 |
2 files changed, 84 insertions(+), 1 deletion(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/blockdev.c b/blockdev.c
|
|
|
1bdc94 |
index ca2ffff..a88d792 100644
|
|
|
1bdc94 |
--- a/blockdev.c
|
|
|
1bdc94 |
+++ b/blockdev.c
|
|
|
1bdc94 |
@@ -2094,6 +2094,7 @@ typedef struct BlockDirtyBitmapState {
|
|
|
1bdc94 |
BlockDriverState *bs;
|
|
|
1bdc94 |
HBitmap *backup;
|
|
|
1bdc94 |
bool prepared;
|
|
|
1bdc94 |
+ bool was_enabled;
|
|
|
1bdc94 |
} BlockDirtyBitmapState;
|
|
|
1bdc94 |
|
|
|
1bdc94 |
static void block_dirty_bitmap_add_prepare(BlkActionState *common,
|
|
|
1bdc94 |
@@ -2193,6 +2194,74 @@ static void block_dirty_bitmap_clear_commit(BlkActionState *common)
|
|
|
1bdc94 |
hbitmap_free(state->backup);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
+static void block_dirty_bitmap_enable_prepare(BlkActionState *common,
|
|
|
1bdc94 |
+ Error **errp)
|
|
|
1bdc94 |
+{
|
|
|
1bdc94 |
+ BlockDirtyBitmap *action;
|
|
|
1bdc94 |
+ BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
|
|
|
1bdc94 |
+ common, common);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ if (action_check_completion_mode(common, errp) < 0) {
|
|
|
1bdc94 |
+ return;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ action = common->action->u.x_block_dirty_bitmap_enable.data;
|
|
|
1bdc94 |
+ state->bitmap = block_dirty_bitmap_lookup(action->node,
|
|
|
1bdc94 |
+ action->name,
|
|
|
1bdc94 |
+ NULL,
|
|
|
1bdc94 |
+ errp);
|
|
|
1bdc94 |
+ if (!state->bitmap) {
|
|
|
1bdc94 |
+ return;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ state->was_enabled = bdrv_dirty_bitmap_enabled(state->bitmap);
|
|
|
1bdc94 |
+ bdrv_enable_dirty_bitmap(state->bitmap);
|
|
|
1bdc94 |
+}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+static void block_dirty_bitmap_enable_abort(BlkActionState *common)
|
|
|
1bdc94 |
+{
|
|
|
1bdc94 |
+ BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
|
|
|
1bdc94 |
+ common, common);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ if (!state->was_enabled) {
|
|
|
1bdc94 |
+ bdrv_disable_dirty_bitmap(state->bitmap);
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+static void block_dirty_bitmap_disable_prepare(BlkActionState *common,
|
|
|
1bdc94 |
+ Error **errp)
|
|
|
1bdc94 |
+{
|
|
|
1bdc94 |
+ BlockDirtyBitmap *action;
|
|
|
1bdc94 |
+ BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
|
|
|
1bdc94 |
+ common, common);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ if (action_check_completion_mode(common, errp) < 0) {
|
|
|
1bdc94 |
+ return;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ action = common->action->u.x_block_dirty_bitmap_disable.data;
|
|
|
1bdc94 |
+ state->bitmap = block_dirty_bitmap_lookup(action->node,
|
|
|
1bdc94 |
+ action->name,
|
|
|
1bdc94 |
+ NULL,
|
|
|
1bdc94 |
+ errp);
|
|
|
1bdc94 |
+ if (!state->bitmap) {
|
|
|
1bdc94 |
+ return;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ state->was_enabled = bdrv_dirty_bitmap_enabled(state->bitmap);
|
|
|
1bdc94 |
+ bdrv_disable_dirty_bitmap(state->bitmap);
|
|
|
1bdc94 |
+}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+static void block_dirty_bitmap_disable_abort(BlkActionState *common)
|
|
|
1bdc94 |
+{
|
|
|
1bdc94 |
+ BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
|
|
|
1bdc94 |
+ common, common);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ if (state->was_enabled) {
|
|
|
1bdc94 |
+ bdrv_enable_dirty_bitmap(state->bitmap);
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
static void abort_prepare(BlkActionState *common, Error **errp)
|
|
|
1bdc94 |
{
|
|
|
1bdc94 |
error_setg(errp, "Transaction aborted using Abort action");
|
|
|
1bdc94 |
@@ -2253,7 +2322,17 @@ static const BlkActionOps actions[] = {
|
|
|
1bdc94 |
.prepare = block_dirty_bitmap_clear_prepare,
|
|
|
1bdc94 |
.commit = block_dirty_bitmap_clear_commit,
|
|
|
1bdc94 |
.abort = block_dirty_bitmap_clear_abort,
|
|
|
1bdc94 |
- }
|
|
|
1bdc94 |
+ },
|
|
|
1bdc94 |
+ [TRANSACTION_ACTION_KIND_X_BLOCK_DIRTY_BITMAP_ENABLE] = {
|
|
|
1bdc94 |
+ .instance_size = sizeof(BlockDirtyBitmapState),
|
|
|
1bdc94 |
+ .prepare = block_dirty_bitmap_enable_prepare,
|
|
|
1bdc94 |
+ .abort = block_dirty_bitmap_enable_abort,
|
|
|
1bdc94 |
+ },
|
|
|
1bdc94 |
+ [TRANSACTION_ACTION_KIND_X_BLOCK_DIRTY_BITMAP_DISABLE] = {
|
|
|
1bdc94 |
+ .instance_size = sizeof(BlockDirtyBitmapState),
|
|
|
1bdc94 |
+ .prepare = block_dirty_bitmap_disable_prepare,
|
|
|
1bdc94 |
+ .abort = block_dirty_bitmap_disable_abort,
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
};
|
|
|
1bdc94 |
|
|
|
1bdc94 |
/**
|
|
|
1bdc94 |
diff --git a/qapi/transaction.json b/qapi/transaction.json
|
|
|
1bdc94 |
index bd31279..d7e4274 100644
|
|
|
1bdc94 |
--- a/qapi/transaction.json
|
|
|
1bdc94 |
+++ b/qapi/transaction.json
|
|
|
1bdc94 |
@@ -46,6 +46,8 @@
|
|
|
1bdc94 |
# - @abort: since 1.6
|
|
|
1bdc94 |
# - @block-dirty-bitmap-add: since 2.5
|
|
|
1bdc94 |
# - @block-dirty-bitmap-clear: since 2.5
|
|
|
1bdc94 |
+# - @x-block-dirty-bitmap-enable: since 3.0
|
|
|
1bdc94 |
+# - @x-block-dirty-bitmap-disable: since 3.0
|
|
|
1bdc94 |
# - @blockdev-backup: since 2.3
|
|
|
1bdc94 |
# - @blockdev-snapshot: since 2.5
|
|
|
1bdc94 |
# - @blockdev-snapshot-internal-sync: since 1.7
|
|
|
1bdc94 |
@@ -59,6 +61,8 @@
|
|
|
1bdc94 |
'abort': 'Abort',
|
|
|
1bdc94 |
'block-dirty-bitmap-add': 'BlockDirtyBitmapAdd',
|
|
|
1bdc94 |
'block-dirty-bitmap-clear': 'BlockDirtyBitmap',
|
|
|
1bdc94 |
+ 'x-block-dirty-bitmap-enable': 'BlockDirtyBitmap',
|
|
|
1bdc94 |
+ 'x-block-dirty-bitmap-disable': 'BlockDirtyBitmap',
|
|
|
1bdc94 |
'blockdev-backup': 'BlockdevBackup',
|
|
|
1bdc94 |
'blockdev-snapshot': 'BlockdevSnapshot',
|
|
|
1bdc94 |
'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal',
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|