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

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