thebeanogamer / rpms / qemu-kvm

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