backup_job_create() takes int64_t speed. The underlying BlockJob abstraction takes uint64_t. backup_job_create() converts from int64_t to uint64_t, rejecting negative speed.
Lift this check and conversion out of backup_job_create() 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/backup.c | 7 +------ blockdev.c | 12 ++++++++++++ include/block/block_int.h | 2 +- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/block/backup.c b/block/backup.c index 3a97836..eddc17a 100644 --- a/block/backup.c +++ b/block/backup.c @@ -529,7 +529,7 @@ static const BlockJobDriver backup_job_driver = { }; BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, + BlockDriverState *target, uint64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, BlockdevOnError on_source_error, @@ -577,11 +577,6 @@ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, return NULL; } - if (speed < 0) { - error_setg(errp, QERR_INVALID_PARAMETER, "speed"); - return NULL; - } - if (sync_mode == MIRROR_SYNC_MODE_INCREMENTAL) { if (!sync_bitmap) { error_setg(errp, "must provide a valid bitmap name for " diff --git a/blockdev.c b/blockdev.c index f9afc32..1deea49 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3210,6 +3210,12 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, return NULL; } + if (backup->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return NULL; + } + aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); @@ -3353,6 +3359,12 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, BlockJobTxn *txn, return NULL; } + if (backup->speed < 0) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "speed", + "a non-negative rate limit"); + return NULL; + } + aio_context = bdrv_get_aio_context(bs); aio_context_acquire(aio_context); diff --git a/include/block/block_int.h b/include/block/block_int.h index c09076e..19639c0 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -923,7 +923,7 @@ void mirror_start(const char *job_id, BlockDriverState *bs, * until the job is cancelled or manually completed. */ BlockJob *backup_job_create(const char *job_id, BlockDriverState *bs, - BlockDriverState *target, int64_t speed, + BlockDriverState *target, uint64_t speed, MirrorSyncMode sync_mode, BdrvDirtyBitmap *sync_bitmap, bool compress, -- 2.7.5