From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595156640418.46952424972983; Wed, 19 Apr 2017 02:45:56 -0700 (PDT) Received: from localhost ([::1]:46709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mBP-00056t-6B for importer@patchew.org; Wed, 19 Apr 2017 05:45:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52167) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0m9k-0003mv-Ap for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0m9j-000599-HC for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55164) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0m9h-00055s-6Y; Wed, 19 Apr 2017 05:44:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1D9FD3B72D; Wed, 19 Apr 2017 09:44:08 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id B33CEC90BD; Wed, 19 Apr 2017 09:44:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D9FD3B72D Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D9FD3B72D From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:41 +0800 Message-Id: <20170419094356.19826-2-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 19 Apr 2017 09:44:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 01/16] block: Define BLK_PERM_AIO_CONTEXT_CHANGE 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block.c | 2 ++ include/block/block.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 1fbbb8d..5a3affb 100644 --- a/block.c +++ b/block.c @@ -1562,6 +1562,8 @@ static char *bdrv_perm_names(uint64_t perm) { BLK_PERM_WRITE_UNCHANGED, "write unchanged" }, { BLK_PERM_RESIZE, "resize" }, { BLK_PERM_GRAPH_MOD, "change children" }, + { BLK_PERM_AIO_CONTEXT_CHANGE, + "aio context change" }, { 0, NULL } }; =20 diff --git a/include/block/block.h b/include/block/block.h index 5ddc0cf..3c409a3 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -221,7 +221,12 @@ enum { */ BLK_PERM_GRAPH_MOD =3D 0x10, =20 - BLK_PERM_ALL =3D 0x1f, + /** + * This permission is required to change the AioContext of this node. + */ + BLK_PERM_AIO_CONTEXT_CHANGE =3D 0x20, + + BLK_PERM_ALL =3D 0x3f, }; =20 /* disk I/O throttling */ --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595315129375.6117840252771; Wed, 19 Apr 2017 02:48:35 -0700 (PDT) Received: from localhost ([::1]:46720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mDv-0007D9-N6 for importer@patchew.org; Wed, 19 Apr 2017 05:48:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52259) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0m9p-0003rj-At for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0m9m-0005C3-8R for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46772) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0m9k-000596-4x; Wed, 19 Apr 2017 05:44:12 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11CED8B976; Wed, 19 Apr 2017 09:44:11 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id C9BC5C90BD; Wed, 19 Apr 2017 09:44:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 11CED8B976 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 11CED8B976 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:42 +0800 Message-Id: <20170419094356.19826-3-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 19 Apr 2017 09:44:11 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 02/16] block-backend: Add blk_request_perm 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" This function tries to request, if not granted yet, for the given permissions. Signed-off-by: Fam Zheng --- block/block-backend.c | 12 ++++++++++++ include/sysemu/block-backend.h | 1 + 2 files changed, 13 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 7405024..6bdd9ce 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -629,6 +629,18 @@ void blk_resume_after_migration(Error **errp) } } =20 +int blk_request_perm(BlockBackend *blk, uint64_t perm, Error **errp) +{ + uint64_t blk_perm, shared_perm; + + blk_get_perm(blk, &blk_perm, &shared_perm); + if ((blk_perm & perm) =3D=3D perm) { + return 0; + } + blk_perm |=3D perm; + return blk_set_perm(blk, blk_perm, shared_perm, errp); +} + static int blk_do_attach_dev(BlockBackend *blk, void *dev) { if (blk->dev) { diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 7462228..537f92f 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -116,6 +116,7 @@ bool bdrv_is_root_node(BlockDriverState *bs); int blk_set_perm(BlockBackend *blk, uint64_t perm, uint64_t shared_perm, Error **errp); void blk_get_perm(BlockBackend *blk, uint64_t *perm, uint64_t *shared_perm= ); +int blk_request_perm(BlockBackend *blk, uint64_t perm, Error **errp); =20 void blk_set_allow_write_beyond_eof(BlockBackend *blk, bool allow); void blk_iostatus_enable(BlockBackend *blk); --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595318273584.5455212969835; Wed, 19 Apr 2017 02:48:38 -0700 (PDT) Received: from localhost ([::1]:46721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mE0-0007G1-U2 for importer@patchew.org; Wed, 19 Apr 2017 05:48:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0m9r-0003tR-4n for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0m9q-0005GZ-GZ for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0m9o-0005DZ-6z; Wed, 19 Apr 2017 05:44:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2A5F7C05973F; Wed, 19 Apr 2017 09:44:15 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D9877E224; Wed, 19 Apr 2017 09:44:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A5F7C05973F Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2A5F7C05973F From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:43 +0800 Message-Id: <20170419094356.19826-4-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Apr 2017 09:44:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 03/16] blockjob: Add BLK_PERM_AIO_CONTEXT_CHANGE shared perm on bs 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- blockjob.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/blockjob.c b/blockjob.c index 6e48932..b20fb86 100644 --- a/blockjob.c +++ b/blockjob.c @@ -214,6 +214,9 @@ void *block_job_create(const char *job_id, const BlockJ= obDriver *driver, } } =20 + /* The notifier we'll register on @blk takes care of following context + * change, so permit it. */ + shared_perm |=3D BLK_PERM_AIO_CONTEXT_CHANGE; blk =3D blk_new(perm, shared_perm); ret =3D blk_insert_bs(blk, bs, errp); if (ret < 0) { --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 149259532286033.307063520123165; Wed, 19 Apr 2017 02:48:42 -0700 (PDT) Received: from localhost ([::1]:46722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mE5-0007LO-F9 for importer@patchew.org; Wed, 19 Apr 2017 05:48:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0m9y-00040N-Tb for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0m9v-0005Jc-Rh for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41060) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0m9t-0005Hj-5O; Wed, 19 Apr 2017 05:44:21 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A5974E35B; Wed, 19 Apr 2017 09:44:20 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0C63C90BD; Wed, 19 Apr 2017 09:44:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A5974E35B Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1A5974E35B From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:44 +0800 Message-Id: <20170419094356.19826-5-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 19 Apr 2017 09:44:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 04/16] blockjob: Allow aio context change on intermediate nodes 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" The intermediate nodes do work with aio context change, so allow that operations. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/commit.c | 3 ++- block/mirror.c | 3 ++- block/stream.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/commit.c b/block/commit.c index 91d2c34..c07ee00 100644 --- a/block/commit.c +++ b/block/commit.c @@ -365,7 +365,8 @@ void commit_start(const char *job_id, BlockDriverState = *bs, * for its backing file). The other options would be a second filt= er * driver above s->base. */ ret =3D block_job_add_bdrv(&s->common, "intermediate node", iter, = 0, - BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE, + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE= | + BLK_PERM_AIO_CONTEXT_CHANGE, errp); if (ret < 0) { goto fail; diff --git a/block/mirror.c b/block/mirror.c index 164438f..7ab3289 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1231,7 +1231,8 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, * also blocked for its backing file). The other options would= be a * second filter driver above s->base (=3D=3D target). */ ret =3D block_job_add_bdrv(&s->common, "intermediate node", it= er, 0, - BLK_PERM_WRITE_UNCHANGED | BLK_PERM_W= RITE, + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_W= RITE | + BLK_PERM_AIO_CONTEXT_CHANGE, errp); if (ret < 0) { goto fail; diff --git a/block/stream.c b/block/stream.c index 0113710..2fab1f4 100644 --- a/block/stream.c +++ b/block/stream.c @@ -265,7 +265,8 @@ void stream_start(const char *job_id, BlockDriverState = *bs, * and resizes. */ for (iter =3D backing_bs(bs); iter && iter !=3D base; iter =3D backing= _bs(iter)) { block_job_add_bdrv(&s->common, "intermediate node", iter, 0, - BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHA= NGED, + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHA= NGED | + BLK_PERM_AIO_CONTEXT_CHANGE, &error_abort); } =20 --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595454411141.01313575146503; Wed, 19 Apr 2017 02:50:54 -0700 (PDT) Received: from localhost ([::1]:46736 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mGC-0000a4-Cu for importer@patchew.org; Wed, 19 Apr 2017 05:50:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mA2-00043U-2U for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mA0-0005N0-WD for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5517) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0m9y-0005LF-Me; Wed, 19 Apr 2017 05:44:26 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 97FEAC05AA52; Wed, 19 Apr 2017 09:44:25 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id B38467E224; Wed, 19 Apr 2017 09:44:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 97FEAC05AA52 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 97FEAC05AA52 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:45 +0800 Message-Id: <20170419094356.19826-6-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Apr 2017 09:44:25 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 05/16] block: Propagate BLK_PERM_AIO_CONTEXT_CHANGE down the graph 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" bdrv_set_aio_context can take care of children recursively, so it is okay to pass down the perm. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block.c | 10 ++++++---- block/vvfat.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index 5a3affb..7e696e5 100644 --- a/block.c +++ b/block.c @@ -1685,7 +1685,8 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t pe= rm, uint64_t shared, #define DEFAULT_PERM_PASSTHROUGH (BLK_PERM_CONSISTENT_READ \ | BLK_PERM_WRITE \ | BLK_PERM_WRITE_UNCHANGED \ - | BLK_PERM_RESIZE) + | BLK_PERM_RESIZE \ + | BLK_PERM_AIO_CONTEXT_CHANGE) #define DEFAULT_PERM_UNCHANGED (BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH) =20 void bdrv_filter_default_perms(BlockDriverState *bs, BdrvChild *c, @@ -1728,9 +1729,10 @@ void bdrv_format_default_perms(BlockDriverState *bs,= BdrvChild *c, perm |=3D BLK_PERM_CONSISTENT_READ; shared &=3D ~(BLK_PERM_WRITE | BLK_PERM_RESIZE); } else { - /* We want consistent read from backing files if the parent needs = it. + /* We want consistent read and aio context change from backing fil= es if + * the parent needs it. * No other operations are performed on backing files. */ - perm &=3D BLK_PERM_CONSISTENT_READ; + perm &=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_AIO_CONTEXT_CHANGE; =20 /* If the parent can deal with changing data, we're okay with a * writable and resizable backing file. */ @@ -1742,7 +1744,7 @@ void bdrv_format_default_perms(BlockDriverState *bs, = BdrvChild *c, } =20 shared |=3D BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD | - BLK_PERM_WRITE_UNCHANGED; + BLK_PERM_WRITE_UNCHANGED | BLK_PERM_AIO_CONTEXT_CHANGE; } =20 *nperm =3D perm; diff --git a/block/vvfat.c b/block/vvfat.c index af5153d..70ce452 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3080,7 +3080,7 @@ static void vvfat_child_perm(BlockDriverState *bs, Bd= rvChild *c, if (c =3D=3D s->qcow) { /* This is a private node, nobody should try to attach to it */ *nperm =3D BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE; - *nshared =3D BLK_PERM_WRITE_UNCHANGED; + *nshared =3D BLK_PERM_WRITE_UNCHANGED | BLK_PERM_AIO_CONTEXT_CHANG= E; } else { /* The backing file is there so 'commit' can use it. vvfat doesn't * access it in any way. */ --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595471205567.5350424282301; Wed, 19 Apr 2017 02:51:11 -0700 (PDT) Received: from localhost ([::1]:46738 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mGT-0000nh-Ly for importer@patchew.org; Wed, 19 Apr 2017 05:51:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mA7-00047m-0Y for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mA3-0005PQ-Uz for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39706) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mA1-0005NA-P4; Wed, 19 Apr 2017 05:44:29 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A75392E6059; Wed, 19 Apr 2017 09:44:28 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C10BC90BD; Wed, 19 Apr 2017 09:44:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A75392E6059 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A75392E6059 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:46 +0800 Message-Id: <20170419094356.19826-7-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 19 Apr 2017 09:44:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 06/16] backup: Request BLK_PERM_AIO_CONTEXT_CHANGE on target 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" What's done in the source's context change notifier is moving the target's context to follow the new one, so we request this permission here. Signed-off-by: Fam Zheng --- block/backup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/backup.c b/block/backup.c index a4fb288..546c5c5 100644 --- a/block/backup.c +++ b/block/backup.c @@ -636,7 +636,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, } =20 /* The target must match the source in size, so no resize here either = */ - job->target =3D blk_new(BLK_PERM_WRITE, + job->target =3D blk_new(BLK_PERM_WRITE | BLK_PERM_AIO_CONTEXT_CHANGE, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE | BLK_PERM_WRITE_UNCHANGED | BLK_PERM_GRAPH_MOD); ret =3D blk_insert_bs(job->target, target, errp); --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595459623421.3696032906929; Wed, 19 Apr 2017 02:50:59 -0700 (PDT) Received: from localhost ([::1]:46737 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mGI-0000dq-73 for importer@patchew.org; Wed, 19 Apr 2017 05:50:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAA-0004Bo-0m for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mA8-0005TH-UF for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38166) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mA6-0005Qa-72; Wed, 19 Apr 2017 05:44:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FC448AE73; Wed, 19 Apr 2017 09:44:33 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4ADD818A42; Wed, 19 Apr 2017 09:44:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FC448AE73 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1FC448AE73 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:47 +0800 Message-Id: <20170419094356.19826-8-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Apr 2017 09:44:33 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 07/16] backup: Do initial aio context move of target via BB interface 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" The old aio context check is hacky because when it was added we didn't have the permission system to enforce a general rule. It only checks if the target BDS has a BB, which is in fact insufficient because there may be other BBs in the graph that cannot handle the aio context change. Do this through blk_set_aio_context interface, in backup_job_create() which is a central place for both drive-backup and blockdev-backup, to take care of the compatibility check. Also the bdrv_set_aio_context in do_drive_backup could have been conditional, to save a recursion when possible. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/backup.c | 9 +++++++++ blockdev.c | 14 -------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/block/backup.c b/block/backup.c index 546c5c5..9136f91 100644 --- a/block/backup.c +++ b/block/backup.c @@ -564,6 +564,7 @@ BlockJob *backup_job_create(const char *job_id, BlockDr= iverState *bs, BlockDriverInfo bdi; BackupBlockJob *job =3D NULL; int ret; + AioContext *aio_context, *target_context; =20 assert(bs); assert(target); @@ -644,6 +645,14 @@ BlockJob *backup_job_create(const char *job_id, BlockD= riverState *bs, goto error; } =20 + aio_context =3D bdrv_get_aio_context(bs); + target_context =3D bdrv_get_aio_context(target); + if (target_context !=3D aio_context) { + aio_context_acquire(target_context); + blk_set_aio_context(job->target, aio_context); + aio_context_release(target_context); + } + job->on_source_error =3D on_source_error; job->on_target_error =3D on_target_error; job->sync_mode =3D sync_mode; diff --git a/blockdev.c b/blockdev.c index 4927914..dfd1385 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3259,8 +3259,6 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, goto out; } =20 - bdrv_set_aio_context(target_bs, aio_context); - if (backup->has_bitmap) { bmap =3D bdrv_find_dirty_bitmap(bs, backup->bitmap); if (!bmap) { @@ -3337,18 +3335,6 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup,= BlockJobTxn *txn, if (!target_bs) { goto out; } - - if (bdrv_get_aio_context(target_bs) !=3D aio_context) { - if (!bdrv_has_blk(target_bs)) { - /* The target BDS is not attached, we can safely move it to an= other - * AioContext. */ - bdrv_set_aio_context(target_bs, aio_context); - } else { - error_setg(errp, "Target is attached to a different thread fro= m " - "source."); - goto out; - } - } job =3D backup_job_create(backup->job_id, bs, target_bs, backup->speed, backup->sync, NULL, backup->compress, backup->on_source_error, backup->on_target_err= or, --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595600420816.416826547446; Wed, 19 Apr 2017 02:53:20 -0700 (PDT) Received: from localhost ([::1]:46749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mIY-0002RG-W5 for importer@patchew.org; Wed, 19 Apr 2017 05:53:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAK-0004Lp-V1 for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAK-0005al-7O for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41272) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAC-0005VJ-QB; Wed, 19 Apr 2017 05:44:40 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B71A64ACB6; Wed, 19 Apr 2017 09:44:39 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE017C90BD; Wed, 19 Apr 2017 09:44:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B71A64ACB6 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B71A64ACB6 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:48 +0800 Message-Id: <20170419094356.19826-9-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 19 Apr 2017 09:44:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 08/16] mirror: Request aio context change permission on target 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" What's done in the source's context change notifier is moving the target's context to follow the new one, so we request this permission here. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/mirror.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/mirror.c b/block/mirror.c index 7ab3289..fe2fb7a 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1189,6 +1189,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, target_is_backing =3D bdrv_chain_contains(bs, target); target_graph_mod =3D (backing_mode !=3D MIRROR_LEAVE_BACKING_CHAIN); s->target =3D blk_new(BLK_PERM_WRITE | BLK_PERM_RESIZE | + BLK_PERM_AIO_CONTEXT_CHANGE | (target_graph_mod ? BLK_PERM_GRAPH_MOD : 0), BLK_PERM_WRITE_UNCHANGED | (target_is_backing ? BLK_PERM_CONSISTENT_READ | --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595259124597.6976258652727; Wed, 19 Apr 2017 02:47:39 -0700 (PDT) Received: from localhost ([::1]:46719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mD3-0006SB-Ko for importer@patchew.org; Wed, 19 Apr 2017 05:47:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAJ-0004KM-EH for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAI-0005Ze-Oa for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39016) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAG-0005XW-Q7; Wed, 19 Apr 2017 05:44:44 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A1E797D0DE; Wed, 19 Apr 2017 09:44:43 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A1547E226; Wed, 19 Apr 2017 09:44:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A1E797D0DE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A1E797D0DE From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:49 +0800 Message-Id: <20170419094356.19826-10-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 19 Apr 2017 09:44:43 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 09/16] commit: Allow aio context change on s->base 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" The block job has the aio context change notifier, we should allow it here as well. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index c07ee00..1241dd3 100644 --- a/block/commit.c +++ b/block/commit.c @@ -391,7 +391,8 @@ void commit_start(const char *job_id, BlockDriverState = *bs, | BLK_PERM_RESIZE, BLK_PERM_CONSISTENT_READ | BLK_PERM_GRAPH_MOD - | BLK_PERM_WRITE_UNCHANGED); + | BLK_PERM_WRITE_UNCHANGED + | BLK_PERM_AIO_CONTEXT_CHANGE); ret =3D blk_insert_bs(s->base, base, errp); if (ret < 0) { goto fail; --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 149259559196437.40944983063355; Wed, 19 Apr 2017 02:53:11 -0700 (PDT) Received: from localhost ([::1]:46747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mIQ-0002KN-Iz for importer@patchew.org; Wed, 19 Apr 2017 05:53:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52743) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAP-0004PW-7o for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAM-0005cY-5r for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAJ-0005Zo-F5; Wed, 19 Apr 2017 05:44:47 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63B3231F3E2; Wed, 19 Apr 2017 09:44:46 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 40ADCC90BD; Wed, 19 Apr 2017 09:44:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 63B3231F3E2 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 63B3231F3E2 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:50 +0800 Message-Id: <20170419094356.19826-11-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 19 Apr 2017 09:44:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 10/16] mirror: Do initial aio context move of target via BB interface 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" While blockdev-backup tried to verify before moving target's aio context, t= he same is missing for blockdev-mirror. Now that we have the right interface, = fix this as well. As a bonus, the aio context move is now conditional, which avoids some unnecessary operations in bdrv_set_aio_context. Signed-off-by: Fam Zheng --- block/mirror.c | 9 +++++++++ blockdev.c | 4 ---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index fe2fb7a..2a287b0 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1117,6 +1117,7 @@ static void mirror_start_job(const char *job_id, Bloc= kDriverState *bs, bool is_none_mode, BlockDriverState *base, bool auto_complete, const char *filter_node_n= ame) { + AioContext *aio_context, *target_context; MirrorBlockJob *s; BlockDriverState *mirror_top_bs; bool target_graph_mod; @@ -1200,6 +1201,14 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, goto fail; } =20 + aio_context =3D bdrv_get_aio_context(bs); + target_context =3D bdrv_get_aio_context(target); + if (target_context !=3D aio_context) { + aio_context_acquire(target_context); + blk_set_aio_context(s->target, aio_context); + aio_context_release(target_context); + } + s->replaces =3D g_strdup(replaces); s->on_source_error =3D on_source_error; s->on_target_error =3D on_target_error; diff --git a/blockdev.c b/blockdev.c index dfd1385..53f9874 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3556,8 +3556,6 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) goto out; } =20 - bdrv_set_aio_context(target_bs, aio_context); - blockdev_mirror_common(arg->has_job_id ? arg->job_id : NULL, bs, targe= t_bs, arg->has_replaces, arg->replaces, arg->sync, backing_mode, arg->has_speed, arg->speed, @@ -3608,8 +3606,6 @@ void qmp_blockdev_mirror(bool has_job_id, const char = *job_id, aio_context =3D bdrv_get_aio_context(bs); aio_context_acquire(aio_context); =20 - bdrv_set_aio_context(target_bs, aio_context); - blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs, has_replaces, replaces, sync, backing_mode, has_speed, speed, --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595736656986.8451769482795; Wed, 19 Apr 2017 02:55:36 -0700 (PDT) Received: from localhost ([::1]:46763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mKl-0004ax-C6 for importer@patchew.org; Wed, 19 Apr 2017 05:55:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAV-0004V6-FJ for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAU-0005gY-Oe for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:44:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41452) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAS-0005fF-L9; Wed, 19 Apr 2017 05:44:56 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D2B62D8EA3; Wed, 19 Apr 2017 09:44:55 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 243BF7E211; Wed, 19 Apr 2017 09:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D2B62D8EA3 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 7D2B62D8EA3 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:51 +0800 Message-Id: <20170419094356.19826-12-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 19 Apr 2017 09:44:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 11/16] virtio-scsi: Request BLK_PERM_AIO_CONTEXT_CHANGE for dataplane 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" blk_set_aio_context is audited by perm API, so follow the protocol and request for permission first. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- hw/scsi/virtio-scsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index bd62d08..d130ba3 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -794,6 +794,10 @@ static void virtio_scsi_hotplug(HotplugHandler *hotplu= g_dev, DeviceState *dev, return; } virtio_scsi_acquire(s); + if (!blk_request_perm(sd->conf.blk, BLK_PERM_AIO_CONTEXT_CHANGE, e= rrp)) { + virtio_scsi_release(s); + return; + } blk_set_aio_context(sd->conf.blk, s->ctx); virtio_scsi_release(s); =20 --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595840326297.2757886665023; Wed, 19 Apr 2017 02:57:20 -0700 (PDT) Received: from localhost ([::1]:46777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mMQ-0005yb-Fd for importer@patchew.org; Wed, 19 Apr 2017 05:57:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAf-0004h7-Rd for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAZ-0005k5-WE for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53338) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAX-0005hP-50; Wed, 19 Apr 2017 05:45:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 130CD4AEBE; Wed, 19 Apr 2017 09:45:00 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B5B218A42; Wed, 19 Apr 2017 09:44:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 130CD4AEBE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 130CD4AEBE From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:52 +0800 Message-Id: <20170419094356.19826-13-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 19 Apr 2017 09:45:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 12/16] virtio-blk: Request BLK_PERM_AIO_CONTEXT_CHANGE for dataplane 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" blk_set_aio_context is audited by perm API, so follow the protocol and request for permission first. Previously the return code in error path was hardcoded as -EPERM, but returning 'r' is more meaningful here both for the new error and existing ones. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- hw/block/dataplane/virtio-blk.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index 5556f0e..8f2ff2df 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -168,6 +168,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) unsigned i; unsigned nvqs =3D s->conf->num_queues; int r; + Error *local_err =3D NULL; =20 if (vblk->dataplane_started || s->starting) { return 0; @@ -175,12 +176,18 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) =20 s->starting =3D true; =20 + r =3D blk_request_perm(s->conf->conf.blk, BLK_PERM_AIO_CONTEXT_CHANGE, + &local_err); + if (r) { + error_report_err(local_err); + goto fail; + } /* Set up guest notifier (irq) */ r =3D k->set_guest_notifiers(qbus->parent, nvqs, true); if (r !=3D 0) { fprintf(stderr, "virtio-blk failed to set guest notifier (%d), " "ensure -enable-kvm is set\n", r); - goto fail_guest_notifiers; + goto fail; } =20 /* Set up virtqueue notify */ @@ -191,7 +198,7 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) while (i--) { virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false); } - goto fail_guest_notifiers; + goto fail; } } =20 @@ -219,11 +226,11 @@ int virtio_blk_data_plane_start(VirtIODevice *vdev) aio_context_release(s->ctx); return 0; =20 - fail_guest_notifiers: +fail: vblk->dataplane_disabled =3D true; s->starting =3D false; vblk->dataplane_started =3D true; - return -ENOSYS; + return r; } =20 /* Context: QEMU global mutex held */ --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595610653761.7025594877979; Wed, 19 Apr 2017 02:53:30 -0700 (PDT) Received: from localhost ([::1]:46750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mIj-0002b8-3S for importer@patchew.org; Wed, 19 Apr 2017 05:53:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAk-0004nS-HC for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAj-0005va-Nj for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41656) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAf-0005qC-9s; Wed, 19 Apr 2017 05:45:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26E74C05AA66; Wed, 19 Apr 2017 09:45:08 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 838E118A42; Wed, 19 Apr 2017 09:45:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 26E74C05AA66 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 26E74C05AA66 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:53 +0800 Message-Id: <20170419094356.19826-14-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 19 Apr 2017 09:45:08 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 13/16] blk: fix aio context loss on media change 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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: Vladimir Sementsov-Ogievskiy If we have separate iothread for cdrom, we lose connection to it on qmp_blockdev_change_medium, as aio_context is on bds which is dropped and switched with new one. As an example result, after such media change we have crash on virtio_scsi_ctx_check: Assertion `blk_get_aio_context(d->conf.blk) =3D=3D s= ->ctx' failed. Signed-off-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/block-backend.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 6bdd9ce..6133917 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -68,6 +68,7 @@ struct BlockBackend { NotifierList remove_bs_notifiers, insert_bs_notifiers; =20 int quiesce_counter; + AioContext *aio_context; }; =20 typedef struct BlockBackendAIOCB { @@ -565,6 +566,10 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState = *bs, Error **errp) } bdrv_ref(bs); =20 + if (blk->aio_context !=3D NULL) { + bdrv_set_aio_context(bs, blk->aio_context); + } + notifier_list_notify(&blk->insert_bs_notifiers, blk); if (blk->public.throttle_state) { throttle_timers_attach_aio_context( @@ -1667,6 +1672,7 @@ void blk_set_aio_context(BlockBackend *blk, AioContex= t *new_context) { BlockDriverState *bs =3D blk_bs(blk); =20 + blk->aio_context =3D new_context; if (bs) { if (blk->public.throttle_state) { throttle_timers_detach_aio_context(&blk->public.throttle_timer= s); --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595744081248.83030625429444; Wed, 19 Apr 2017 02:55:44 -0700 (PDT) Received: from localhost ([::1]:46764 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mKs-0004hJ-PZ for importer@patchew.org; Wed, 19 Apr 2017 05:55:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAm-0004pJ-Ch for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAl-0005y8-LE for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAj-0005ui-GW; Wed, 19 Apr 2017 05:45:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62278C04BD37; Wed, 19 Apr 2017 09:45:12 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAA6918A42; Wed, 19 Apr 2017 09:45:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 62278C04BD37 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 62278C04BD37 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:54 +0800 Message-Id: <20170419094356.19826-15-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 19 Apr 2017 09:45:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 14/16] nbd: Allow BLK_PERM_AIO_CONTEXT_CHANGE on BB 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" This is safe because of the aio context notifier we'll register on this node. So allow it. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- nbd/server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 924a1fe..a8f58fb 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -900,8 +900,10 @@ NBDExport *nbd_export_new(BlockDriverState *bs, off_t = dev_offset, off_t size, if ((nbdflags & NBD_FLAG_READ_ONLY) =3D=3D 0) { perm |=3D BLK_PERM_WRITE; } - blk =3D blk_new(perm, BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHAN= GED | - BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD); + blk =3D blk_new(perm, + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED | + BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD | + BLK_PERM_AIO_CONTEXT_CHANGE); ret =3D blk_insert_bs(blk, bs, errp); if (ret < 0) { goto fail; --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595849028321.9438413316059; Wed, 19 Apr 2017 02:57:29 -0700 (PDT) Received: from localhost ([::1]:46778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mMZ-00065n-Q0 for importer@patchew.org; Wed, 19 Apr 2017 05:57:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAw-0004xu-7q for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAv-00067G-Hu for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAm-0005xx-6m; Wed, 19 Apr 2017 05:45:16 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 207077F3EC; Wed, 19 Apr 2017 09:45:15 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D4ED18A42; Wed, 19 Apr 2017 09:45:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 207077F3EC Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 207077F3EC From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:55 +0800 Message-Id: <20170419094356.19826-16-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 19 Apr 2017 09:45:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 15/16] block: Add perm assertion on blk_set_aio_context 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" Now that all BB users comply with the BLK_PERM_AIO_CONTEXT_CHANGE rule, we can assert it. Signed-off-by: Fam Zheng Reviewed-by: Stefan Hajnoczi --- block/block-backend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 6133917..166edac 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1670,8 +1670,12 @@ static AioContext *blk_aiocb_get_aio_context(BlockAI= OCB *acb) =20 void blk_set_aio_context(BlockBackend *blk, AioContext *new_context) { + uint64_t perm, shared_perm; BlockDriverState *bs =3D blk_bs(blk); =20 + blk_get_perm(blk, &perm, &shared_perm); + assert(perm & BLK_PERM_AIO_CONTEXT_CHANGE); + blk->aio_context =3D new_context; if (bs) { if (blk->public.throttle_state) { --=20 2.9.3 From nobody Sun May 5 14:31:54 2024 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.zoho.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 1492595747984469.5668189311792; Wed, 19 Apr 2017 02:55:47 -0700 (PDT) Received: from localhost ([::1]:46765 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mKw-0004ju-Kr for importer@patchew.org; Wed, 19 Apr 2017 05:55:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d0mAx-0004zV-QD for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d0mAw-00068a-Qw for qemu-devel@nongnu.org; Wed, 19 Apr 2017 05:45:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47804) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d0mAs-00063c-1T; Wed, 19 Apr 2017 05:45:22 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EC62280F9E; Wed, 19 Apr 2017 09:45:20 +0000 (UTC) Received: from lemon.redhat.com (ovpn-8-64.pek2.redhat.com [10.72.8.64]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9440518A42; Wed, 19 Apr 2017 09:45:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EC62280F9E Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EC62280F9E From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 19 Apr 2017 17:43:56 +0800 Message-Id: <20170419094356.19826-17-famz@redhat.com> In-Reply-To: <20170419094356.19826-1-famz@redhat.com> References: <20170419094356.19826-1-famz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 19 Apr 2017 09:45:21 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 16/16] tests: Add test case for BLK_PERM_AIO_CONTEXT_CHANGE 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 , qemu-block@nongnu.org, Stefan Hajnoczi , Max Reitz 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" Signed-off-by: Fam Zheng --- tests/Makefile.include | 2 ++ tests/test-blk-perm.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 61 insertions(+) create mode 100644 tests/test-blk-perm.c diff --git a/tests/Makefile.include b/tests/Makefile.include index f3de81f..b38e090 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -56,6 +56,7 @@ gcov-files-test-thread-pool-y =3D thread-pool.c gcov-files-test-hbitmap-y =3D util/hbitmap.c check-unit-y +=3D tests/test-hbitmap$(EXESUF) gcov-files-test-hbitmap-y =3D blockjob.c +check-unit-y +=3D tests/test-blk-perm$(EXESUF) check-unit-y +=3D tests/test-blockjob$(EXESUF) check-unit-y +=3D tests/test-blockjob-txn$(EXESUF) check-unit-y +=3D tests/test-x86-cpuid$(EXESUF) @@ -543,6 +544,7 @@ tests/test-coroutine$(EXESUF): tests/test-coroutine.o $= (test-block-obj-y) tests/test-aio$(EXESUF): tests/test-aio.o $(test-block-obj-y) tests/test-aio-multithread$(EXESUF): tests/test-aio-multithread.o $(test-b= lock-obj-y) tests/test-throttle$(EXESUF): tests/test-throttle.o $(test-block-obj-y) +tests/test-blk-perm$(EXESUF): tests/test-blk-perm.o $(test-block-obj-y) tests/test-blockjob$(EXESUF): tests/test-blockjob.o $(test-block-obj-y) $(= test-util-obj-y) tests/test-blockjob-txn$(EXESUF): tests/test-blockjob-txn.o $(test-block-o= bj-y) $(test-util-obj-y) tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj= -y) diff --git a/tests/test-blk-perm.c b/tests/test-blk-perm.c new file mode 100644 index 0000000..d6129ab --- /dev/null +++ b/tests/test-blk-perm.c @@ -0,0 +1,59 @@ +/* + * Block permission tests + * + * Copyright Red Hat, Inc. 2017 + * + * Authors: + * Fam Zheng + * + * This work is licensed under the terms of the GNU LGPL, version 2 or lat= er. + * See the COPYING.LIB file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "sysemu/block-backend.h" + +static void test_aio_context_success(void) +{ + BlockBackend *blk1 =3D blk_new(BLK_PERM_AIO_CONTEXT_CHANGE, BLK_PERM_A= LL); + BlockBackend *blk2 =3D blk_new(BLK_PERM_AIO_CONTEXT_CHANGE, BLK_PERM_A= LL); + BlockDriverState *bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error= _abort); + + blk_insert_bs(blk1, bs, &error_abort); + blk_insert_bs(blk2, bs, &error_abort); + + blk_unref(blk1); + blk_unref(blk2); + bdrv_unref(bs); +} + +static void test_aio_context_failure(void) +{ + Error *local_err =3D NULL; + BlockBackend *blk1 =3D blk_new(BLK_PERM_AIO_CONTEXT_CHANGE, + BLK_PERM_ALL & ~BLK_PERM_AIO_CONTEXT_CHAN= GE); + BlockBackend *blk2 =3D blk_new(BLK_PERM_AIO_CONTEXT_CHANGE, BLK_PERM_A= LL); + BlockDriverState *bs =3D bdrv_open("null-co://", NULL, NULL, 0, &error= _abort); + + blk_insert_bs(blk1, bs, &error_abort); + blk_insert_bs(blk2, bs, &local_err); + + g_assert_nonnull(local_err); + + blk_unref(blk1); + blk_unref(blk2); + bdrv_unref(bs); +} + +int main(int argc, char **argv) +{ + bdrv_init(); + qemu_init_main_loop(&error_abort); + g_test_init(&argc, &argv, NULL); + g_test_add_func("/block/perm/aio-context/success", + test_aio_context_success); + g_test_add_func("/block/perm/aio-context/failure", + test_aio_context_failure); + return g_test_run(); +} --=20 2.9.3