From nobody Wed Oct 29 09:14:50 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 1526650803198650.0882571104505; Fri, 18 May 2018 06:40:03 -0700 (PDT) Received: from localhost ([::1]:38987 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJfc2-0007sg-C0 for importer@patchew.org; Fri, 18 May 2018 09:40:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59837) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJfKj-000097-G2 for qemu-devel@nongnu.org; Fri, 18 May 2018 09:22:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJfKi-0006Fa-H9 for qemu-devel@nongnu.org; Fri, 18 May 2018 09:22:09 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47734 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 1fJfKg-0006Db-Ei; Fri, 18 May 2018 09:22:06 -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 0BF62C12A1; Fri, 18 May 2018 13:22:06 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-149.ams2.redhat.com [10.36.117.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id B25F42026DFD; Fri, 18 May 2018 13:22:04 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Fri, 18 May 2018 15:21:02 +0200 Message-Id: <20180518132114.4070-29-kwolf@redhat.com> In-Reply-To: <20180518132114.4070-1-kwolf@redhat.com> References: <20180518132114.4070-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.1]); Fri, 18 May 2018 13:22:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Fri, 18 May 2018 13:22:06 +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 v2 28/40] 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, jsnow@redhat.com, jcody@redhat.com, armbru@redhat.com, mreitz@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" 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 3b39bbd7a8..d8c53ab9fd 100644 --- a/vl.c +++ b/vl.c @@ -4679,6 +4679,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