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