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

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