|
|
26ba25 |
From ba435686f6f81197fe01a47ee8962b5ea60fce6c Mon Sep 17 00:00:00 2001
|
|
|
26ba25 |
From: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
Date: Tue, 25 Sep 2018 22:34:15 +0100
|
|
|
26ba25 |
Subject: [PATCH 12/28] jobs: remove job_defer_to_main_loop
|
|
|
26ba25 |
|
|
|
26ba25 |
RH-Author: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
Message-id: <20180925223431.24791-10-jsnow@redhat.com>
|
|
|
26ba25 |
Patchwork-id: 82275
|
|
|
26ba25 |
O-Subject: [RHEL8/rhel qemu-kvm PATCH 09/25] jobs: remove job_defer_to_main_loop
|
|
|
26ba25 |
Bugzilla: 1632939
|
|
|
26ba25 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
26ba25 |
|
|
|
26ba25 |
Now that the job infrastructure is handling the job_completed call for
|
|
|
26ba25 |
all implemented jobs, we can remove the interface that allowed jobs to
|
|
|
26ba25 |
schedule their own completion.
|
|
|
26ba25 |
|
|
|
26ba25 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
Reviewed-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
Message-id: 20180830015734.19765-10-jsnow@redhat.com
|
|
|
26ba25 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
26ba25 |
(cherry picked from commit e21a1c9831fc80ae3f3c1affdfa43350035d8588)
|
|
|
26ba25 |
Signed-off-by: John Snow <jsnow@redhat.com>
|
|
|
26ba25 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
26ba25 |
---
|
|
|
26ba25 |
include/qemu/job.h | 17 -----------------
|
|
|
26ba25 |
job.c | 40 ++--------------------------------------
|
|
|
26ba25 |
2 files changed, 2 insertions(+), 55 deletions(-)
|
|
|
26ba25 |
|
|
|
26ba25 |
diff --git a/include/qemu/job.h b/include/qemu/job.h
|
|
|
26ba25 |
index 952ac3a..04090ba 100644
|
|
|
26ba25 |
--- a/include/qemu/job.h
|
|
|
26ba25 |
+++ b/include/qemu/job.h
|
|
|
26ba25 |
@@ -553,23 +553,6 @@ void job_finalize(Job *job, Error **errp);
|
|
|
26ba25 |
*/
|
|
|
26ba25 |
void job_dismiss(Job **job, Error **errp);
|
|
|
26ba25 |
|
|
|
26ba25 |
-typedef void JobDeferToMainLoopFn(Job *job, void *opaque);
|
|
|
26ba25 |
-
|
|
|
26ba25 |
-/**
|
|
|
26ba25 |
- * @job: The job
|
|
|
26ba25 |
- * @fn: The function to run in the main loop
|
|
|
26ba25 |
- * @opaque: The opaque value that is passed to @fn
|
|
|
26ba25 |
- *
|
|
|
26ba25 |
- * This function must be called by the main job coroutine just before it
|
|
|
26ba25 |
- * returns. @fn is executed in the main loop with the job AioContext acquired.
|
|
|
26ba25 |
- *
|
|
|
26ba25 |
- * Block jobs must call bdrv_unref(), bdrv_close(), and anything that uses
|
|
|
26ba25 |
- * bdrv_drain_all() in the main loop.
|
|
|
26ba25 |
- *
|
|
|
26ba25 |
- * The @job AioContext is held while @fn executes.
|
|
|
26ba25 |
- */
|
|
|
26ba25 |
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque);
|
|
|
26ba25 |
-
|
|
|
26ba25 |
/**
|
|
|
26ba25 |
* Synchronously finishes the given @job. If @finish is given, it is called to
|
|
|
26ba25 |
* trigger completion or cancellation of the job.
|
|
|
26ba25 |
diff --git a/job.c b/job.c
|
|
|
26ba25 |
index e935a36..edcae98 100644
|
|
|
26ba25 |
--- a/job.c
|
|
|
26ba25 |
+++ b/job.c
|
|
|
26ba25 |
@@ -556,12 +556,8 @@ static void coroutine_fn job_co_entry(void *opaque)
|
|
|
26ba25 |
assert(job && job->driver && job->driver->run);
|
|
|
26ba25 |
job_pause_point(job);
|
|
|
26ba25 |
job->ret = job->driver->run(job, &job->err);
|
|
|
26ba25 |
- if (!job->deferred_to_main_loop) {
|
|
|
26ba25 |
- job->deferred_to_main_loop = true;
|
|
|
26ba25 |
- aio_bh_schedule_oneshot(qemu_get_aio_context(),
|
|
|
26ba25 |
- job_exit,
|
|
|
26ba25 |
- job);
|
|
|
26ba25 |
- }
|
|
|
26ba25 |
+ job->deferred_to_main_loop = true;
|
|
|
26ba25 |
+ aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
|
|
|
26ba25 |
@@ -964,38 +960,6 @@ void job_complete(Job *job, Error **errp)
|
|
|
26ba25 |
job->driver->complete(job, errp);
|
|
|
26ba25 |
}
|
|
|
26ba25 |
|
|
|
26ba25 |
-
|
|
|
26ba25 |
-typedef struct {
|
|
|
26ba25 |
- Job *job;
|
|
|
26ba25 |
- JobDeferToMainLoopFn *fn;
|
|
|
26ba25 |
- void *opaque;
|
|
|
26ba25 |
-} JobDeferToMainLoopData;
|
|
|
26ba25 |
-
|
|
|
26ba25 |
-static void job_defer_to_main_loop_bh(void *opaque)
|
|
|
26ba25 |
-{
|
|
|
26ba25 |
- JobDeferToMainLoopData *data = opaque;
|
|
|
26ba25 |
- Job *job = data->job;
|
|
|
26ba25 |
- AioContext *aio_context = job->aio_context;
|
|
|
26ba25 |
-
|
|
|
26ba25 |
- aio_context_acquire(aio_context);
|
|
|
26ba25 |
- data->fn(data->job, data->opaque);
|
|
|
26ba25 |
- aio_context_release(aio_context);
|
|
|
26ba25 |
-
|
|
|
26ba25 |
- g_free(data);
|
|
|
26ba25 |
-}
|
|
|
26ba25 |
-
|
|
|
26ba25 |
-void job_defer_to_main_loop(Job *job, JobDeferToMainLoopFn *fn, void *opaque)
|
|
|
26ba25 |
-{
|
|
|
26ba25 |
- JobDeferToMainLoopData *data = g_malloc(sizeof(*data));
|
|
|
26ba25 |
- data->job = job;
|
|
|
26ba25 |
- data->fn = fn;
|
|
|
26ba25 |
- data->opaque = opaque;
|
|
|
26ba25 |
- job->deferred_to_main_loop = true;
|
|
|
26ba25 |
-
|
|
|
26ba25 |
- aio_bh_schedule_oneshot(qemu_get_aio_context(),
|
|
|
26ba25 |
- job_defer_to_main_loop_bh, data);
|
|
|
26ba25 |
-}
|
|
|
26ba25 |
-
|
|
|
26ba25 |
int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp)
|
|
|
26ba25 |
{
|
|
|
26ba25 |
Error *local_err = NULL;
|
|
|
26ba25 |
--
|
|
|
26ba25 |
1.8.3.1
|
|
|
26ba25 |
|