From nobody Thu Dec 18 19:31:05 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 1527082803411963.0310842237235; Wed, 23 May 2018 06:40:03 -0700 (PDT) Received: from localhost ([::1]:33464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLTzi-0006JE-9R for importer@patchew.org; Wed, 23 May 2018 09:39:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fLTZL-0002At-6T for qemu-devel@nongnu.org; Wed, 23 May 2018 09:12:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fLTZI-0007CI-98 for qemu-devel@nongnu.org; Wed, 23 May 2018 09:12:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43412 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 1fLTZB-00076v-3d; Wed, 23 May 2018 09:12:33 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BDECD8182D27; Wed, 23 May 2018 13:12:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.36.118.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAAD785787; Wed, 23 May 2018 13:12:31 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 23 May 2018 15:11:43 +0200 Message-Id: <20180523131155.12359-35-kwolf@redhat.com> In-Reply-To: <20180523131155.12359-1-kwolf@redhat.com> References: <20180523131155.12359-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 23 May 2018 13:12:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 23 May 2018 13:12:32 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.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] [PULL 34/46] block: Cancel job in bdrv_close_all() callers 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 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" Now that we cancel all jobs and not only block jobs on shutdown, doing that in bdrv_close_all() isn't really appropriate any more. Move the job_cancel_sync_all() call to the callers, and only assert that there are no job running in bdrv_close_all(). Signed-off-by: Kevin Wolf --- block.c | 4 +--- qemu-nbd.c | 8 +++++++- vl.c | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block.c b/block.c index d50b08c29b..501b64c819 100644 --- a/block.c +++ b/block.c @@ -3362,9 +3362,7 @@ static void bdrv_close(BlockDriverState *bs) =20 void bdrv_close_all(void) { - /* TODO We do want to cancel all jobs instead of just block jobs on - * shutdown, but bdrv_close_all() isn't the right place any more. */ - job_cancel_sync_all(); + assert(job_next(NULL) =3D=3D NULL); nbd_export_close_all(); =20 /* Drop references from requests still in flight, such as canceled blo= ck diff --git a/qemu-nbd.c b/qemu-nbd.c index 0af0560ad1..51b9d38c72 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -482,6 +482,12 @@ static const char *socket_activation_validate_opts(con= st char *device, return NULL; } =20 +static void qemu_nbd_shutdown(void) +{ + job_cancel_sync_all(); + bdrv_close_all(); +} + int main(int argc, char **argv) { BlockBackend *blk; @@ -928,7 +934,7 @@ int main(int argc, char **argv) exit(EXIT_FAILURE); } bdrv_init(); - atexit(bdrv_close_all); + atexit(qemu_nbd_shutdown); =20 srcpath =3D argv[optind]; if (imageOpts) { diff --git a/vl.c b/vl.c index d5836c65ae..038d7f8042 100644 --- a/vl.c +++ b/vl.c @@ -4683,6 +4683,7 @@ int main(int argc, char **argv, char **envp) /* No more vcpu or device emulation activity beyond this point */ vm_shutdown(); =20 + job_cancel_sync_all(); bdrv_close_all(); =20 res_free(); --=20 2.13.6