|
|
26ba25 |
From 7d96749f6e1f97c41f37ad6ec2ff23eb3ae27c28 Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
Date: Wed, 10 Oct 2018 20:21:59 +0100
|
|
|
26ba25 |
Subject: [PATCH 33/49] test-blockjob: Acquire AioContext around
|
|
|
26ba25 |
job_cancel_sync()
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
Message-id: <20181010202213.7372-21-kwolf@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 82606
|
|
|
26ba25 |
O-Subject: [RHEL-8 qemu-kvm PATCH 30/44] test-blockjob: Acquire AioContext around job_cancel_sync()
|
|
|
26ba25 |
Bugzilla: 1637976
|
|
|
26ba25 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
All callers in QEMU proper hold the AioContext lock when calling
|
|
|
26ba25 |
job_finish_sync(). test-blockjob should do the same when it calls the
|
|
|
26ba25 |
function indirectly through job_cancel_sync().
|
|
|
26ba25 |
|
|
|
26ba25 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
26ba25 |
(cherry picked from commit 30c070a547322a5e41ce129d540bca3653b1a9c8)
|
|
|
26ba25 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
include/qemu/job.h | 6 ++++++
|
|
|
26ba25 |
tests/test-blockjob.c | 6 ++++++
|
|
|
26ba25 |
2 files changed, 12 insertions(+)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
26ba25 |
index 407d549..35ac7a9 100644
|
|
|
26ba25 |
--- a/include/qemu/job.h
|
|
|
26ba25 |
+++ b/include/qemu/job.h
|
|
|
26ba25 |
@@ -509,6 +509,8 @@ void job_user_cancel(Job *job, bool force, Error **errp);
|
|
|
26ba25 |
*
|
|
|
26ba25 |
* Returns the return value from the job if the job actually completed
|
|
|
26ba25 |
* during the call, or -ECANCELED if it was canceled.
|
|
|
26ba25 |
+ *
|
|
|
26ba25 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
26ba25 |
*/
|
|
|
26ba25 |
int job_cancel_sync(Job *job);
|
|
|
26ba25 |
|
|
|
26ba25 |
@@ -526,6 +528,8 @@ void job_cancel_sync_all(void);
|
|
|
26ba25 |
* function).
|
|
|
26ba25 |
*
|
|
|
26ba25 |
* Returns the return value from the job.
|
|
|
26ba25 |
+ *
|
|
|
26ba25 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
26ba25 |
*/
|
|
|
26ba25 |
int job_complete_sync(Job *job, Error **errp);
|
|
|
26ba25 |
|
|
|
26ba25 |
@@ -551,6 +555,8 @@ void job_dismiss(Job **job, Error **errp);
|
|
|
26ba25 |
*
|
|
|
26ba25 |
* Returns 0 if the job is successfully completed, -ECANCELED if the job was
|
|
|
26ba25 |
* cancelled before completing, and -errno in other error cases.
|
|
|
26ba25 |
+ *
|
|
|
26ba25 |
+ * Callers must hold the AioContext lock of job->aio_context.
|
|
|
26ba25 |
*/
|
|
|
26ba25 |
int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp);
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
|
|
|
26ba25 |
index de4c1c2..652d1e8 100644
|
|
|
26ba25 |
--- a/tests/test-blockjob.c
|
|
|
26ba25 |
+++ b/tests/test-blockjob.c
|
|
|
26ba25 |
@@ -223,6 +223,10 @@ static void cancel_common(CancelJob *s)
|
|
|
26ba25 |
BlockJob *job = &s->common;
|
|
|
26ba25 |
BlockBackend *blk = s->blk;
|
|
|
26ba25 |
JobStatus sts = job->job.status;
|
|
|
26ba25 |
+ AioContext *ctx;
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ ctx = job->job.aio_context;
|
|
|
26ba25 |
+ aio_context_acquire(ctx);
|
|
|
26ba25 |
|
|
|
26ba25 |
job_cancel_sync(&job->job);
|
|
|
26ba25 |
if (sts != JOB_STATUS_CREATED && sts != JOB_STATUS_CONCLUDED) {
|
|
|
26ba25 |
@@ -232,6 +236,8 @@ static void cancel_common(CancelJob *s)
|
|
|
26ba25 |
assert(job->job.status == JOB_STATUS_NULL);
|
|
|
26ba25 |
job_unref(&job->job);
|
|
|
26ba25 |
destroy_blk(blk);
|
|
|
26ba25 |
+
|
|
|
26ba25 |
+ aio_context_release(ctx);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
static void test_cancel_created(void)
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|