mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
block: add block_job_sleep_ns
This function abstracts the pretty complex semantics of the "busy" member of BlockJob. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
0ac9377d04
commit
4513eafe92
3 changed files with 35 additions and 21 deletions
11
block.c
11
block.c
|
@ -4188,6 +4188,7 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,
|
|||
job->bs = bs;
|
||||
job->cb = cb;
|
||||
job->opaque = opaque;
|
||||
job->busy = true;
|
||||
bs->job = job;
|
||||
|
||||
/* Only set speed when necessary to avoid NotSupported error */
|
||||
|
@ -4254,3 +4255,13 @@ void block_job_cancel_sync(BlockJob *job)
|
|||
qemu_aio_wait();
|
||||
}
|
||||
}
|
||||
|
||||
void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns)
|
||||
{
|
||||
/* Check cancellation *before* setting busy = false, too! */
|
||||
if (!block_job_is_cancelled(job)) {
|
||||
job->busy = false;
|
||||
co_sleep_ns(clock, ns);
|
||||
job->busy = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue