|
|
383d26 |
From db5e1dfac375e869234340036cd232313c6d4d7b Mon Sep 17 00:00:00 2001
|
|
|
383d26 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Date: Fri, 14 Sep 2018 10:55:28 +0200
|
|
|
383d26 |
Subject: [PATCH 37/49] test-blockjob: Acquire AioContext around
|
|
|
383d26 |
job_cancel_sync()
|
|
|
383d26 |
|
|
|
383d26 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Message-id: <20180914105540.18077-31-kwolf@redhat.com>
|
|
|
383d26 |
Patchwork-id: 82183
|
|
|
383d26 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 30/42] test-blockjob: Acquire AioContext around job_cancel_sync()
|
|
|
383d26 |
Bugzilla: 1601212
|
|
|
383d26 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
383d26 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
|
|
|
383d26 |
All callers in QEMU proper hold the AioContext lock when calling
|
|
|
383d26 |
job_finish_sync(). test-blockjob should do the same when it calls the
|
|
|
383d26 |
function indirectly through job_cancel_sync().
|
|
|
383d26 |
|
|
|
383d26 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
383d26 |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
383d26 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
383d26 |
---
|
|
|
383d26 |
include/qemu/job.h | 6 ++++++
|
|
|
383d26 |
tests/test-blockjob.c | 6 ++++++
|
|
|
383d26 |
2 files changed, 12 insertions(+)
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
383d26 |
index 407d549..35ac7a9 100644
|
|
|
383d26 |
--- a/include/qemu/job.h
|
|
|
383d26 |
+++ b/include/qemu/job.h
|
|
|
383d26 |
@@ -509,6 +509,8 @@ void job_user_cancel(Job *job, bool force, Error **errp);
|
|
|
383d26 |
*
|
|
|
383d26 |
* Returns the return value from the job if the job actually completed
|
|
|
383d26 |
* during the call, or -ECANCELED if it was canceled.
|
|
|
383d26 |
+ *
|
|
|
383d26 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
383d26 |
*/
|
|
|
383d26 |
int job_cancel_sync(Job *job);
|
|
|
383d26 |
|
|
|
383d26 |
@@ -526,6 +528,8 @@ void job_cancel_sync_all(void);
|
|
|
383d26 |
* function).
|
|
|
383d26 |
*
|
|
|
383d26 |
* Returns the return value from the job.
|
|
|
383d26 |
+ *
|
|
|
383d26 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
383d26 |
*/
|
|
|
383d26 |
int job_complete_sync(Job *job, Error **errp);
|
|
|
383d26 |
|
|
|
383d26 |
@@ -551,6 +555,8 @@ void job_dismiss(Job **job, Error **errp);
|
|
|
383d26 |
*
|
|
|
383d26 |
* Returns 0 if the job is successfully completed, -ECANCELED if the job was
|
|
|
383d26 |
* cancelled before completing, and -errno in other error cases.
|
|
|
383d26 |
+ *
|
|
|
383d26 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
383d26 |
*/
|
|
|
383d26 |
int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp);
|
|
|
383d26 |
|
|
|
383d26 |
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
|
|
|
383d26 |
index de4c1c2..652d1e8 100644
|
|
|
383d26 |
--- a/tests/test-blockjob.c
|
|
|
383d26 |
+++ b/tests/test-blockjob.c
|
|
|
383d26 |
@@ -223,6 +223,10 @@ static void cancel_common(CancelJob *s)
|
|
|
383d26 |
BlockJob *job = &s->common;
|
|
|
383d26 |
BlockBackend *blk = s->blk;
|
|
|
383d26 |
JobStatus sts = job->job.status;
|
|
|
383d26 |
+ AioContext *ctx;
|
|
|
383d26 |
+
|
|
|
383d26 |
+ ctx = job->job.aio_context;
|
|
|
383d26 |
+ aio_context_acquire(ctx);
|
|
|
383d26 |
|
|
|
383d26 |
job_cancel_sync(&job->job);
|
|
|
383d26 |
if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) {
|
|
|
383d26 |
@@ -232,6 +236,8 @@ static void cancel_common(CancelJob *s)
|
|
|
383d26 |
assert(job->job.status == JOB_STATUS_NULL);
|
|
|
383d26 |
job_unref(&job->job);
|
|
|
383d26 |
destroy_blk(blk);
|
|
|
383d26 |
+
|
|
|
383d26 |
+ aio_context_release(ctx);
|
|
|
383d26 |
}
|
|
|
383d26 |
|
|
|
383d26 |
static void test_cancel_created(void)
|
|
|
383d26 |
--
|
|
|
383d26 |
1.8.3.1
|
|
|
383d26 |
|