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

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