From nobody Sat Apr 27 05:17:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560377683; cv=none; d=zoho.com; s=zohoarc; b=RTzEXtqW89Pp07cMg5+u+8cwIe95jtkKGQqYAK+iQ2JQAPK+EMDjaIbbktUyAm9QoRdv1MMt+YYfiIqvxj+jbFTig9XjJ/d2WHHjtpocy8fQvBZdImEgrJFWLSbQt11aRL8c/zpDSI1asC+bFfTN3ofRgymxgr4WaW7gtVXTjOc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560377683; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=RJLgVasOMrRn8bROvWXKVyLTIgN07zG87cTSDpcJQrI=; b=SmxJBT5J21D4UAgss8sibFD+fiL///m5Zl61CMsSjC3y0xWO7Fcm3kyO6zXf5I+/zIqZ0URMaIKkvL927uKbH0djAyEhN7yakriomMb/q1diREZe4Pal9Oc5+RvU9P9aMkpgjCoMwLBRVcK1xuyuWVq6U3ygUmGujjl003zS0wU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1560377683668611.0743535417658; Wed, 12 Jun 2019 15:14:43 -0700 (PDT) Received: from localhost ([::1]:35394 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBVw-0001h2-N6 for importer@patchew.org; Wed, 12 Jun 2019 18:14:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44706) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBQR-0005lp-NB for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:09:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbBQP-0006Wd-MP for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:08:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33360) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbBQK-0006Sh-CG; Wed, 12 Jun 2019 18:08:53 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B245307C945; Wed, 12 Jun 2019 22:08:44 +0000 (UTC) Received: from localhost (unknown [10.40.205.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CE4B61D09; Wed, 12 Jun 2019 22:08:43 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Jun 2019 00:08:38 +0200 Message-Id: <20190612220839.1374-2-mreitz@redhat.com> In-Reply-To: <20190612220839.1374-1-mreitz@redhat.com> References: <20190612220839.1374-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Wed, 12 Jun 2019 22:08:44 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/2] vl: Drain before (block) job cancel when quitting X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If the main loop cancels all block jobs while the block layer is not drained, this cancelling may not happen instantaneously. We can start a drained section before vm_shutdown(), which entails another bdrv_drain_all(); this nested bdrv_drain_all() will thus be a no-op, basically. We do not have to end the drained section, because we actually do not want any requests to happen from this point on. Signed-off-by: Max Reitz --- I don't know whether it actually makes sense to never end this drained section. It makes sense to me. Please correct me if I'm wrong. --- vl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vl.c b/vl.c index cd1fbc4cdc..3f8b3f74f5 100644 --- a/vl.c +++ b/vl.c @@ -4538,6 +4538,17 @@ int main(int argc, char **argv, char **envp) */ migration_shutdown(); =20 + /* + * We must cancel all block jobs while the block layer is drained, + * or cancelling will be affected by throttling and thus may block + * for an extended period of time. + * vm_shutdown() will bdrv_drain_all(), so we may as well include + * it in the drained section. + * We do not need to end this section, because we do not want any + * requests happening from here on anyway. + */ + bdrv_drain_all_begin(); + /* No more vcpu or device emulation activity beyond this point */ vm_shutdown(); =20 --=20 2.21.0 From nobody Sat Apr 27 05:17:32 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.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 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1560377504; cv=none; d=zoho.com; s=zohoarc; b=HXZXfZYFRu/jdsSbYZlzYUcx6fFwugGodGukwiATi3lfdqIMRx1tCtpfipZmy0XoAi7iorZDcuQxZ25/A2qWwASWveE54FB+5L4y5wcbooO1TvQvmvnoCMC94k33Y4HJqwWNH0V6DCsgMQI2PRMIiqy5ep1cBZfyfmGIfHWVOr4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1560377504; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=rANFmnON4MP91M+TZoPDsqjgWHXMh3nVoZTC0O/RxlY=; b=HLX4zuh6g0QwL8ZzZMilLaBM1UwE4FNtiqX4wVLnMSPFZgoRCeC6LJIpFPcDyRvcoPL1yBsHHoRExeycvTSVlxGgW9iYAAuEod9QdVo3mjNwYXIofqEmi+j+WTkxMOdQxIpVcaDT0Q57028wKpVKHKCxNZ/FUi8x5SIbJrptI+w= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 156037750430162.24315569351745; Wed, 12 Jun 2019 15:11:44 -0700 (PDT) Received: from localhost ([::1]:35374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBSu-0007O7-Ge for importer@patchew.org; Wed, 12 Jun 2019 18:11:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44705) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hbBQR-0005ln-N4 for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:09:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hbBQP-0006We-MS for qemu-devel@nongnu.org; Wed, 12 Jun 2019 18:08:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35884) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hbBQK-0006RD-CG; Wed, 12 Jun 2019 18:08:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DD85A30860B9; Wed, 12 Jun 2019 22:08:46 +0000 (UTC) Received: from localhost (unknown [10.40.205.72]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69E261710F; Wed, 12 Jun 2019 22:08:46 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Thu, 13 Jun 2019 00:08:39 +0200 Message-Id: <20190612220839.1374-3-mreitz@redhat.com> In-Reply-To: <20190612220839.1374-1-mreitz@redhat.com> References: <20190612220839.1374-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 12 Jun 2019 22:08:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] iotests: Test quitting with job on throttled node X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" When qemu quits, all throttling should be ignored. That means, if there is a mirror job running from a throttled node, it should be cancelled immediately and qemu close without blocking. Signed-off-by: Max Reitz --- tests/qemu-iotests/218 | 55 ++++++++++++++++++++++++++++++++++++-- tests/qemu-iotests/218.out | 4 +++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218 index 92c331b6fb..2554d84581 100755 --- a/tests/qemu-iotests/218 +++ b/tests/qemu-iotests/218 @@ -27,9 +27,9 @@ # Creator/Owner: Max Reitz =20 import iotests -from iotests import log +from iotests import log, qemu_img, qemu_io_silent =20 -iotests.verify_platform(['linux']) +iotests.verify_image_format(supported_fmts=3D['qcow2', 'raw']) =20 =20 # Launches the VM, adds two null-co nodes (source and target), and @@ -136,3 +136,54 @@ with iotests.VM() as vm: =20 log(vm.event_wait('BLOCK_JOB_CANCELLED'), filters=3D[iotests.filter_qmp_event]) + +log('') +log('=3D=3D=3D Cancel mirror job from throttled node by quitting =3D=3D=3D= ') +log('') + +with iotests.VM() as vm, \ + iotests.FilePath('src.img') as src_img_path: + + assert qemu_img('create', '-f', iotests.imgfmt, src_img_path, '64M') = =3D=3D 0 + assert qemu_io_silent('-f', iotests.imgfmt, src_img_path, + '-c', 'write -P 42 0M 64M') =3D=3D 0 + + vm.launch() + + ret =3D vm.qmp('object-add', qom_type=3D'throttle-group', id=3D'tg', + props=3D{'x-bps-read': 4096}) + assert ret['return'] =3D=3D {} + + ret =3D vm.qmp('blockdev-add', + node_name=3D'source', + driver=3Diotests.imgfmt, + file=3D{ + 'driver': 'file', + 'filename': src_img_path + }) + assert ret['return'] =3D=3D {} + + ret =3D vm.qmp('blockdev-add', + node_name=3D'throttled-source', + driver=3D'throttle', + throttle_group=3D'tg', + file=3D'source') + assert ret['return'] =3D=3D {} + + ret =3D vm.qmp('blockdev-add', + node_name=3D'target', + driver=3D'null-co', + size=3D(64 * 1048576)) + assert ret['return'] =3D=3D {} + + ret =3D vm.qmp('blockdev-mirror', + job_id=3D'mirror', + device=3D'throttled-source', + target=3D'target', + sync=3D'full') + assert ret['return'] =3D=3D {} + + log(vm.qmp('quit')) + + with iotests.Timeout(5, 'Timeout waiting for VM to quit'): + vm.shutdown(has_quit=3DTrue) diff --git a/tests/qemu-iotests/218.out b/tests/qemu-iotests/218.out index 825a657081..5a86a97550 100644 --- a/tests/qemu-iotests/218.out +++ b/tests/qemu-iotests/218.out @@ -28,3 +28,7 @@ Cancelling job Cancelling job {"return": {}} {"data": {"device": "mirror", "len": 1048576, "offset": 1048576, "speed": = 0, "type": "mirror"}, "event": "BLOCK_JOB_CANCELLED", "timestamp": {"micros= econds": "USECS", "seconds": "SECS"}} + +=3D=3D=3D Cancel mirror job from throttled node by quitting =3D=3D=3D + +{"return": {}} --=20 2.21.0