Blame SOURCES/kvm-qapi-add-transaction-support-for-x-block-dirty-bitma.patch

7711c0
From f678429fca4701bda6a4631722e99c57a977846f Mon Sep 17 00:00:00 2001
7711c0
From: John Snow <jsnow@redhat.com>
7711c0
Date: Wed, 6 Feb 2019 22:12:30 +0100
7711c0
Subject: [PATCH 20/33] qapi: add transaction support for
7711c0
 x-block-dirty-bitmap-merge
7711c0
7711c0
RH-Author: John Snow <jsnow@redhat.com>
7711c0
Message-id: <20190206221243.7407-11-jsnow@redhat.com>
7711c0
Patchwork-id: 84270
7711c0
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v2 10/23] qapi: add transaction support for x-block-dirty-bitmap-merge
7711c0
Bugzilla: 1658343
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
7711c0
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
7711c0
New action is like clean action: do the whole thing in .prepare and
7711c0
undo in .abort. This behavior for bitmap-changing actions is needed
7711c0
because backup job actions use bitmap in .prepare.
7711c0
7711c0
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
7711c0
Reviewed-by: John Snow <jsnow@redhat.com>
7711c0
(cherry picked from commit 6fd2e40789ef7389b17c5fff93b0bf82d4352cb3)
7711c0
Signed-off-by: John Snow <jsnow@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 blockdev.c            | 35 +++++++++++++++++++++++++++++++++++
7711c0
 qapi/transaction.json |  2 ++
7711c0
 2 files changed, 37 insertions(+)
7711c0
7711c0
diff --git a/blockdev.c b/blockdev.c
7711c0
index 853dd0e..df0cbe2 100644
7711c0
--- a/blockdev.c
7711c0
+++ b/blockdev.c
7711c0
@@ -2264,6 +2264,35 @@ static void block_dirty_bitmap_disable_abort(BlkActionState *common)
7711c0
     }
7711c0
 }
7711c0
 
7711c0
+static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
7711c0
+                                             Error **errp)
7711c0
+{
7711c0
+    BlockDirtyBitmapMerge *action;
7711c0
+    BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
7711c0
+                                             common, common);
7711c0
+    BdrvDirtyBitmap *merge_source;
7711c0
+
7711c0
+    if (action_check_completion_mode(common, errp) < 0) {
7711c0
+        return;
7711c0
+    }
7711c0
+
7711c0
+    action = common->action->u.x_block_dirty_bitmap_merge.data;
7711c0
+    state->bitmap = block_dirty_bitmap_lookup(action->node,
7711c0
+                                              action->dst_name,
7711c0
+                                              &state->bs,
7711c0
+                                              errp);
7711c0
+    if (!state->bitmap) {
7711c0
+        return;
7711c0
+    }
7711c0
+
7711c0
+    merge_source = bdrv_find_dirty_bitmap(state->bs, action->src_name);
7711c0
+    if (!merge_source) {
7711c0
+        return;
7711c0
+    }
7711c0
+
7711c0
+    bdrv_merge_dirty_bitmap(state->bitmap, merge_source, &state->backup, errp);
7711c0
+}
7711c0
+
7711c0
 static void abort_prepare(BlkActionState *common, Error **errp)
7711c0
 {
7711c0
     error_setg(errp, "Transaction aborted using Abort action");
7711c0
@@ -2335,6 +2364,12 @@ static const BlkActionOps actions[] = {
7711c0
         .prepare = block_dirty_bitmap_disable_prepare,
7711c0
         .abort = block_dirty_bitmap_disable_abort,
7711c0
     },
7711c0
+    [TRANSACTION_ACTION_KIND_X_BLOCK_DIRTY_BITMAP_MERGE] = {
7711c0
+        .instance_size = sizeof(BlockDirtyBitmapState),
7711c0
+        .prepare = block_dirty_bitmap_merge_prepare,
7711c0
+        .commit = block_dirty_bitmap_free_backup,
7711c0
+        .abort = block_dirty_bitmap_restore,
7711c0
+    },
7711c0
     /* Where are transactions for MIRROR, COMMIT and STREAM?
7711c0
      * Although these blockjobs use transaction callbacks like the backup job,
7711c0
      * these jobs do not necessarily adhere to transaction semantics.
7711c0
diff --git a/qapi/transaction.json b/qapi/transaction.json
7711c0
index d7e4274..5875cdb 100644
7711c0
--- a/qapi/transaction.json
7711c0
+++ b/qapi/transaction.json
7711c0
@@ -48,6 +48,7 @@
7711c0
 # - @block-dirty-bitmap-clear: since 2.5
7711c0
 # - @x-block-dirty-bitmap-enable: since 3.0
7711c0
 # - @x-block-dirty-bitmap-disable: since 3.0
7711c0
+# - @x-block-dirty-bitmap-merge: since 3.1
7711c0
 # - @blockdev-backup: since 2.3
7711c0
 # - @blockdev-snapshot: since 2.5
7711c0
 # - @blockdev-snapshot-internal-sync: since 1.7
7711c0
@@ -63,6 +64,7 @@
7711c0
        'block-dirty-bitmap-clear': 'BlockDirtyBitmap',
7711c0
        'x-block-dirty-bitmap-enable': 'BlockDirtyBitmap',
7711c0
        'x-block-dirty-bitmap-disable': 'BlockDirtyBitmap',
7711c0
+       'x-block-dirty-bitmap-merge': 'BlockDirtyBitmapMerge',
7711c0
        'blockdev-backup': 'BlockdevBackup',
7711c0
        'blockdev-snapshot': 'BlockdevSnapshot',
7711c0
        'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal',
7711c0
-- 
7711c0
1.8.3.1
7711c0