aboutsummaryrefslogtreecommitdiff
path: root/block_int.h
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_int.h
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_int.h')
-rw-r--r--block_int.h22
1 files changed, 15 insertions, 7 deletions
diff --git a/block_int.h b/block_int.h
index fbbc7aeb1a..3bf23670b7 100644
--- a/block_int.h
+++ b/block_int.h
@@ -97,18 +97,15 @@ struct BlockJob {
/**
* Set to true if the job should cancel itself. The flag must
* always be tested just before toggling the busy flag from false
- * to true. After a job has detected that the cancelled flag is
- * true, it should not anymore issue any I/O operation to the
- * block device.
+ * to true. After a job has been cancelled, it should only yield
+ * if #qemu_aio_wait will ("sooner or later") reenter the coroutine.
*/
bool cancelled;
/**
* Set to false by the job while it is in a quiescent state, where
- * no I/O is pending and cancellation can be processed without
- * issuing new I/O. The busy flag must be set to false when the
- * job goes to sleep on any condition that is not detected by
- * #qemu_aio_wait, such as a timer.
+ * no I/O is pending and the job has yielded on any condition
+ * that is not detected by #qemu_aio_wait, such as a timer.
*/
bool busy;
@@ -364,6 +361,17 @@ void *block_job_create(const BlockJobType *job_type, BlockDriverState *bs,
void *opaque, Error **errp);
/**
+ * block_job_sleep_ns:
+ * @job: The job that calls the function.
+ * @clock: The clock to sleep on.
+ * @ns: How many nanoseconds to stop for.
+ *
+ * Put the job to sleep (assuming that it wasn't canceled) for @ns
+ * nanoseconds. Canceling the job will interrupt the wait immediately.
+ */
+void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns);
+
+/**
* block_job_complete:
* @job: The job being completed.
* @ret: The status code.