yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

ae23c9
From 5acc09c438937522b0bc4ae5b9a1968ef11e049c Mon Sep 17 00:00:00 2001
ae23c9
From: John Snow <jsnow@redhat.com>
ae23c9
Date: Tue, 20 Nov 2018 18:18:15 +0000
ae23c9
Subject: [PATCH 21/35] qapi: add transaction support for
ae23c9
 x-block-dirty-bitmap-merge
ae23c9
ae23c9
RH-Author: John Snow <jsnow@redhat.com>
ae23c9
Message-id: <20181120181828.15132-12-jsnow@redhat.com>
ae23c9
Patchwork-id: 83066
ae23c9
O-Subject: [RHEL8/rhel qemu-kvm PATCH 11/24] qapi: add transaction support for x-block-dirty-bitmap-merge
ae23c9
Bugzilla: 1518989
ae23c9
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
ae23c9
New action is like clean action: do the whole thing in .prepare and
ae23c9
undo in .abort. This behavior for bitmap-changing actions is needed
ae23c9
because backup job actions use bitmap in .prepare.
ae23c9
ae23c9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
Reviewed-by: John Snow <jsnow@redhat.com>
ae23c9
(cherry picked from commit 6fd2e40789ef7389b17c5fff93b0bf82d4352cb3)
ae23c9
Signed-off-by: John Snow <jsnow@redhat.com>
ae23c9
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ae23c9
---
ae23c9
 blockdev.c            | 35 +++++++++++++++++++++++++++++++++++
ae23c9
 qapi/transaction.json |  2 ++
ae23c9
 2 files changed, 37 insertions(+)
ae23c9
ae23c9
diff --git a/blockdev.c b/blockdev.c
ae23c9
index c4b9ddd..d2e7e5a 100644
ae23c9
--- a/blockdev.c
ae23c9
+++ b/blockdev.c
ae23c9
@@ -2222,6 +2222,35 @@ static void block_dirty_bitmap_disable_abort(BlkActionState *common)
ae23c9
     }
ae23c9
 }
ae23c9
 
ae23c9
+static void block_dirty_bitmap_merge_prepare(BlkActionState *common,
ae23c9
+                                             Error **errp)
ae23c9
+{
ae23c9
+    BlockDirtyBitmapMerge *action;
ae23c9
+    BlockDirtyBitmapState *state = DO_UPCAST(BlockDirtyBitmapState,
ae23c9
+                                             common, common);
ae23c9
+    BdrvDirtyBitmap *merge_source;
ae23c9
+
ae23c9
+    if (action_check_completion_mode(common, errp) < 0) {
ae23c9
+        return;
ae23c9
+    }
ae23c9
+
ae23c9
+    action = common->action->u.x_block_dirty_bitmap_merge.data;
ae23c9
+    state->bitmap = block_dirty_bitmap_lookup(action->node,
ae23c9
+                                              action->dst_name,
ae23c9
+                                              &state->bs,
ae23c9
+                                              errp);
ae23c9
+    if (!state->bitmap) {
ae23c9
+        return;
ae23c9
+    }
ae23c9
+
ae23c9
+    merge_source = bdrv_find_dirty_bitmap(state->bs, action->src_name);
ae23c9
+    if (!merge_source) {
ae23c9
+        return;
ae23c9
+    }
ae23c9
+
ae23c9
+    bdrv_merge_dirty_bitmap(state->bitmap, merge_source, &state->backup, errp);
ae23c9
+}
ae23c9
+
ae23c9
 static void abort_prepare(BlkActionState *common, Error **errp)
ae23c9
 {
ae23c9
     error_setg(errp, "Transaction aborted using Abort action");
ae23c9
@@ -2293,6 +2322,12 @@ static const BlkActionOps actions[] = {
ae23c9
         .prepare = block_dirty_bitmap_disable_prepare,
ae23c9
         .abort = block_dirty_bitmap_disable_abort,
ae23c9
     },
ae23c9
+    [TRANSACTION_ACTION_KIND_X_BLOCK_DIRTY_BITMAP_MERGE] = {
ae23c9
+        .instance_size = sizeof(BlockDirtyBitmapState),
ae23c9
+        .prepare = block_dirty_bitmap_merge_prepare,
ae23c9
+        .commit = block_dirty_bitmap_free_backup,
ae23c9
+        .abort = block_dirty_bitmap_restore,
ae23c9
+    },
ae23c9
     /* Where are transactions for MIRROR, COMMIT and STREAM?
ae23c9
      * Although these blockjobs use transaction callbacks like the backup job,
ae23c9
      * these jobs do not necessarily adhere to transaction semantics.
ae23c9
diff --git a/qapi/transaction.json b/qapi/transaction.json
ae23c9
index d7e4274..5875cdb 100644
ae23c9
--- a/qapi/transaction.json
ae23c9
+++ b/qapi/transaction.json
ae23c9
@@ -48,6 +48,7 @@
ae23c9
 # - @block-dirty-bitmap-clear: since 2.5
ae23c9
 # - @x-block-dirty-bitmap-enable: since 3.0
ae23c9
 # - @x-block-dirty-bitmap-disable: since 3.0
ae23c9
+# - @x-block-dirty-bitmap-merge: since 3.1
ae23c9
 # - @blockdev-backup: since 2.3
ae23c9
 # - @blockdev-snapshot: since 2.5
ae23c9
 # - @blockdev-snapshot-internal-sync: since 1.7
ae23c9
@@ -63,6 +64,7 @@
ae23c9
        'block-dirty-bitmap-clear': 'BlockDirtyBitmap',
ae23c9
        'x-block-dirty-bitmap-enable': 'BlockDirtyBitmap',
ae23c9
        'x-block-dirty-bitmap-disable': 'BlockDirtyBitmap',
ae23c9
+       'x-block-dirty-bitmap-merge': 'BlockDirtyBitmapMerge',
ae23c9
        'blockdev-backup': 'BlockdevBackup',
ae23c9
        'blockdev-snapshot': 'BlockdevSnapshot',
ae23c9
        'blockdev-snapshot-internal-sync': 'BlockdevSnapshotInternal',
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9