blockdev_mirror_common() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. blockdev_mirror_common() converts from int64_t to uint64_t, rejecting negative speed.
Lift this check and conversion out of blockdev_mirror_common() into its callers. I'm going to lift it further until it falls off the top. Signed-off-by: Markus Armbruster <[email protected]> --- blockdev.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/blockdev.c b/blockdev.c index 06f87e3..13df88b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3419,7 +3419,7 @@ static void blockdev_mirror_common(const char *job_id, BlockDriverState *bs, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, BlockMirrorBackingMode backing_mode, - bool has_speed, int64_t speed, + bool has_speed, uint64_t speed, bool has_granularity, uint64_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, @@ -3454,11 +3454,6 @@ 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]"); @@ -3508,6 +3503,12 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) return; } + if (arg->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -3667,6 +3668,12 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id, return; } + if (speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return; + } + aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); -- 2.7.5
