From nobody Tue Apr 8 17:32:28 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535726166740532.5833412265866; Fri, 31 Aug 2018 07:36:06 -0700 (PDT) Received: from localhost ([::1]:53992 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvkWr-0007HA-IW for importer@patchew.org; Fri, 31 Aug 2018 10:36:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50527) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fvkQN-00014U-6H for qemu-devel@nongnu.org; Fri, 31 Aug 2018 10:29:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fvkMN-0000sE-FU for qemu-devel@nongnu.org; Fri, 31 Aug 2018 10:25:16 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50298 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fvkML-0000qw-M7; Fri, 31 Aug 2018 10:25:13 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8690D8077102; Fri, 31 Aug 2018 14:25:12 +0000 (UTC) Received: from localhost (ovpn-117-235.ams2.redhat.com [10.36.117.235]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 182372166B41; Fri, 31 Aug 2018 14:25:11 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 31 Aug 2018 16:24:45 +0200 Message-Id: <20180831142446.22264-11-mreitz@redhat.com> In-Reply-To: <20180831142446.22264-1-mreitz@redhat.com> References: <20180831142446.22264-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 31 Aug 2018 14:25:12 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 31 Aug 2018 14:25:12 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 10/11] jobs: remove ret argument to job_completed; privatize it X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Snow Jobs are now expected to return their retcode on the stack, from the .run callback, so we can remove that argument. job_cancel does not need to set -ECANCELED because job_completed will update the return code itself if the job was canceled. While we're here, make job_completed static to job.c and remove it from job.h; move the documentation of return code to the .run() callback and to the job->ret property, accordingly. Signed-off-by: John Snow Message-id: 20180830015734.19765-9-jsnow@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz --- include/qemu/job.h | 28 +++++++++++++++------------- job.c | 11 ++++++----- trace-events | 2 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 1144d671a1..23395c17fa 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -124,7 +124,11 @@ typedef struct Job { /** Estimated progress_current value at the completion of the job */ int64_t progress_total; =20 - /** ret code passed to job_completed. */ + /** + * Return code from @run and/or @prepare callback(s). + * Not final until the job has reached the CONCLUDED status. + * 0 on success, -errno on failure. + */ int ret; =20 /** @@ -172,7 +176,16 @@ struct JobDriver { /** Enum describing the operation */ JobType job_type; =20 - /** Mandatory: Entrypoint for the Coroutine. */ + /** + * Mandatory: Entrypoint for the Coroutine. + * + * This callback will be invoked when moving from CREATED to RUNNING. + * + * If this callback returns nonzero, the job transaction it is part of= is + * aborted. If it returns zero, the job moves into the WAITING state. = If it + * is the last job to complete in its transaction, all jobs in the + * transaction move from WAITING to PENDING. + */ int coroutine_fn (*run)(Job *job, Error **errp); =20 /** @@ -496,17 +509,6 @@ void job_early_fail(Job *job); /** Moves the @job from RUNNING to READY */ void job_transition_to_ready(Job *job); =20 -/** - * @job: The job being completed. - * @ret: The status code. - * - * Marks @job as completed. If @ret is non-zero, the job transaction it is= part - * of is aborted. If @ret is zero, the job moves into the WAITING state. I= f it - * is the last job to complete in its transaction, all jobs in the transac= tion - * move from WAITING to PENDING. - */ -void job_completed(Job *job, int ret); - /** Asynchronously complete the specified @job. */ void job_complete(Job *job, Error **errp); =20 diff --git a/job.c b/job.c index 5df7791ad8..37d828f964 100644 --- a/job.c +++ b/job.c @@ -535,6 +535,8 @@ void job_drain(Job *job) } } =20 +static void job_completed(Job *job); + static void job_exit(void *opaque) { Job *job =3D (Job *)opaque; @@ -545,7 +547,7 @@ static void job_exit(void *opaque) job->driver->exit(job); aio_context_release(aio_context); } - job_completed(job, job->ret); + job_completed(job); } =20 /** @@ -883,13 +885,12 @@ static void job_completed_txn_success(Job *job) } } =20 -void job_completed(Job *job, int ret) +static void job_completed(Job *job) { assert(job && job->txn && !job_is_completed(job)); =20 - job->ret =3D ret; job_update_rc(job); - trace_job_completed(job, ret, job->ret); + trace_job_completed(job, job->ret); if (job->ret) { job_completed_txn_abort(job); } else { @@ -905,7 +906,7 @@ void job_cancel(Job *job, bool force) } job_cancel_async(job, force); if (!job_started(job)) { - job_completed(job, -ECANCELED); + job_completed(job); } else if (job->deferred_to_main_loop) { job_completed_txn_abort(job); } else { diff --git a/trace-events b/trace-events index c445f54773..4fd2cb4b97 100644 --- a/trace-events +++ b/trace-events @@ -107,7 +107,7 @@ gdbstub_err_checksum_incorrect(uint8_t expected, uint8_= t got) "got command packe # job.c job_state_transition(void *job, int ret, const char *legal, const char *s= 0, const char *s1) "job %p (ret: %d) attempting %s transition (%s-->%s)" job_apply_verb(void *job, const char *state, const char *verb, const char = *legal) "job %p in state %s; applying verb %s (%s)" -job_completed(void *job, int ret, int jret) "job %p ret %d corrected ret %= d" +job_completed(void *job, int ret) "job %p ret %d" =20 # job-qmp.c qmp_job_cancel(void *job) "job %p" --=20 2.17.1