From nobody Sun Feb 8 06:18:00 2026 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 1525884289623764.9563226890782; Wed, 9 May 2018 09:44:49 -0700 (PDT) Received: from localhost ([::1]:57624 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGSCu-0006Xa-Q3 for importer@patchew.org; Wed, 09 May 2018 12:44:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGRwO-0005ek-PP for qemu-devel@nongnu.org; Wed, 09 May 2018 12:27:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGRwN-0002L2-Gb for qemu-devel@nongnu.org; Wed, 09 May 2018 12:27:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33490 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 1fGRwK-0002D2-Qg; Wed, 09 May 2018 12:27:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C483406F88F; Wed, 9 May 2018 16:27:40 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-193.ams2.redhat.com [10.36.117.193]) by smtp.corp.redhat.com (Postfix) with ESMTP id F10022023433; Wed, 9 May 2018 16:27:38 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 9 May 2018 18:26:18 +0200 Message-Id: <20180509162637.15575-24-kwolf@redhat.com> In-Reply-To: <20180509162637.15575-1-kwolf@redhat.com> References: <20180509162637.15575-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 09 May 2018 16:27:40 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 09 May 2018 16:27:40 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kwolf@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 23/42] blockjob: Split block_job_event_pending() 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: kwolf@redhat.com, qemu-devel@nongnu.org, jcody@redhat.com, armbru@redhat.com, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" block_job_event_pending() doesn't only send a QMP event, but it also transitions to the PENDING state. Split the function so that we get one part only sending the event (like other block_job_event_* functions) and another part than does the state transition. Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- blockjob.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/blockjob.c b/blockjob.c index 4cfedbe791..de9a789e29 100644 --- a/blockjob.c +++ b/blockjob.c @@ -38,7 +38,7 @@ =20 static void block_job_event_cancelled(BlockJob *job); static void block_job_event_completed(BlockJob *job, const char *msg); -static int block_job_event_pending(BlockJob *job); +static void block_job_event_pending(BlockJob *job); =20 /* Transactional group of block jobs */ struct BlockJobTxn { @@ -501,6 +501,15 @@ static void block_job_do_finalize(BlockJob *job) } } =20 +static int block_job_transition_to_pending(BlockJob *job) +{ + job_state_transition(&job->job, JOB_STATUS_PENDING); + if (!job->job.auto_finalize) { + block_job_event_pending(job); + } + return 0; +} + static void block_job_completed_txn_success(BlockJob *job) { BlockJobTxn *txn =3D job->txn; @@ -519,7 +528,7 @@ static void block_job_completed_txn_success(BlockJob *j= ob) assert(other_job->ret =3D=3D 0); } =20 - block_job_txn_apply(txn, block_job_event_pending, false); + block_job_txn_apply(txn, block_job_transition_to_pending, false); =20 /* If no jobs need manual finalization, automatically do so */ if (block_job_txn_apply(txn, block_job_needs_finalize, false) =3D=3D 0= ) { @@ -734,15 +743,15 @@ static void block_job_event_completed(BlockJob *job, = const char *msg) &error_abort); } =20 -static int block_job_event_pending(BlockJob *job) +static void block_job_event_pending(BlockJob *job) { - job_state_transition(&job->job, JOB_STATUS_PENDING); - if (!job->job.auto_finalize && !block_job_is_internal(job)) { - qapi_event_send_block_job_pending(job_type(&job->job), - job->job.id, - &error_abort); + if (block_job_is_internal(job)) { + return; } - return 0; + + qapi_event_send_block_job_pending(job_type(&job->job), + job->job.id, + &error_abort); } =20 /* --=20 2.13.6