mirror_start_job() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. mirror_start_job() converts from int64_t to uint64_t, rejecting negative speed.
Lift this check and conversion out of mirror_start_job() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster <arm...@redhat.com> --- block/mirror.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index af54163..27b4c7f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1119,7 +1119,7 @@ static BlockDriver bdrv_mirror_top = { static void mirror_start_job(const char *job_id, BlockDriverState *bs, int creation_flags, BlockDriverState *target, - const char *replaces, int64_t speed, + const char *replaces, uint64_t speed, uint64_t granularity, int64_t buf_size, BlockMirrorBackingMode backing_mode, BlockdevOnError on_source_error, @@ -1139,12 +1139,6 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, Error *local_err = NULL; int ret; - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", - "a non-negative rate limit"); - return; - } - if (granularity == 0) { granularity = bdrv_get_default_bitmap_granularity(target); } @@ -1298,6 +1292,11 @@ 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; @@ -1323,6 +1322,12 @@ void commit_active_start(const char *job_id, BlockDriverState *bs, orig_base_flags = bdrv_get_flags(base); + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + if (bdrv_reopen(base, bs->open_flags, errp)) { return; } -- 2.7.5