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 <arm...@redhat.com> --- block/mirror.c | 7 +------ blockdev.c | 5 +++++ include/block/block_int.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 27b4c7f..af0c989 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -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; diff --git a/blockdev.c b/blockdev.c index 4d9a665..06f87e3 100644 --- a/blockdev.c +++ b/blockdev.c @@ -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]"); diff --git a/include/block/block_int.h b/include/block/block_int.h index 695d7b3..3ff5536 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -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, -- 2.7.5