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

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