From nobody Wed May 1 10:36:49 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547044227004472.0864229823037; Wed, 9 Jan 2019 06:30:27 -0800 (PST) Received: from localhost ([127.0.0.1]:55566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghEsE-0000lT-1d for importer@patchew.org; Wed, 09 Jan 2019 09:30:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39278) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghEr3-0008NG-2L for qemu-devel@nongnu.org; Wed, 09 Jan 2019 09:29:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghEr0-000186-Dk for qemu-devel@nongnu.org; Wed, 09 Jan 2019 09:29:13 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:37374) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghEqz-00016F-RA; Wed, 09 Jan 2019 09:29:10 -0500 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ghEqx-0004tF-33; Wed, 09 Jan 2019 15:29:07 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghEqh-0007Dv-GF; Wed, 09 Jan 2019 16:28:51 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=Ngv2gfJ4e9rVVTdueJNWym+QwUAlqMMbk+zyWdFt63Q=; b=dvXIJEO5QCBq5vfHtiDVrs+5KKwH1tNoXrFRlhO+5sMR6848nZ/RyXhfRvicrTRKhfripZOPpYVPs2pQ5RP0mGlf3Sy1evMsMM6BhXBhRUaUGOhBTTvOL4MqJ0I/cyep0niMDgUZVA0HR3YYGOZkzsbJgxd+bm0hpxyE5tXeMIMg3Ahq2KlqXhAAUgd80HN8FRYj6ZUStqxxAY9d2a+V69CDiJbAka4H12BZYPg64J9tSBzOcjYILUBHPXkfCJKs4ovVsNvlbc9+LIMmruCC4Le8qvR/qYDuXRFG06n68huzycfnKtn6khS8eWt+wN+ItwIIdMlPeB3yx7LDAaw5Ow==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 16:28:50 +0200 Message-Id: <20190109142850.27727-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] block: Acquire the AioContext in guess_disk_lchs() 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: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This fixes the following crash: { "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0"}} { "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}} { "execute": "x-blockdev-set-iothread", "arguments": {"node-name": "hd0", "iothread": "iothread0"}} { "execute": "device_add", "arguments": {"id": "virtio0", "driver": "virtio-blk-pci", "drive": "hd0"}} qemu: qemu_mutex_unlock_impl: Operation not permitted Aborted Signed-off-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi --- hw/block/hd-geometry.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/block/hd-geometry.c b/hw/block/hd-geometry.c index 79384a2b0a..0d9a7b7e7d 100644 --- a/hw/block/hd-geometry.c +++ b/hw/block/hd-geometry.c @@ -55,6 +55,7 @@ struct partition { static int guess_disk_lchs(BlockBackend *blk, int *pcylinders, int *pheads, int *psectors) { + AioContext *ctx =3D blk_get_aio_context(blk); uint8_t buf[BDRV_SECTOR_SIZE]; int i, heads, sectors, cylinders; struct partition *p; @@ -68,7 +69,10 @@ static int guess_disk_lchs(BlockBackend *blk, * but also in async I/O mode. So the I/O throttling function has to * be disabled temporarily here, not permanently. */ - if (blk_pread_unthrottled(blk, 0, buf, BDRV_SECTOR_SIZE) < 0) { + aio_context_acquire(ctx); + i =3D blk_pread_unthrottled(blk, 0, buf, BDRV_SECTOR_SIZE); + aio_context_release(ctx); + if (i < 0) { return -1; } /* test msdos magic */ --=20 2.11.0