Blame SOURCES/kvm-jobs-remove-.exit-callback.patch

357786
From 583fce2c4839f5b0f3da8794182cc7738311a991 Mon Sep 17 00:00:00 2001
357786
From: John Snow <jsnow@redhat.com>
357786
Date: Mon, 10 Sep 2018 18:17:58 +0200
357786
Subject: [PATCH 20/25] jobs: remove .exit callback
357786
357786
RH-Author: John Snow <jsnow@redhat.com>
357786
Message-id: <20180910181803.11781-21-jsnow@redhat.com>
357786
Patchwork-id: 82101
357786
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 20/25] jobs: remove .exit callback
357786
Bugzilla: 1626061
357786
RH-Acked-by: Max Reitz <mreitz@redhat.com>
357786
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
357786
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
357786
357786
Now that all of the jobs use the component finalization callbacks,
357786
there's no use for the heavy-hammer .exit callback anymore.
357786
357786
job_exit becomes a glorified type shim so that we can call
357786
job_completed from aio_bh_schedule_oneshot.
357786
357786
Move these three functions down into job.c to eliminate a
357786
forward reference.
357786
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Reviewed-by: Max Reitz <mreitz@redhat.com>
357786
Message-id: 20180906130225.5118-12-jsnow@redhat.com
357786
Reviewed-by: Jeff Cody <jcody@redhat.com>
357786
Signed-off-by: Max Reitz <mreitz@redhat.com>
357786
(cherry picked from commit 7e9e7780ef18e902a6458dfa6b024d9e2053923c)
357786
Signed-off-by: John Snow <jsnow@redhat.com>
357786
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
357786
---
357786
 include/qemu/job.h | 11 --------
357786
 job.c              | 77 ++++++++++++++++++++++++------------------------------
357786
 2 files changed, 34 insertions(+), 54 deletions(-)
357786
357786
diff --git a/include/qemu/job.h b/include/qemu/job.h
357786
index 04090ba..fdaa06f 100644
357786
--- a/include/qemu/job.h
357786
+++ b/include/qemu/job.h
357786
@@ -222,17 +222,6 @@ struct JobDriver {
357786
     void (*drain)(Job *job);
357786
 
357786
     /**
357786
-     * If the callback is not NULL, exit will be invoked from the main thread
357786
-     * when the job's coroutine has finished, but before transactional
357786
-     * convergence; before @prepare or @abort.
357786
-     *
357786
-     * FIXME TODO: This callback is only temporary to transition remaining jobs
357786
-     * to prepare/commit/abort/clean callbacks and will be removed before 3.1.
357786
-     * is released.
357786
-     */
357786
-    void (*exit)(Job *job);
357786
-
357786
-    /**
357786
      * If the callback is not NULL, prepare will be invoked when all the jobs
357786
      * belonging to the same transaction complete; or upon this job's completion
357786
      * if it is not in a transaction.
357786
diff --git a/job.c b/job.c
357786
index f56e6a3..dfba4bc 100644
357786
--- a/job.c
357786
+++ b/job.c
357786
@@ -530,49 +530,6 @@ void job_drain(Job *job)
357786
     }
357786
 }
357786
 
357786
-static void job_completed(Job *job);
357786
-
357786
-static void job_exit(void *opaque)
357786
-{
357786
-    Job *job = (Job *)opaque;
357786
-    AioContext *aio_context = job->aio_context;
357786
-
357786
-    if (job->driver->exit) {
357786
-        aio_context_acquire(aio_context);
357786
-        job->driver->exit(job);
357786
-        aio_context_release(aio_context);
357786
-    }
357786
-    job_completed(job);
357786
-}
357786
-
357786
-/**
357786
- * All jobs must allow a pause point before entering their job proper. This
357786
- * ensures that jobs can be paused prior to being started, then resumed later.
357786
- */
357786
-static void coroutine_fn job_co_entry(void *opaque)
357786
-{
357786
-    Job *job = opaque;
357786
-
357786
-    assert(job && job->driver && job->driver->run);
357786
-    job_pause_point(job);
357786
-    job->ret = job->driver->run(job, &job->err);
357786
-    job->deferred_to_main_loop = true;
357786
-    aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
357786
-}
357786
-
357786
-
357786
-void job_start(Job *job)
357786
-{
357786
-    assert(job && !job_started(job) && job->paused &&
357786
-           job->driver && job->driver->run);
357786
-    job->co = qemu_coroutine_create(job_co_entry, job);
357786
-    job->pause_count--;
357786
-    job->busy = true;
357786
-    job->paused = false;
357786
-    job_state_transition(job, JOB_STATUS_RUNNING);
357786
-    aio_co_enter(job->aio_context, job->co);
357786
-}
357786
-
357786
 /* Assumes the block_job_mutex is held */
357786
 static bool job_timer_not_pending(Job *job)
357786
 {
357786
@@ -889,6 +846,40 @@ static void job_completed(Job *job)
357786
     }
357786
 }
357786
 
357786
+/** Useful only as a type shim for aio_bh_schedule_oneshot. */
357786
+static void job_exit(void *opaque)
357786
+{
357786
+    Job *job = (Job *)opaque;
357786
+    job_completed(job);
357786
+}
357786
+
357786
+/**
357786
+ * All jobs must allow a pause point before entering their job proper. This
357786
+ * ensures that jobs can be paused prior to being started, then resumed later.
357786
+ */
357786
+static void coroutine_fn job_co_entry(void *opaque)
357786
+{
357786
+    Job *job = opaque;
357786
+
357786
+    assert(job && job->driver && job->driver->run);
357786
+    job_pause_point(job);
357786
+    job->ret = job->driver->run(job, &job->err);
357786
+    job->deferred_to_main_loop = true;
357786
+    aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job);
357786
+}
357786
+
357786
+void job_start(Job *job)
357786
+{
357786
+    assert(job && !job_started(job) && job->paused &&
357786
+           job->driver && job->driver->run);
357786
+    job->co = qemu_coroutine_create(job_co_entry, job);
357786
+    job->pause_count--;
357786
+    job->busy = true;
357786
+    job->paused = false;
357786
+    job_state_transition(job, JOB_STATUS_RUNNING);
357786
+    aio_co_enter(job->aio_context, job->co);
357786
+}
357786
+
357786
 void job_cancel(Job *job, bool force)
357786
 {
357786
     if (job->status == JOB_STATUS_CONCLUDED) {
357786
-- 
357786
1.8.3.1
357786