@@ -1283,7 +1283,7 @@ fail:
void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
- int64_t speed, uint64_t granularity, int64_t buf_size,
+ uint64_t speed, uint64_t granularity, int64_t buf_size,
MirrorSyncMode mode, BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
@@ -1292,11 +1292,6 @@ void mirror_start(const char *job_id, BlockDriverState *bs,
bool is_none_mode;
BlockDriverState *base;
- if (speed < 0) {
- error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed",
- "a non-negative rate limit");
- return;
- }
if (mode == MIRROR_SYNC_MODE_INCREMENTAL) {
error_setg(errp, "Sync mode 'incremental' not supported");
return;
@@ -3454,6 +3454,11 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs,
filter_node_name = NULL;
}
+ if (speed < 0) {
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed",
+ "a non-negative rate limit");
+ return;
+ }
if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) {
error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity",
"a value in range [512B, 64MB]");
@@ -896,7 +896,7 @@ void commit_active_start(const char *job_id, BlockDriverState *bs,
*/
void mirror_start(const char *job_id, BlockDriverState *bs,
BlockDriverState *target, const char *replaces,
- int64_t speed, uint64_t granularity, int64_t buf_size,
+ uint64_t speed, uint64_t granularity, int64_t buf_size,
MirrorSyncMode mode, BlockMirrorBackingMode backing_mode,
BlockdevOnError on_source_error,
BlockdevOnError on_target_error,
mirror_start() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. mirror_start() converts from int64_t to uint64_t, rejecting negative speed. Lift this check and conversion out of mirror_start() into its caller. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster <armbru@redhat.com> --- block/mirror.c | 7 +------ blockdev.c | 5 +++++ include/block/block_int.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-)