|
|
9ae3a8 |
From 96f8c9bed66c9c910332d86368b7e0e94c190f62 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 20 Aug 2014 16:40:09 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 06/11] blockjob: Add block_job_yield()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1408552814-23031-3-git-send-email-eblake@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 60644
|
|
|
9ae3a8 |
O-Subject: [qemu-kvm-rhev 7.0.z PATCH 2/7] blockjob: Add block_job_yield()
|
|
|
9ae3a8 |
Bugzilla: 1130603
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
This will unset busy flag and put coroutine to sleep, can be used to
|
|
|
9ae3a8 |
wait for QMP complete/cancel.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit dc71ce45ded4e872e25c2de32d5e7a71842b0985)
|
|
|
9ae3a8 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
blockjob.c | 14 ++++++++++++++
|
|
|
9ae3a8 |
include/block/blockjob.h | 8 ++++++++
|
|
|
9ae3a8 |
2 files changed, 22 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/blockjob.c b/blockjob.c
|
|
|
9ae3a8 |
index a4430a0..1117ee7 100644
|
|
|
9ae3a8 |
--- a/blockjob.c
|
|
|
9ae3a8 |
+++ b/blockjob.c
|
|
|
9ae3a8 |
@@ -206,6 +206,20 @@ void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns)
|
|
|
9ae3a8 |
job->busy = true;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+void block_job_yield(BlockJob *job)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ assert(job->busy);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ /* Check cancellation *before* setting busy = false, too! */
|
|
|
9ae3a8 |
+ if (block_job_is_cancelled(job)) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ job->busy = false;
|
|
|
9ae3a8 |
+ qemu_coroutine_yield();
|
|
|
9ae3a8 |
+ job->busy = true;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
BlockJobInfo *block_job_query(BlockJob *job)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
BlockJobInfo *info = g_new0(BlockJobInfo, 1);
|
|
|
9ae3a8 |
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
|
|
|
9ae3a8 |
index 5a7d859..11f7c7e 100644
|
|
|
9ae3a8 |
--- a/include/block/blockjob.h
|
|
|
9ae3a8 |
+++ b/include/block/blockjob.h
|
|
|
9ae3a8 |
@@ -144,6 +144,14 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
|
|
|
9ae3a8 |
void block_job_sleep_ns(BlockJob *job, QEMUClock *clock, int64_t ns);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/**
|
|
|
9ae3a8 |
+ * block_job_yield:
|
|
|
9ae3a8 |
+ * @job: The job that calls the function.
|
|
|
9ae3a8 |
+ *
|
|
|
9ae3a8 |
+ * Yield the block job coroutine.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+void block_job_yield(BlockJob *job);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+/**
|
|
|
9ae3a8 |
* block_job_completed:
|
|
|
9ae3a8 |
* @job: The job being completed.
|
|
|
9ae3a8 |
* @ret: The status code.
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|