yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

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