thebeanogamer / rpms / qemu-kvm

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