@@ -37,7 +37,7 @@ typedef struct BackupBlockJob {
BdrvDirtyBitmap *sync_bitmap;
- MirrorSyncMode sync_mode;
+ BackupSyncMode sync_mode;
BitmapSyncMode bitmap_mode;
BlockdevOnError on_source_error;
BlockdevOnError on_target_error;
@@ -111,7 +111,7 @@ void backup_do_checkpoint(BlockJob *job, Error **errp)
assert(block_job_driver(job) == &backup_job_driver);
- if (backup_job->sync_mode != MIRROR_SYNC_MODE_NONE) {
+ if (backup_job->sync_mode != BACKUP_SYNC_MODE_NONE) {
error_setg(errp, "The backup job only supports block checkpoint in"
" sync=none mode");
return;
@@ -231,11 +231,11 @@ static void backup_init_bcs_bitmap(BackupBlockJob *job)
uint64_t estimate;
BdrvDirtyBitmap *bcs_bitmap = block_copy_dirty_bitmap(job->bcs);
- if (job->sync_mode == MIRROR_SYNC_MODE_BITMAP) {
+ if (job->sync_mode == BACKUP_SYNC_MODE_BITMAP) {
bdrv_clear_dirty_bitmap(bcs_bitmap, NULL);
bdrv_dirty_bitmap_merge_internal(bcs_bitmap, job->sync_bitmap, NULL,
true);
- } else if (job->sync_mode == MIRROR_SYNC_MODE_TOP) {
+ } else if (job->sync_mode == BACKUP_SYNC_MODE_TOP) {
/*
* We can't hog the coroutine to initialize this thoroughly.
* Set a flag and resume work when we are able to yield safely.
@@ -254,7 +254,7 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
backup_init_bcs_bitmap(s);
- if (s->sync_mode == MIRROR_SYNC_MODE_TOP) {
+ if (s->sync_mode == BACKUP_SYNC_MODE_TOP) {
int64_t offset = 0;
int64_t count;
@@ -282,7 +282,7 @@ static int coroutine_fn backup_run(Job *job, Error **errp)
block_copy_set_skip_unallocated(s->bcs, false);
}
- if (s->sync_mode == MIRROR_SYNC_MODE_NONE) {
+ if (s->sync_mode == BACKUP_SYNC_MODE_NONE) {
/*
* All bits are set in bcs bitmap to allow any cluster to be copied.
* This does not actually require them to be copied.
@@ -354,7 +354,7 @@ static const BlockJobDriver backup_job_driver = {
BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, int64_t speed,
- MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap,
+ BackupSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap,
BitmapSyncMode bitmap_mode,
bool compress,
const char *filter_node_name,
@@ -376,8 +376,8 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
GLOBAL_STATE_CODE();
/* QMP interface protects us from these cases */
- assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
- assert(sync_bitmap || sync_mode != MIRROR_SYNC_MODE_BITMAP);
+ assert(sync_mode != BACKUP_SYNC_MODE_INCREMENTAL);
+ assert(sync_bitmap || sync_mode != BACKUP_SYNC_MODE_BITMAP);
if (bs == target) {
error_setg(errp, "Source and target cannot be the same");
@@ -2011,13 +2011,6 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
GLOBAL_STATE_CODE();
- if ((mode == MIRROR_SYNC_MODE_INCREMENTAL) ||
- (mode == MIRROR_SYNC_MODE_BITMAP)) {
- error_setg(errp, "Sync mode '%s' not supported",
- MirrorSyncMode_str(mode));
- return;
- }
-
bdrv_graph_rdlock_main_loop();
is_none_mode = mode == MIRROR_SYNC_MODE_NONE;
base = mode == MIRROR_SYNC_MODE_TOP ? bdrv_backing_chain_next(bs) : NULL;
@@ -266,7 +266,7 @@ void hmp_drive_backup(Monitor *mon, const QDict *qdict)
.device = (char *)device,
.target = (char *)filename,
.format = (char *)format,
- .sync = full ? MIRROR_SYNC_MODE_FULL : MIRROR_SYNC_MODE_TOP,
+ .sync = full ? BACKUP_SYNC_MODE_FULL : BACKUP_SYNC_MODE_TOP,
.has_mode = true,
.mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS,
.has_compress = !!compress,
@@ -582,7 +582,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
s->backup_job = backup_job_create(
NULL, s->secondary_disk->bs, s->hidden_disk->bs,
- 0, MIRROR_SYNC_MODE_NONE, NULL, 0, false, NULL,
+ 0, BACKUP_SYNC_MODE_NONE, NULL, 0, false, NULL,
&perf,
BLOCKDEV_ON_ERROR_REPORT,
BLOCKDEV_ON_ERROR_REPORT, JOB_INTERNAL,
@@ -1642,7 +1642,7 @@ static void drive_backup_action(DriveBackup *backup,
* See if we have a backing HD we can use to create our new image
* on top of.
*/
- if (backup->sync == MIRROR_SYNC_MODE_TOP) {
+ if (backup->sync == BACKUP_SYNC_MODE_TOP) {
/*
* Backup will not replace the source by the target, so none
* of the filters skipped here will be removed (in contrast to
@@ -1651,10 +1651,10 @@ static void drive_backup_action(DriveBackup *backup,
*/
source = bdrv_cow_bs(bdrv_skip_filters(bs));
if (!source) {
- backup->sync = MIRROR_SYNC_MODE_FULL;
+ backup->sync = BACKUP_SYNC_MODE_FULL;
}
}
- if (backup->sync == MIRROR_SYNC_MODE_NONE) {
+ if (backup->sync == BACKUP_SYNC_MODE_NONE) {
source = bs;
flags |= BDRV_O_NO_BACKING;
set_backing_hd = true;
@@ -2655,27 +2655,27 @@ static BlockJob *do_backup_common(BackupCommon *backup,
}
}
- if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
- (backup->sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
+ if ((backup->sync == BACKUP_SYNC_MODE_BITMAP) ||
+ (backup->sync == BACKUP_SYNC_MODE_INCREMENTAL)) {
/* done before desugaring 'incremental' to print the right message */
if (!backup->bitmap) {
error_setg(errp, "must provide a valid bitmap name for "
- "'%s' sync mode", MirrorSyncMode_str(backup->sync));
+ "'%s' sync mode", BackupSyncMode_str(backup->sync));
return NULL;
}
}
- if (backup->sync == MIRROR_SYNC_MODE_INCREMENTAL) {
+ if (backup->sync == BACKUP_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));
+ BackupSyncMode_str(backup->sync));
return NULL;
}
backup->has_bitmap_mode = true;
- backup->sync = MIRROR_SYNC_MODE_BITMAP;
+ backup->sync = BACKUP_SYNC_MODE_BITMAP;
backup->bitmap_mode = BITMAP_SYNC_MODE_ON_SUCCESS;
}
@@ -2695,19 +2695,19 @@ static BlockJob *do_backup_common(BackupCommon *backup,
}
/* This does not produce a useful bitmap artifact: */
- if (backup->sync == MIRROR_SYNC_MODE_NONE) {
+ if (backup->sync == BACKUP_SYNC_MODE_NONE) {
error_setg(errp, "sync mode '%s' does not produce meaningful bitmap"
- " outputs", MirrorSyncMode_str(backup->sync));
+ " outputs", BackupSyncMode_str(backup->sync));
return NULL;
}
/* If the bitmap isn't used for input or output, this is useless: */
if (backup->bitmap_mode == BITMAP_SYNC_MODE_NEVER &&
- backup->sync != MIRROR_SYNC_MODE_BITMAP) {
+ backup->sync != BACKUP_SYNC_MODE_BITMAP) {
error_setg(errp, "Bitmap sync mode '%s' has no meaningful effect"
" when combined with sync mode '%s'",
BitmapSyncMode_str(backup->bitmap_mode),
- MirrorSyncMode_str(backup->sync));
+ BackupSyncMode_str(backup->sync));
return NULL;
}
}
@@ -190,7 +190,7 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
*/
BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, int64_t speed,
- MirrorSyncMode sync_mode,
+ BackupSyncMode sync_mode,
BdrvDirtyBitmap *sync_bitmap,
BitmapSyncMode bitmap_mode,
bool compress,
@@ -1304,10 +1304,10 @@
'data': ['report', 'ignore', 'enospc', 'stop', 'auto'] }
##
-# @MirrorSyncMode:
+# @BackupSyncMode:
#
-# An enumeration of possible behaviors for the initial synchronization
-# phase of storage mirroring.
+# An enumeration of possible behaviors for image synchronization used
+# by backup jobs.
#
# @top: copies data in the topmost image to the destination
#
@@ -1323,7 +1323,7 @@
#
# Since: 1.3
##
-{ 'enum': 'MirrorSyncMode',
+{ 'enum': 'BackupSyncMode',
'data': ['top', 'full', 'none', 'incremental', 'bitmap'] }
##
@@ -1347,6 +1347,23 @@
{ 'enum': 'BitmapSyncMode',
'data': ['on-success', 'never', 'always'] }
+##
+# @MirrorSyncMode:
+#
+# An enumeration of possible behaviors for the initial synchronization
+# phase of storage mirroring.
+#
+# @top: copies data in the topmost image to the destination
+#
+# @full: copies data from all images to the destination
+#
+# @none: only copy data written from now on
+#
+# Since: 1.3
+##
+{ 'enum': 'MirrorSyncMode',
+ 'data': ['top', 'full', 'none'] }
+
##
# @MirrorCopyMode:
#
@@ -1624,7 +1641,7 @@
##
{ 'struct': 'BackupCommon',
'data': { '*job-id': 'str', 'device': 'str',
- 'sync': 'MirrorSyncMode', '*speed': 'int',
+ 'sync': 'BackupSyncMode', '*speed': 'int',
'*bitmap': 'str', '*bitmap-mode': 'BitmapSyncMode',
'*compress': 'bool',
'*on-source-error': 'BlockdevOnError',
Backup supports all modes listed in MirrorSyncMode, while mirror does not. Introduce BackupSyncMode by copying the current MirrorSyncMode and drop the variants mirror does not support from MirrorSyncMode as well as the corresponding manual check in mirror_start(). Suggested-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> --- I felt like keeping the "Since: X.Y" as before makes the most sense as to not lose history. Or is it necessary to change this for BackupSyncMode (and its members) since it got a new name? block/backup.c | 18 ++++++++--------- block/mirror.c | 7 ------- block/monitor/block-hmp-cmds.c | 2 +- block/replication.c | 2 +- blockdev.c | 26 ++++++++++++------------- include/block/block_int-global-state.h | 2 +- qapi/block-core.json | 27 +++++++++++++++++++++----- 7 files changed, 47 insertions(+), 37 deletions(-)