yeahuh / rpms / qemu-kvm

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