mirror of
https://github.com/mii443/qemu.git
synced 2025-08-22 15:15:46 +00:00
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>
This commit is contained in:
25
blockdev.c
25
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user