Skip to content

Commit

Permalink
block/backup: hoist bitmap check into QMP interface
Browse files Browse the repository at this point in the history
This is nicer to do in the unified QMP interface that we have now,
because it lets us use the right terminology back at the user.

Signed-off-by: John Snow <[email protected]>
Reviewed-by: Max Reitz <[email protected]>
Message-id: [email protected]
Signed-off-by: John Snow <[email protected]>
  • Loading branch information
jnsnow committed Aug 16, 2019
1 parent 0af2a09 commit a6c9365
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
13 changes: 4 additions & 9 deletions block/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,10 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
assert(bs);
assert(target);

/* QMP interface protects us from these cases */
assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);
assert(sync_bitmap || sync_mode != MIRROR_SYNC_MODE_BITMAP);

if (bs == target) {
error_setg(errp, "Source and target cannot be the same");
return NULL;
Expand Down Expand Up @@ -607,16 +611,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs,
return NULL;
}

/* QMP interface should have handled translating this to bitmap mode */
assert(sync_mode != MIRROR_SYNC_MODE_INCREMENTAL);

if (sync_mode == MIRROR_SYNC_MODE_BITMAP) {
if (!sync_bitmap) {
error_setg(errp, "must provide a valid bitmap name for "
"'%s' sync mode", MirrorSyncMode_str(sync_mode));
return NULL;
}

/* If we need to write to this bitmap, check that we can: */
if (bitmap_mode != BITMAP_SYNC_MODE_NEVER &&
bdrv_dirty_bitmap_check(sync_bitmap, BDRV_BITMAP_DEFAULT, errp)) {
Expand Down
10 changes: 10 additions & 0 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -3529,6 +3529,16 @@ static BlockJob *do_backup_common(BackupCommon *backup,
return NULL;
}

if ((backup->sync == MIRROR_SYNC_MODE_BITMAP) ||
(backup->sync == MIRROR_SYNC_MODE_INCREMENTAL)) {
/* done before desugaring 'incremental' to print the right message */
if (!backup->has_bitmap) {
error_setg(errp, "must provide a valid bitmap name for "
"'%s' sync mode", MirrorSyncMode_str(backup->sync));
return NULL;
}
}

if (backup->sync == MIRROR_SYNC_MODE_INCREMENTAL) {
if (backup->has_bitmap_mode &&
backup->bitmap_mode != BITMAP_SYNC_MODE_ON_SUCCESS) {
Expand Down

0 comments on commit a6c9365

Please sign in to comment.