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