From nobody Tue Nov 4 15:40:41 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503966710977786.6529730606039; Mon, 28 Aug 2017 17:31:50 -0700 (PDT) Received: from localhost ([::1]:41970 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmURZ-00075R-1f for importer@patchew.org; Mon, 28 Aug 2017 20:31:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCE-0000wx-9Q for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCB-0005C4-21 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:58 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52595 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCA-0005Bu-Rt for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9gd081527 for ; Mon, 28 Aug 2017 20:15:54 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncr8y-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:54 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:51 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FoFS22544428; Tue, 29 Aug 2017 00:15:50 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C37A1112054; Mon, 28 Aug 2017 20:15:36 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 9080A112051; Mon, 28 Aug 2017 20:15:36 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:56 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-2213-0000-0000-00000210D341 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-2214-0000-0000-0000575DECBF Message-Id: <1503965694-10794-22-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 21/79] aio: add missing aio_notify() to aio_enable_external() 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: qemu-stable@nongnu.org, Stefan Hajnoczi 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" From: Stefan Hajnoczi The main loop uses aio_disable_external()/aio_enable_external() to temporarily disable processing of external AioContext clients like device emulation. This allows monitor commands to quiesce I/O and prevent the guest from submitting new requests while a monitor command is in progress. The aio_enable_external() API is currently broken when an IOThread is in aio_poll() waiting for fd activity when the main loop re-enables external clients. Incrementing ctx->external_disable_cnt does not wake the IOThread from ppoll(2) so fd processing remains suspended and leads to unresponsive emulated devices. This patch adds an aio_notify() call to aio_enable_external() so the IOThread is kicked out of ppoll(2) and will re-arm the file descriptors. The bug can be reproduced as follows: $ qemu -M accel=3Dkvm -m 1024 \ -object iothread,id=3Diothread0 \ -device virtio-scsi-pci,iothread=3Diothread0,id=3Dvirtio-scsi-pci0= \ -drive if=3Dnone,id=3Ddrive0,aio=3Dnative,cache=3Dnone,format=3Dra= w,file=3Dtest.img \ -device scsi-hd,id=3Dscsi-hd0,drive=3Ddrive0 \ -qmp tcp::5555,server,nowait $ scripts/qmp/qmp-shell localhost:5555 (qemu) blockdev-snapshot-sync device=3Ddrive0 snapshot-file=3Dsn1.qcow2 mode=3Dabsolute-paths format=3Dqcow2 After blockdev-snapshot-sync completes the SCSI disk will be unresponsive. This leads to request timeouts inside the guest. Reported-by: Qianqian Zhu Reviewed-by: Fam Zheng Signed-off-by: Stefan Hajnoczi Message-id: 20170508180705.20609-1-stefanha@redhat.com Suggested-by: Fam Zheng Signed-off-by: Stefan Hajnoczi (cherry picked from commit 321d1dba8bef9676a77e9399484e3cd8bf2cf16a) Signed-off-by: Michael Roth --- include/block/aio.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index 406e323..e9aeeae 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -454,8 +454,14 @@ static inline void aio_disable_external(AioContext *ct= x) */ static inline void aio_enable_external(AioContext *ctx) { - assert(ctx->external_disable_cnt > 0); - atomic_dec(&ctx->external_disable_cnt); + int old; + + old =3D atomic_fetch_dec(&ctx->external_disable_cnt); + assert(old > 0); + if (old =3D=3D 1) { + /* Kick event loop so it re-arms file descriptors */ + aio_notify(ctx); + } } =20 /** --=20 2.7.4