Blame SOURCES/kvm-jobs-remove-ret-argument-to-job_completed-privatize-.patch

383d26
From 8a39bfe61aa3e30907f583f7f2e90e7d90004f56 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Mon, 10 Sep 2018 18:17:46 +0200
383d26
Subject: [PATCH 08/25] jobs: remove ret argument to job_completed; privatize
383d26
 it
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20180910181803.11781-9-jsnow@redhat.com>
383d26
Patchwork-id: 82095
383d26
O-Subject: [RHEL-7.6 qemu-kvm-rhev PATCH 08/25] jobs: remove ret argument to job_completed; privatize it
383d26
Bugzilla: 1626061
383d26
RH-Acked-by: Max Reitz <mreitz@redhat.com>
383d26
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
383d26
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
383d26
383d26
Jobs are now expected to return their retcode on the stack, from the
383d26
.run callback, so we can remove that argument.
383d26
383d26
job_cancel does not need to set -ECANCELED because job_completed will
383d26
update the return code itself if the job was canceled.
383d26
383d26
While we're here, make job_completed static to job.c and remove it from
383d26
job.h; move the documentation of return code to the .run() callback and
383d26
to the job->ret property, accordingly.
383d26
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Message-id: 20180830015734.19765-9-jsnow@redhat.com
383d26
Reviewed-by: Max Reitz <mreitz@redhat.com>
383d26
Signed-off-by: Max Reitz <mreitz@redhat.com>
383d26
(cherry picked from commit 404ff28d6ae59fc1c24d631710d4063fc68aed03)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 include/qemu/job.h | 28 +++++++++++++++-------------
383d26
 job.c              | 11 ++++++-----
383d26
 trace-events       |  2 +-
383d26
 3 files changed, 22 insertions(+), 19 deletions(-)
383d26
383d26
diff --git a/include/qemu/job.h b/include/qemu/job.h
383d26
index 24b5f3f..952ac3a 100644
383d26
--- a/include/qemu/job.h
383d26
+++ b/include/qemu/job.h
383d26
@@ -124,7 +124,11 @@ typedef struct Job {
383d26
     /** Estimated progress_current value at the completion of the job */
383d26
     int64_t progress_total;
383d26
 
383d26
-    /** ret code passed to job_completed. */
383d26
+    /**
383d26
+     * Return code from @run and/or @prepare callback(s).
383d26
+     * Not final until the job has reached the CONCLUDED status.
383d26
+     * 0 on success, -errno on failure.
383d26
+     */
383d26
     int ret;
383d26
 
383d26
     /**
383d26
@@ -172,7 +176,16 @@ struct JobDriver {
383d26
     /** Enum describing the operation */
383d26
     JobType job_type;
383d26
 
383d26
-    /** Mandatory: Entrypoint for the Coroutine. */
383d26
+    /**
383d26
+     * Mandatory: Entrypoint for the Coroutine.
383d26
+     *
383d26
+     * This callback will be invoked when moving from CREATED to RUNNING.
383d26
+     *
383d26
+     * If this callback returns nonzero, the job transaction it is part of is
383d26
+     * aborted. If it returns zero, the job moves into the WAITING state. If it
383d26
+     * is the last job to complete in its transaction, all jobs in the
383d26
+     * transaction move from WAITING to PENDING.
383d26
+     */
383d26
     int coroutine_fn (*run)(Job *job, Error **errp);
383d26
 
383d26
     /**
383d26
@@ -481,17 +494,6 @@ void job_early_fail(Job *job);
383d26
 /** Moves the @job from RUNNING to READY */
383d26
 void job_transition_to_ready(Job *job);
383d26
 
383d26
-/**
383d26
- * @job: The job being completed.
383d26
- * @ret: The status code.
383d26
- *
383d26
- * Marks @job as completed. If @ret is non-zero, the job transaction it is part
383d26
- * of is aborted. If @ret is zero, the job moves into the WAITING state. If it
383d26
- * is the last job to complete in its transaction, all jobs in the transaction
383d26
- * move from WAITING to PENDING.
383d26
- */
383d26
-void job_completed(Job *job, int ret);
383d26
-
383d26
 /** Asynchronously complete the specified @job. */
383d26
 void job_complete(Job *job, Error **errp);
383d26
 
383d26
diff --git a/job.c b/job.c
383d26
index a814857..1acbcbc 100644
383d26
--- a/job.c
383d26
+++ b/job.c
383d26
@@ -530,6 +530,8 @@ void job_drain(Job *job)
383d26
     }
383d26
 }
383d26
 
383d26
+static void job_completed(Job *job);
383d26
+
383d26
 static void job_exit(void *opaque)
383d26
 {
383d26
     Job *job = (Job *)opaque;
383d26
@@ -540,7 +542,7 @@ static void job_exit(void *opaque)
383d26
         job->driver->exit(job);
383d26
         aio_context_release(aio_context);
383d26
     }
383d26
-    job_completed(job, job->ret);
383d26
+    job_completed(job);
383d26
 }
383d26
 
383d26
 /**
383d26
@@ -878,13 +880,12 @@ static void job_completed_txn_success(Job *job)
383d26
     }
383d26
 }
383d26
 
383d26
-void job_completed(Job *job, int ret)
383d26
+static void job_completed(Job *job)
383d26
 {
383d26
     assert(job && job->txn && !job_is_completed(job));
383d26
 
383d26
-    job->ret = ret;
383d26
     job_update_rc(job);
383d26
-    trace_job_completed(job, ret, job->ret);
383d26
+    trace_job_completed(job, job->ret);
383d26
     if (job->ret) {
383d26
         job_completed_txn_abort(job);
383d26
     } else {
383d26
@@ -900,7 +901,7 @@ void job_cancel(Job *job, bool force)
383d26
     }
383d26
     job_cancel_async(job, force);
383d26
     if (!job_started(job)) {
383d26
-        job_completed(job, -ECANCELED);
383d26
+        job_completed(job);
383d26
     } else if (job->deferred_to_main_loop) {
383d26
         job_completed_txn_abort(job);
383d26
     } else {
383d26
diff --git a/trace-events b/trace-events
383d26
index c445f54..4fd2cb4 100644
383d26
--- a/trace-events
383d26
+++ b/trace-events
383d26
@@ -107,7 +107,7 @@ gdbstub_err_checksum_incorrect(uint8_t expected, uint8_t got) "got command packe
383d26
 # job.c
383d26
 job_state_transition(void *job,  int ret, const char *legal, const char *s0, const char *s1) "job %p (ret: %d) attempting %s transition (%s-->%s)"
383d26
 job_apply_verb(void *job, const char *state, const char *verb, const char *legal) "job %p in state %s; applying verb %s (%s)"
383d26
-job_completed(void *job, int ret, int jret) "job %p ret %d corrected ret %d"
383d26
+job_completed(void *job, int ret) "job %p ret %d"
383d26
 
383d26
 # job-qmp.c
383d26
 qmp_job_cancel(void *job) "job %p"
383d26
-- 
383d26
1.8.3.1
383d26