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

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