cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 5d85a570191c28cc5c1f894c7fcfd1d14bf80033 Mon Sep 17 00:00:00 2001
26ba25
From: John Snow <jsnow@redhat.com>
26ba25
Date: Tue, 20 Nov 2018 18:18:10 +0000
26ba25
Subject: [PATCH 16/35] blockdev-backup: add bitmap argument
26ba25
26ba25
RH-Author: John Snow <jsnow@redhat.com>
26ba25
Message-id: <20181120181828.15132-7-jsnow@redhat.com>
26ba25
Patchwork-id: 83060
26ba25
O-Subject: [RHEL8/rhel qemu-kvm PATCH 06/24] blockdev-backup: add bitmap argument
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
It is only an oversight that we don't allow incremental backup with
26ba25
blockdev-backup. Add the bitmap argument which enables this.
26ba25
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
Message-id: 20180830211605.13683-2-jsnow@redhat.com
26ba25
Signed-off-by: John Snow <jsnow@redhat.com>
26ba25
(cherry picked from commit 945c1ee0cb7d29f2fd0fece2cd2b5329802de5e9)
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           | 18 +++++++++++++++++-
26ba25
 qapi/block-core.json |  7 ++++++-
26ba25
 2 files changed, 23 insertions(+), 2 deletions(-)
26ba25
26ba25
diff --git a/blockdev.c b/blockdev.c
26ba25
index 69610e7..a722188 100644
26ba25
--- a/blockdev.c
26ba25
+++ b/blockdev.c
26ba25
@@ -3654,6 +3654,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
26ba25
     BlockDriverState *bs;
26ba25
     BlockDriverState *target_bs;
26ba25
     Error *local_err = NULL;
26ba25
+    BdrvDirtyBitmap *bmap = NULL;
26ba25
     AioContext *aio_context;
26ba25
     BlockJob *job = NULL;
26ba25
     int job_flags = JOB_DEFAULT;
26ba25
@@ -3704,6 +3705,21 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
26ba25
             goto out;
26ba25
         }
26ba25
     }
26ba25
+
26ba25
+    if (backup->has_bitmap) {
26ba25
+        bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap);
26ba25
+        if (!bmap) {
26ba25
+            error_setg(errp, "Bitmap '%s' could not be found", backup->bitmap);
26ba25
+            goto out;
26ba25
+        }
26ba25
+        if (bdrv_dirty_bitmap_qmp_locked(bmap)) {
26ba25
+            error_setg(errp,
26ba25
+                       "Bitmap '%s' is currently locked and cannot be used for "
26ba25
+                       "backup", backup->bitmap);
26ba25
+            goto out;
26ba25
+        }
26ba25
+    }
26ba25
+
26ba25
     if (!backup->auto_finalize) {
26ba25
         job_flags |= JOB_MANUAL_FINALIZE;
26ba25
     }
26ba25
@@ -3711,7 +3727,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, JobTxn *txn,
26ba25
         job_flags |= JOB_MANUAL_DISMISS;
26ba25
     }
26ba25
     job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
26ba25
-                            backup->sync, NULL, backup->compress,
26ba25
+                            backup->sync, bmap, backup->compress,
26ba25
                             backup->on_source_error, backup->on_target_error,
26ba25
                             job_flags, NULL, NULL, txn, &local_err);
26ba25
     if (local_err != NULL) {
26ba25
diff --git a/qapi/block-core.json b/qapi/block-core.json
26ba25
index 5fb7983..a6c3977 100644
26ba25
--- a/qapi/block-core.json
26ba25
+++ b/qapi/block-core.json
26ba25
@@ -1293,6 +1293,10 @@
26ba25
 # @speed: the maximum speed, in bytes per second. The default is 0,
26ba25
 #         for unlimited.
26ba25
 #
26ba25
+# @bitmap: the name of dirty bitmap if sync is "incremental".
26ba25
+#          Must be present if sync is "incremental", must NOT be present
26ba25
+#          otherwise. (Since 3.1)
26ba25
+#
26ba25
 # @compress: true to compress data, if the target format supports it.
26ba25
 #            (default: false) (since 2.8)
26ba25
 #
26ba25
@@ -1325,7 +1329,8 @@
26ba25
 ##
26ba25
 { 'struct': 'BlockdevBackup',
26ba25
   'data': { '*job-id': 'str', 'device': 'str', 'target': 'str',
26ba25
-            'sync': 'MirrorSyncMode', '*speed': 'int', '*compress': 'bool',
26ba25
+            'sync': 'MirrorSyncMode', '*speed': 'int',
26ba25
+            '*bitmap': 'str', '*compress': 'bool',
26ba25
             '*on-source-error': 'BlockdevOnError',
26ba25
             '*on-target-error': 'BlockdevOnError',
26ba25
             '*auto-finalize': 'bool', '*auto-dismiss': 'bool' } }
26ba25
-- 
26ba25
1.8.3.1
26ba25