Skip to content

Commit e0323a0

Browse files
Vladimir Sementsov-OgievskiyXanClic
authored andcommitted
blockjob: add set_speed to BlockJobDriver
We are going to use async block-copy call in backup, so we'll need to passthrough setting backup speed to block-copy call. Signed-off-by: Vladimir Sementsov-Ogievskiy <[email protected]> Reviewed-by: Max Reitz <[email protected]> Message-Id: <[email protected]> Signed-off-by: Max Reitz <[email protected]>
1 parent a6d23d5 commit e0323a0

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

blockjob.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ static bool job_timer_pending(Job *job)
256256

257257
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
258258
{
259+
const BlockJobDriver *drv = block_job_driver(job);
259260
int64_t old_speed = job->speed;
260261

261262
if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) {
@@ -270,6 +271,11 @@ void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
270271
ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME);
271272

272273
job->speed = speed;
274+
275+
if (drv->set_speed) {
276+
drv->set_speed(job, speed);
277+
}
278+
273279
if (speed && speed <= old_speed) {
274280
return;
275281
}

include/block/blockjob_int.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ struct BlockJobDriver {
5252
* besides job->blk to the new AioContext.
5353
*/
5454
void (*attached_aio_context)(BlockJob *job, AioContext *new_context);
55+
56+
void (*set_speed)(BlockJob *job, int64_t speed);
5557
};
5658

5759
/**

0 commit comments

Comments
 (0)