aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2019-07-29 16:35:52 -0400
committerJohn Snow <jsnow@redhat.com>2019-08-16 16:28:02 -0400
commitc8b56501780615f709d96419fd718ca562d41c46 (patch)
tree8b52259a49f81a7405f8f94f511892416ad7c14f /blockdev.c
parent00a463b1dc73d1665ce6720df4de052aff95acf8 (diff)
downloadqemu-c8b56501780615f709d96419fd718ca562d41c46.zip
qemu-c8b56501780615f709d96419fd718ca562d41c46.tar.gz
qemu-c8b56501780615f709d96419fd718ca562d41c46.tar.bz2
block/backup: Add mirror sync mode 'bitmap'
We don't need or want a new sync mode for simple differences in semantics. Create a new mode simply named "BITMAP" that is designed to make use of the new Bitmap Sync Mode field. Because the only bitmap sync mode is 'on-success', this adds no new functionality to the backup job (yet). The old incremental backup mode is maintained as a syntactic sugar for sync=bitmap, mode=on-success. Add all of the plumbing necessary to support this new instruction. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-id: 20190709232550.10724-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/blockdev.c b/blockdev.c
index 8e4f70a..985b6cd 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3466,12 +3466,31 @@ static BlockJob *do_backup_common(BackupCommon *backup,
return NULL;
}
+ if (backup->sync == MIRROR_SYNC_MODE_INCREMENTAL) {
+ if (backup->has_bitmap_mode &&
+ backup->bitmap_mode != BITMAP_SYNC_MODE_ON_SUCCESS) {
+ error_setg(errp, "Bitmap sync mode must be '%s' "
+ "when using sync mode '%s'",
+ BitmapSyncMode_str(BITMAP_SYNC_MODE_ON_SUCCESS),
+ MirrorSyncMode_str(backup->sync));
+ return NULL;
+ }
+ backup->has_bitmap_mode = true;
+ backup->sync = MIRROR_SYNC_MODE_BITMAP;
+ backup->bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
+ }
+
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);
return NULL;
}
+ if (!backup->has_bitmap_mode) {
+ error_setg(errp, "Bitmap sync mode must be given "
+ "when providing a bitmap");
+ return NULL;
+ }
if (bdrv_dirty_bitmap_check(bmap, BDRV_BITMAP_DEFAULT, errp)) {
return NULL;
}
@@ -3485,8 +3504,10 @@ static BlockJob *do_backup_common(BackupCommon *backup,
}
job = backup_job_create(backup->job_id, bs, target_bs, backup->speed,
- backup->sync, bmap, backup->compress,
- backup->on_source_error, backup->on_target_error,
+ backup->sync, bmap, backup->bitmap_mode,
+ backup->compress,
+ backup->on_source_error,
+ backup->on_target_error,
job_flags, NULL, NULL, txn, errp);
return job;
}