From nobody Sat Feb 7 15:49:55 2026 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 1547132998132779.218910067069; Thu, 10 Jan 2019 07:09:58 -0800 (PST) Received: from localhost ([127.0.0.1]:45658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghby1-0006ru-3W for importer@patchew.org; Thu, 10 Jan 2019 10:09:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsN-00036w-Vx for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007OR-Gm for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:06 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57861) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007NK-Tl; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mU-Oi; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bb-32; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=1RDoTfYk81Gj3E6of/gL7KLZOJeO382M3nMlpGpF9YU=; b=dVslm2tOWO6iBcP2yqcqIXnNyITnF2WHQ8Yy5HrV42Akzuzs+tMzpUCKMrIYF7gTGW9GPiRzTf51BXJn3zpJIe6Jyw9ltIOIghbI7uyJnQxBYPh/OIm9F3uac7MfXMJ+vA64VH3CSotl92uoBX52jTsnmdhIqUng2dRpC/ks4JPDzryYIiCNe3EHWz1xJTRaYwiB/1Qi4P5XicP27G84xbTP/h0fMaH52A31+1/rY1XYfJuREPtS0E7CFSwEjLy+LIo7wYrpl5h2LQDrGCmLqKuC/ICghz50tM2pkV8IHlvRSppRbECXpaMMRw72L49IMFrnoq0fb4ameT2z/RlwZA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:35 +0200 Message-Id: <4a595def20efc9d1d076850d79a2c7e6d0996ffd.1547132561.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 1/6] block: Acquire the AioContext in virtio_blk_device_realize() 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 --- hw/block/virtio-blk.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index f208c6ddb9..5357da82af 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -912,6 +912,7 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) VirtIODevice *vdev =3D VIRTIO_DEVICE(dev); VirtIOBlock *s =3D VIRTIO_BLK(dev); VirtIOBlkConf *conf =3D &s->conf; + AioContext *ctx; Error *err =3D NULL; unsigned i; =20 @@ -919,30 +920,34 @@ static void virtio_blk_device_realize(DeviceState *de= v, Error **errp) error_setg(errp, "drive property not set"); return; } + + ctx =3D blk_get_aio_context(conf->conf.blk); + aio_context_acquire(ctx); + if (!blk_is_inserted(conf->conf.blk)) { error_setg(errp, "Device needs media, but drive is empty"); - return; + goto out; } if (!conf->num_queues) { error_setg(errp, "num-queues property must be larger than 0"); - return; + goto out; } if (!is_power_of_2(conf->queue_size) || conf->queue_size > VIRTQUEUE_MAX_SIZE) { error_setg(errp, "invalid queue-size property (%" PRIu16 "), " "must be a power of 2 (max %d)", conf->queue_size, VIRTQUEUE_MAX_SIZE); - return; + goto out; } =20 if (!blkconf_apply_backend_options(&conf->conf, blk_is_read_only(conf->conf.blk), t= rue, errp)) { - return; + goto out; } s->original_wce =3D blk_enable_write_cache(conf->conf.blk); if (!blkconf_geometry(&conf->conf, NULL, 65535, 255, 255, errp)) { - return; + goto out; } =20 blkconf_blocksizes(&conf->conf); @@ -951,7 +956,7 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) conf->conf.physical_block_size) { error_setg(errp, "logical_block_size > physical_block_size not supported= "); - return; + goto out; } =20 virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, @@ -968,7 +973,7 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) if (err !=3D NULL) { error_propagate(errp, err); virtio_cleanup(vdev); - return; + goto out; } =20 s->change =3D qemu_add_vm_change_state_handler(virtio_blk_dma_restart_= cb, s); @@ -976,6 +981,9 @@ static void virtio_blk_device_realize(DeviceState *dev,= Error **errp) blk_set_guest_block_size(s->blk, s->conf.conf.logical_block_size); =20 blk_iostatus_enable(s->blk); + +out: + aio_context_release(ctx); } =20 static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp) --=20 2.11.0 From nobody Sat Feb 7 15:49:55 2026 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547132881221844.5222162294519; Thu, 10 Jan 2019 07:08:01 -0800 (PST) Received: from localhost ([127.0.0.1]:45110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbw2-0005cd-Md for importer@patchew.org; Thu, 10 Jan 2019 10:07:54 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46113) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsJ-000324-FJ for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007O1-EW for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:03 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57867) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007NE-Te; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mT-NJ; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bd-4R; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=o4MgRiH2A9D2KlY6wfivpWdHv4L6n8VMY28b8z4DSDY=; b=fdZnFnHmLHN14kQWM7r7ICZcv9//lTYKNwBkKzylTLnN5DkE35CQF+VCYY8rtdBCJjJXxVSVKnXigdVjLmi0zyVTe1i01opUxQ9c0cHR6gL4R82ZrMyKjio8IRaP0Q1QNul2nHjEOLFz4rM7AkKO9f5zRCjco8uZajwrwlNDPu82QrC5V9rfO7SUqdpFG6Mc6Sdf9dOWsOreLdRj0gxuPBAZQpKKjni3QxymbFuCcSpbTcQQ4MTQfgMwvyTpP+NMcr3tHWk5CAUoEGyZ+bSWgocV4qlgZGPNOxC6oewQWfhtLoFmTmdY06ft52vdU7sgi2Ks5rvEvbJy4pPwBBqktg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:36 +0200 Message-Id: <42c8dab1efbcd608a09a1d84468fc498b612bfa1.1547132561.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 2/6] block: Acquire the AioContext in scsi_*_realize() 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": "scsi-pci0", "driver": "virtio-scsi-pci"}} { "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}} qemu: qemu_mutex_unlock_impl: Operation not permitted Aborted Signed-off-by: Alberto Garcia --- hw/scsi/scsi-disk.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 0e9027c8f3..8a22def7f3 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2318,16 +2318,20 @@ static void scsi_disk_unit_attention_reported(SCSID= evice *dev) static void scsi_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + AioContext *ctx; =20 if (!s->qdev.conf.blk) { error_setg(errp, "drive property not set"); return; } =20 + ctx =3D blk_get_aio_context(s->qdev.conf.blk); + aio_context_acquire(ctx); + if (!(s->features & (1 << SCSI_DISK_F_REMOVABLE)) && !blk_is_inserted(s->qdev.conf.blk)) { error_setg(errp, "Device needs media, but drive is empty"); - return; + goto out; } =20 blkconf_blocksizes(&s->qdev.conf); @@ -2336,18 +2340,18 @@ static void scsi_realize(SCSIDevice *dev, Error **e= rrp) s->qdev.conf.physical_block_size) { error_setg(errp, "logical_block_size > physical_block_size not supported= "); - return; + goto out; } =20 if (dev->type =3D=3D TYPE_DISK) { if (!blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, errp)) { - return; + goto out; } } if (!blkconf_apply_backend_options(&dev->conf, blk_is_read_only(s->qdev.conf.blk), dev->type =3D=3D TYPE_DISK, errp)) { - return; + goto out; } =20 if (s->qdev.conf.discard_granularity =3D=3D -1) { @@ -2364,7 +2368,7 @@ static void scsi_realize(SCSIDevice *dev, Error **err= p) =20 if (blk_is_sg(s->qdev.conf.blk)) { error_setg(errp, "unwanted /dev/sg*"); - return; + goto out; } =20 if ((s->features & (1 << SCSI_DISK_F_REMOVABLE)) && @@ -2376,6 +2380,9 @@ static void scsi_realize(SCSIDevice *dev, Error **err= p) blk_set_guest_block_size(s->qdev.conf.blk, s->qdev.blocksize); =20 blk_iostatus_enable(s->qdev.conf.blk); + +out: + aio_context_release(ctx); } =20 static void scsi_hd_realize(SCSIDevice *dev, Error **errp) @@ -2385,7 +2392,10 @@ static void scsi_hd_realize(SCSIDevice *dev, Error *= *errp) * backend will be issued in scsi_realize */ if (s->qdev.conf.blk) { + AioContext *ctx =3D blk_get_aio_context(s->qdev.conf.blk); + aio_context_acquire(ctx); blkconf_blocksizes(&s->qdev.conf); + aio_context_release(ctx); } s->qdev.blocksize =3D s->qdev.conf.logical_block_size; s->qdev.type =3D TYPE_DISK; @@ -2553,6 +2563,7 @@ static int get_device_type(SCSIDiskState *s) static void scsi_block_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, dev); + AioContext *ctx; int sg_version; int rc; =20 @@ -2568,7 +2579,10 @@ static void scsi_block_realize(SCSIDevice *dev, Erro= r **errp) } =20 /* check we are using a driver managing SG_IO (version 3 and after) */ + ctx =3D blk_get_aio_context(s->qdev.conf.blk); + aio_context_acquire(ctx); rc =3D blk_ioctl(s->qdev.conf.blk, SG_GET_VERSION_NUM, &sg_version); + aio_context_release(ctx); if (rc < 0) { error_setg_errno(errp, -rc, "cannot get SG_IO version number"); if (rc !=3D -EPERM) { --=20 2.11.0 From nobody Sat Feb 7 15:49:55 2026 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 154713276098066.0415855305962; Thu, 10 Jan 2019 07:06:00 -0800 (PST) Received: from localhost ([127.0.0.1]:44578 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbuB-0004Bw-UV for importer@patchew.org; Thu, 10 Jan 2019 10:06:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsH-00030v-K7 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007OJ-G2 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:01 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007NH-Po; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mV-Kq; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bf-5m; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=m2WBlCimuDjftw+8ixiiiYkdpLsUiwuy4ahzX9WwfLg=; b=hV8xgwpy3l9MDp8hb94GHuluEdsvFqA/IIELVFc3/HBU1g/JK8L+89H014LEWBf3OeQfgTDZuVz7JJQZ6aLR3B3LHWm01Fb5mei9aDv8XdA0PeUI30MoYY3vWWi7fUmnKh/47qzrX8zT4r1p4lWRqgYcME3CIvjym6AuprEOXXExAz4pE12399eygUNTTNFZzQJ4VMT0S6GdJqv/YtxHTZg++WEB2gmKdWYJqpZxiLtZQnbDVXOVBfEA7W6ATswLHHedb47kywlnm4Xj2vAvKNGUndDAw6j4qV+MSO59k+naFcyYmxVDYtpqrnWacmy76EupoXm3os52Cm9un8DGkg==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:37 +0200 Message-Id: <26733c0b339a4cf53318aa2b898eaa409fb307c6.1547132561.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 3/6] block: Acquire the AioContext in floppy_drive_realize() 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" Signed-off-by: Alberto Garcia --- hw/block/fdc.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index 6f19f127a5..d9bc80de83 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -512,6 +512,7 @@ static void floppy_drive_realize(DeviceState *qdev, Err= or **errp) { FloppyDrive *dev =3D FLOPPY_DRIVE(qdev); FloppyBus *bus =3D FLOPPY_BUS(qdev->parent_bus); + AioContext *ctx; FDrive *drive; int ret; =20 @@ -543,13 +544,16 @@ static void floppy_drive_realize(DeviceState *qdev, E= rror **errp) assert(ret =3D=3D 0); } =20 + ctx =3D blk_get_aio_context(dev->conf.blk); + aio_context_acquire(ctx); + blkconf_blocksizes(&dev->conf); if (dev->conf.logical_block_size !=3D 512 || dev->conf.physical_block_size !=3D 512) { error_setg(errp, "Physical and logical block size must " "be 512 for floppy"); - return; + goto out; } =20 /* rerror/werror aren't supported by fdc and therefore not even regist= ered @@ -561,7 +565,7 @@ static void floppy_drive_realize(DeviceState *qdev, Err= or **errp) if (!blkconf_apply_backend_options(&dev->conf, blk_is_read_only(dev->conf.blk), false, errp)) { - return; + goto out; } =20 /* 'enospc' is the default for -drive, 'report' is what blk_new() give= s us @@ -569,11 +573,11 @@ static void floppy_drive_realize(DeviceState *qdev, E= rror **errp) if (blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_ENOSPC && blk_get_on_error(dev->conf.blk, 0) !=3D BLOCKDEV_ON_ERROR_REPORT) { error_setg(errp, "fdc doesn't support drive option werror"); - return; + goto out; } if (blk_get_on_error(dev->conf.blk, 1) !=3D BLOCKDEV_ON_ERROR_REPORT) { error_setg(errp, "fdc doesn't support drive option rerror"); - return; + goto out; } =20 drive->conf =3D &dev->conf; @@ -589,6 +593,9 @@ static void floppy_drive_realize(DeviceState *qdev, Err= or **errp) dev->type =3D drive->drive; =20 fd_revalidate(drive); + +out: + aio_context_release(ctx); } =20 static void floppy_drive_class_init(ObjectClass *klass, void *data) --=20 2.11.0 From nobody Sat Feb 7 15:49:55 2026 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 (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547132902739906.7317222830618; Thu, 10 Jan 2019 07:08:22 -0800 (PST) Received: from localhost ([127.0.0.1]:45167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbwG-0005kE-Qy for importer@patchew.org; Thu, 10 Jan 2019 10:08:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsJ-000323-FD for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007O9-Fd for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:03 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57858) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007NG-Tk; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mW-NT; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bk-6u; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=2aMwKPnI9IS6rxkTuyf5yBvVNXJewJfksZj5pzl1vHY=; b=m6ObEf27W9eypmNOUfPMK8lJxtTvKlnGoS9X0lzrI9GnlbvVtCXWTvIlcKVxzdy2oaT6yI1+qCV8gWgYIpoCJ6j1iEvJPrxvYnVhw3PgerBNv7puNwqMXwE7bIUZxKGOL2TOMvZRy3vFEoi+4EKc2WKg3zZsdLnfk2E5SzES3BAV6TV/BtdeP1JmcyLiJTPKAwYNd0A6QtPAmVhc6T1jByLhmReLJnr+nv7PY7JMV2g4oYFpNRoLT593dt5EddDgIHayHMXJqf5WkLc077Wfm+A6F2LS7jj0HedTSuB4x3oR+fHL4JiS3bjiDOOB43czvpEJpnUIZ4eMxwNKW0Pynw==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:38 +0200 Message-Id: <9741b3d123b583ce0abc9f29c9c0abcc89a6aa79.1547132561.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 4/6] block: Acquire the AioContext in nvme_realize() 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" Signed-off-by: Alberto Garcia --- hw/block/nvme.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 7c8c63e8f5..72e94aff86 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1203,6 +1203,7 @@ static void nvme_realize(PCIDevice *pci_dev, Error **= errp) { NvmeCtrl *n =3D NVME(pci_dev); NvmeIdCtrl *id =3D &n->id_ctrl; + AioContext *ctx; =20 int i; int64_t bs_size; @@ -1213,20 +1214,23 @@ static void nvme_realize(PCIDevice *pci_dev, Error = **errp) return; } =20 + ctx =3D blk_get_aio_context(n->conf.blk); + aio_context_acquire(ctx); + bs_size =3D blk_getlength(n->conf.blk); if (bs_size < 0) { error_setg(errp, "could not get backing file size"); - return; + goto out; } =20 if (!n->serial) { error_setg(errp, "serial property not set"); - return; + goto out; } blkconf_blocksizes(&n->conf); if (!blkconf_apply_backend_options(&n->conf, blk_is_read_only(n->conf.= blk), false, errp)) { - return; + goto out; } =20 pci_conf =3D pci_dev->config; @@ -1323,6 +1327,9 @@ static void nvme_realize(PCIDevice *pci_dev, Error **= errp) cpu_to_le64(n->ns_size >> id_ns->lbaf[NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas)].ds); } + +out: + aio_context_release(ctx); } =20 static void nvme_exit(PCIDevice *pci_dev) --=20 2.11.0 From nobody Sat Feb 7 15:49:55 2026 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 1547133001441712.1721203169161; Thu, 10 Jan 2019 07:10:01 -0800 (PST) Received: from localhost ([127.0.0.1]:45678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghby4-0006uO-Dc for importer@patchew.org; Thu, 10 Jan 2019 10:10:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsJ-00031u-A2 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007OD-Ff for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:01 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57859) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007NB-PQ; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mX-O7; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bn-7u; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=W7LVq02B3oJ0WAICRK2gxqTMWcXU/5rEQ6zaeITmus4=; b=SBFLcEVcbyQBbvQfkSAywFHGme/vSU6jGP0YrXWu1haOdXPEg196F239bOPRCVdXtoX7ChQ9Jz8hJeevAGM8xSwVc/WfHGQ2cm0KVnWfN/r5rFQRbc2cgXEOezajWfnSge7hKtwbpOuSUyQQe+qvh29KyOPwmDgBci/IF07xGt/LkFYBIgPiIyZSUPDwwsPEGwH+U2kNeBPwVcxXr7P2PC3AzlUbxAOUvvpvFD72v02t8tKqx20GLazTjgWNA4IURN0RcxyMlGn2iEeQIsrzWZRT6xOlJoZoIDHz6Yfe6YpXROXankg742kbRGM06Mokt5sBSPziIqrCeflL5Hyb9Q==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:39 +0200 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 5/6] block: Acquire the AioContext in ide_dev_initfn() 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" Signed-off-by: Alberto Garcia --- hw/ide/qdev.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c index 573b022e1e..f355f2a352 100644 --- a/hw/ide/qdev.c +++ b/hw/ide/qdev.c @@ -160,6 +160,7 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind= kind, Error **errp) { IDEBus *bus =3D DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s =3D bus->ifs + dev->unit; + AioContext *ctx; int ret; =20 if (!dev->conf.blk) { @@ -174,36 +175,39 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKi= nd kind, Error **errp) } } =20 + ctx =3D blk_get_aio_context(dev->conf.blk); + aio_context_acquire(ctx); + if (dev->conf.discard_granularity =3D=3D -1) { dev->conf.discard_granularity =3D 512; } else if (dev->conf.discard_granularity && dev->conf.discard_granularity !=3D 512) { error_setg(errp, "discard_granularity must be 512 for ide"); - return; + goto out; } =20 blkconf_blocksizes(&dev->conf); if (dev->conf.logical_block_size !=3D 512) { error_setg(errp, "logical_block_size must be 512 for IDE"); - return; + goto out; } =20 if (kind !=3D IDE_CD) { if (!blkconf_geometry(&dev->conf, &dev->chs_trans, 65535, 16, 255, errp)) { - return; + goto out; } } if (!blkconf_apply_backend_options(&dev->conf, kind =3D=3D IDE_CD, kind !=3D IDE_CD, errp)) { - return; + goto out; } =20 if (ide_init_drive(s, dev->conf.blk, kind, dev->version, dev->serial, dev->model, dev->wwn, dev->conf.cyls, dev->conf.heads, dev->conf.secs, dev->chs_trans, errp) < 0) { - return; + goto out; } =20 if (!dev->version) { @@ -215,6 +219,9 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind= kind, Error **errp) =20 add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); + +out: + aio_context_release(ctx); } =20 static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *nam= e, --=20 2.11.0 From nobody Sat Feb 7 15:49:55 2026 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 1547132762457752.2846648132721; Thu, 10 Jan 2019 07:06:02 -0800 (PST) Received: from localhost ([127.0.0.1]:44589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbuD-0004EG-ED for importer@patchew.org; Thu, 10 Jan 2019 10:06:01 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbsH-00030l-C6 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghbsG-0007OW-H1 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 10:04:01 -0500 Received: from fanzine.igalia.com ([91.117.99.155]:57864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghbsF-0007ND-TM; Thu, 10 Jan 2019 10:04:00 -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 1ghbsD-0003mY-O5; Thu, 10 Jan 2019 16:03:57 +0100 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1ghbry-0002Bq-9N; Thu, 10 Jan 2019 17:03:42 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=L9HmUY97OyxWpLBVGHyd1eTDvesw+Ee02jTzh2ZhCVw=; b=DVEIxDbQ8sOQc/VwIy/hKGboPcfncvAf190dawMLxCkzOdHd4QQZByTILwsltZ8P1ekDSLmoDOLMNaCM8QXH30oMRyOmngraAe7vZr68hTo7n4HTl0Te5Ykq45/FtRTB5qjWOQ9D9tYwHDrZd1fxr/gLggDRpuZ5/QYr9swaIl3gZELwGyshrVPf07u+zWbsE2XxrlUKOycPJ/rW//F0iICBsaEWib8UN9zBuTvHTMN1YVZnUf8t1t1YFVnNj4WmcY9E/ArYl2sg4/NZ6LHS/lAm3Gq1xpm2/CDCrDBh6/lkgA9OsNG8H2EOVqu+aQ+KdIevu+aOYPCpHIy6uvetYQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 17:03:40 +0200 Message-Id: <485e041662e587923855fdc037c88556ce6ea5d1.1547132561.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 6/6] block: Acquire the AioContext in usb_msd_storage_realize() 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" Signed-off-by: Alberto Garcia --- hw/usb/dev-storage.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c index cd5551d94f..fa6e552f0f 100644 --- a/hw/usb/dev-storage.c +++ b/hw/usb/dev-storage.c @@ -593,13 +593,18 @@ static void usb_msd_storage_realize(USBDevice *dev, E= rror **errp) MSDState *s =3D USB_STORAGE_DEV(dev); BlockBackend *blk =3D s->conf.blk; SCSIDevice *scsi_dev; + AioContext *ctx; =20 if (!blk) { error_setg(errp, "drive property not set"); return; } =20 + ctx =3D blk_get_aio_context(blk); + aio_context_acquire(ctx); blkconf_blocksizes(&s->conf); + aio_context_release(ctx); + if (!blkconf_apply_backend_options(&s->conf, blk_is_read_only(blk), tr= ue, errp)) { return; --=20 2.11.0