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

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