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

100 lines
3.7 KiB
Diff

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