From patchwork Thu Jan 10 15:03:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alberto Garcia X-Patchwork-Id: 10756039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA47E13B5 for ; Thu, 10 Jan 2019 15:09:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA3B82987E for ; Thu, 10 Jan 2019 15:09:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDFC129884; Thu, 10 Jan 2019 15:09:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 677FF2987E for ; Thu, 10 Jan 2019 15:09:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:45678 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghbxh-0006uO-NB for patchwork-qemu-devel@patchwork.kernel.org; Thu, 10 Jan 2019 10:09:37 -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 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==; 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 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 = DO_UPCAST(IDEBus, qbus, dev->qdev.parent_bus); IDEState *s = bus->ifs + dev->unit; + AioContext *ctx; int ret; if (!dev->conf.blk) { @@ -174,36 +175,39 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp) } } + ctx = blk_get_aio_context(dev->conf.blk); + aio_context_acquire(ctx); + if (dev->conf.discard_granularity == -1) { dev->conf.discard_granularity = 512; } else if (dev->conf.discard_granularity && dev->conf.discard_granularity != 512) { error_setg(errp, "discard_granularity must be 512 for ide"); - return; + goto out; } blkconf_blocksizes(&dev->conf); if (dev->conf.logical_block_size != 512) { error_setg(errp, "logical_block_size must be 512 for IDE"); - return; + goto out; } if (kind != 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 == IDE_CD, kind != IDE_CD, errp)) { - return; + goto out; } 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; } if (!dev->version) { @@ -215,6 +219,9 @@ static void ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind, Error **errp) add_boot_device_path(dev->conf.bootindex, &dev->qdev, dev->unit ? "/disk@1" : "/disk@0"); + +out: + aio_context_release(ctx); } static void ide_dev_get_bootindex(Object *obj, Visitor *v, const char *name,