thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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