mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00
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 <vsementsov@virtuozzo.com> Reviewed-by: Max Reitz <mreitz@redhat.com> Message-Id: <20210116214705.822267-9-vsementsov@virtuozzo.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
a6d23d56df
commit
e0323a045f
2 changed files with 8 additions and 0 deletions
|
@ -256,6 +256,7 @@ static bool job_timer_pending(Job *job)
|
||||||
|
|
||||||
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
||||||
{
|
{
|
||||||
|
const BlockJobDriver *drv = block_job_driver(job);
|
||||||
int64_t old_speed = job->speed;
|
int64_t old_speed = job->speed;
|
||||||
|
|
||||||
if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp)) {
|
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)
|
||||||
ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME);
|
ratelimit_set_speed(&job->limit, speed, BLOCK_JOB_SLICE_TIME);
|
||||||
|
|
||||||
job->speed = speed;
|
job->speed = speed;
|
||||||
|
|
||||||
|
if (drv->set_speed) {
|
||||||
|
drv->set_speed(job, speed);
|
||||||
|
}
|
||||||
|
|
||||||
if (speed && speed <= old_speed) {
|
if (speed && speed <= old_speed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,8 @@ struct BlockJobDriver {
|
||||||
* besides job->blk to the new AioContext.
|
* besides job->blk to the new AioContext.
|
||||||
*/
|
*/
|
||||||
void (*attached_aio_context)(BlockJob *job, AioContext *new_context);
|
void (*attached_aio_context)(BlockJob *job, AioContext *new_context);
|
||||||
|
|
||||||
|
void (*set_speed)(BlockJob *job, int64_t speed);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue