aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-05-08 16:51:45 +0200
committerKevin Wolf <kwolf@redhat.com>2012-05-10 10:32:12 +0200
commit4513eafe928ff47486f4167c28d364c72b5ff7e3 (patch)
tree8976dece72550042799603af6c51c8835fcf0087 /block.c
parent0ac9377d043e03350b1ff8e21b927598c02fc7fb (diff)
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>
Diffstat (limited to 'block.c')
-rw-r--r--block.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/block.c b/block.c
index 6154c3fec0..f9a11aa7a5 100644
--- a/block.c
+++ b/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;
+ }
+}