If users set an unreasonably low speed (like one byte per second), the calculated delay may exceed many hours. While we like to punish users for asking for stupid things, we do also like to allow users to correct their wicked ways.
When a user provides a new speed, kick the job to allow it to recalculate its delay. Signed-off-by: John Snow <js...@redhat.com> --- blockjob.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/blockjob.c b/blockjob.c index 715c2c2680..43f01ad190 100644 --- a/blockjob.c +++ b/blockjob.c @@ -483,6 +483,7 @@ static void block_job_completed_txn_success(BlockJob *job) void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { Error *local_err = NULL; + int64_t old_speed = job->speed; if (!job->driver->set_speed) { error_setg(errp, QERR_UNSUPPORTED); @@ -495,6 +496,10 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) } job->speed = speed; + /* Kick the job to recompute its delay */ + if ((speed > old_speed) && timer_pending(&job->sleep_timer)) { + block_job_enter(job); + } } void block_job_complete(BlockJob *job, Error **errp) -- 2.14.3