Blame SOURCES/kvm-blockdev-backup-add-bitmap-argument.patch

357786
From f165f8b7819f9c9aa0358a1e0bc1f48cf4dfa98f Mon Sep 17 00:00:00 2001
357786
From: John Snow <jsnow@redhat.com>
357786
Date: Fri, 14 Sep 2018 04:08:14 +0200
357786
Subject: [PATCH 07/49] blockdev-backup: add bitmap argument
357786
357786
RH-Author: John Snow <jsnow@redhat.com>
357786
Message-id: <20180914040814.14950-2-jsnow@redhat.com>
357786
Patchwork-id: 82149
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 1/1] blockdev-backup: add bitmap argument
357786
Bugzilla: 1628373
357786
RH-Acked-by: Fam Zheng <famz@redhat.com>
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
357786
357786
It is only an oversight that we don't allow incremental backup with
357786
blockdev-backup. Add the bitmap argument which enables this.
357786
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Message-id: 20180830211605.13683-2-jsnow@redhat.com
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
(cherry picked from commit 4034c1a9fd503f9fa488dc9b851bc4497f374e98)
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 blockdev.c           | 16 +++++++++++++++-
357786
 qapi/block-core.json |  7 ++++++-
357786
 2 files changed, 21 insertions(+), 2 deletions(-)
357786
357786
diff --git a/blockdev.c b/blockdev.c
357786
index fb355c8..6e8a1e9 100644
357786
--- a/blockdev.c
357786
+++ b/blockdev.c
357786
@@ -3701,6 +3701,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
357786
     BlockDriverState *bs;
357786
     BlockDriverState *target_bs;
357786
     Error *local_err = NULL;
357786
+    BdrvDirtyBitmap *bmap = NULL;
357786
     AioContext *aio_context;
357786
     BlockJob *job = NULL;
357786
     int job_flags = JOB_DEFAULT;
357786
@@ -3751,6 +3752,19 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
357786
             goto out;
357786
         }
357786
     }
357786
+    if (backup->has_bitmap) {
357786
+        bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
357786
+        if (!bmap) {
357786
+            error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
357786
+            goto out;
357786
+        }
357786
+        if (bdrv_dirty_bitmap_qmp_locked(bmap)) {
357786
+            error_setg(errp,
357786
+                       "Bitmap '%s' is currently locked and cannot be used for "
357786
+                       "backup", backup->bitmap);
357786
+            goto out;
357786
+        }
357786
+    }
357786
     if (!backup->auto_finalize) {
357786
         job_flags |= JOB_MANUAL_FINALIZE;
357786
     }
357786
@@ -3758,7 +3772,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
357786
         job_flags |= JOB_MANUAL_DISMISS;
357786
     }
357786
     job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
357786
-                            backup->sync, NULL, backup->compress,
357786
+                            backup->sync, bmap, backup->compress,
357786
                             backup->on_source_error, backup->on_target_error,
357786
                             job_flags, NULL, NULL, txn, &local_err);
357786
     if (local_err != NULL) {
357786
diff --git a/qapi/block-core.json b/qapi/block-core.json
357786
index 8da07cd..2706012 100644
357786
--- a/qapi/block-core.json
357786
+++ b/qapi/block-core.json
357786
@@ -1299,6 +1299,10 @@
357786
 # @speed: the maximum speed, in bytes per second. The default is 0,
357786
 #         for unlimited.
357786
 #
357786
+# @bitmap: the name of dirty bitmap if sync is "incremental".
357786
+#          Must be present if sync is "incremental", must NOT be present
357786
+#          otherwise. (Since 3.1)
357786
+#
357786
 # @compress: true to compress data, if the target format supports it.
357786
 #            (default: false) (since 2.8)
357786
 #
357786
@@ -1331,7 +1335,8 @@
357786
 ##
357786
 { 'struct': 'BlockdevBackup',
357786
   'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
357786
-            'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool',
357786
+            'sync': 'MirrorSyncMode', '*speed': 'int',
357786
+            '*bitmap': 'str', '*compress': 'bool',
357786
             '*on-source-error': 'BlockdevOnError',
357786
             '*on-target-error': 'BlockdevOnError',
357786
             '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
357786
-- 
357786
1.8.3.1
357786