From nobody Tue Sep 16 07:42:17 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1508419063415127.5740221124953; Thu, 19 Oct 2017 06:17:43 -0700 (PDT) Received: from localhost ([::1]:49318 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5AhR-0001gy-4O for importer@patchew.org; Thu, 19 Oct 2017 09:17:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e5AgX-0001Ed-KU for qemu-devel@nongnu.org; Thu, 19 Oct 2017 09:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e5AgW-0004fH-Od for qemu-devel@nongnu.org; Thu, 19 Oct 2017 09:16:29 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2271) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1e5AgN-0004YF-RD; Thu, 19 Oct 2017 09:16:20 -0400 Received: from 172.30.72.60 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.60]) by dggrg05-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DJL60538; Thu, 19 Oct 2017 21:16:09 +0800 (CST) Received: from localhost.localdomain (10.175.104.227) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.301.0; Thu, 19 Oct 2017 21:12:40 +0800 From: "sochin.jiang" To: , , , Date: Sun, 24 Nov 2013 11:55:52 +0800 Message-ID: <1385265352-40801-1-git-send-email-sochin.jiang@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.104.227] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.59E8A59B.0005, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 87f88119faf9c02e4f506c00fdbc117c X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [PATCH] throttle: fix a qemu crash problem when calling blk_delete 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: xieyingtai@huawei.com, lina.lulina@huawei.com, lizhengui@huawei.com, qemu-block@nongnu.org, subo7@huawei.com, eric.fangyi@huawei.com, zhangshuai13@huawei.com, qemu-devel@nongnu.org, sochin.jiang@huawei.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 Content-Type: text/plain; charset="utf-8" From: "sochin.jiang" commit 7ca7f0 moves the throttling related part of the BDS life cycle manag= ement to BlockBackend, adds call to throttle_timers_detach_aio_context in blk_rem= ove_bs. commit 1606e remove a block device from its throttle group in blk_delete by= calling blk_io_limits_disable, this fix an easily reproducible qemu crash. But dele= te a BB without a BDS inserted could easily cause a qemu crash too by calling bdrv_drained_begin in blk_io_limits_disable. Say, a simply drive_add and th= en a drive_del command. Signed-off-by: sochin.jiang --- block/io.c | 8 ++++++++ util/throttle.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/block/io.c b/block/io.c index 0854e0f..c411a87 100644 --- a/block/io.c +++ b/block/io.c @@ -269,6 +269,10 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockD= riverState *bs, =20 void bdrv_drained_begin(BlockDriverState *bs) { + if (!bs) { + return; + } + if (qemu_in_coroutine()) { bdrv_co_yield_to_drain(bs, true); return; @@ -284,6 +288,10 @@ void bdrv_drained_begin(BlockDriverState *bs) =20 void bdrv_drained_end(BlockDriverState *bs) { + if (!bs) { + return; + } + if (qemu_in_coroutine()) { bdrv_co_yield_to_drain(bs, false); return; diff --git a/util/throttle.c b/util/throttle.c index b38e742..35a21fc 100644 --- a/util/throttle.c +++ b/util/throttle.c @@ -245,8 +245,6 @@ void throttle_timers_init(ThrottleTimers *tt, /* destroy a timer */ static void throttle_timer_destroy(QEMUTimer **timer) { - assert(*timer !=3D NULL); - timer_del(*timer); timer_free(*timer); *timer =3D NULL; @@ -258,7 +256,9 @@ void throttle_timers_detach_aio_context(ThrottleTimers = *tt) int i; =20 for (i =3D 0; i < 2; i++) { - throttle_timer_destroy(&tt->timers[i]); + if (tt->timers[i]) { + throttle_timer_destroy(&tt->timers[i]); + } } } =20 --=20 1.8.3.1