From nobody Wed May 1 10:50:07 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 1495594478597894.269464257827; Tue, 23 May 2017 19:54:38 -0700 (PDT) Received: from localhost ([::1]:52362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMRY-0001Lu-Fd for importer@patchew.org; Tue, 23 May 2017 22:54:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMPq-0000CN-9P for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMPp-0006hz-MD for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38264) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMPn-0006g6-7O; Tue, 23 May 2017 22:52: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 2A07C80C13; Wed, 24 May 2017 02:52:46 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E8075C6CD; Wed, 24 May 2017 02:52:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2A07C80C13 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 2A07C80C13 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:20 +0800 Message-Id: <20170524025235.32190-2-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:52: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 v3 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 --- block.c | 2 ++ include/block/block.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 50ba264..d98662f 100644 --- a/block.c +++ b/block.c @@ -1649,6 +1649,8 @@ 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 9b355e9..017d6c8 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -225,7 +225,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 char *bdrv_perm_names(uint64_t perm); --=20 2.9.4 From nobody Wed May 1 10:50:07 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 1495594761142902.0318300223458; Tue, 23 May 2017 19:59:21 -0700 (PDT) Received: from localhost ([::1]:52384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMW7-0005Pv-Rn for importer@patchew.org; Tue, 23 May 2017 22:59:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMPw-0000Hr-1B for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMPt-0006mm-0x for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMPr-0006iR-0X; Tue, 23 May 2017 22:52:51 -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 EF081285C1; Wed, 24 May 2017 02:52:49 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5DB25C6CD; Wed, 24 May 2017 02:52:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EF081285C1 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 EF081285C1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:21 +0800 Message-Id: <20170524025235.32190-3-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:52:50 +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 v3 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 Reviewed-by: Stefan Hajnoczi --- 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 f3a6008..5492f64 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -654,6 +654,18 @@ void blk_get_perm(BlockBackend *blk, uint64_t *perm, u= int64_t *shared_perm) *shared_perm =3D blk->shared_perm; } =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 840ad61..fc23a9e 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.4 From nobody Wed May 1 10:50:07 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 1495594882534602.5083247428643; Tue, 23 May 2017 20:01:22 -0700 (PDT) Received: from localhost ([::1]:52405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMY4-00073S-R1 for importer@patchew.org; Tue, 23 May 2017 23:01:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33990) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMPx-0000Kw-Qm for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMPx-0006pR-2T for qemu-devel@nongnu.org; Tue, 23 May 2017 22:52:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMPv-0006n2-83; Tue, 23 May 2017 22:52:55 -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 076B8C057FAB; Wed, 24 May 2017 02:52:54 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 843C05C6CD; Wed, 24 May 2017 02:52:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 076B8C057FAB 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 076B8C057FAB From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:22 +0800 Message-Id: <20170524025235.32190-4-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:52:54 +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 v3 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 --- 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.4 From nobody Wed May 1 10:50:07 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 1495594499322367.04909710309437; Tue, 23 May 2017 19:54:59 -0700 (PDT) Received: from localhost ([::1]:52363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMRt-0001cv-U9 for importer@patchew.org; Tue, 23 May 2017 22:54:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQ5-0000RC-MO for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQ2-0006sm-K4 for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45002) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQ0-0006qA-GA; Tue, 23 May 2017 22:53:00 -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 69BBD83F46; Wed, 24 May 2017 02:52:59 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99B1F19E96; Wed, 24 May 2017 02:52:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 69BBD83F46 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 69BBD83F46 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:23 +0800 Message-Id: <20170524025235.32190-5-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:52:59 +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 v3 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 --- 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 76a0d98..e2ee0ff 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 e86f8f8..03e82eb 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1232,7 +1232,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.4 From nobody Wed May 1 10:50:07 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 1495594505691798.7268080258252; Tue, 23 May 2017 19:55:05 -0700 (PDT) Received: from localhost ([::1]:52364 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMRz-0001gM-Vx for importer@patchew.org; Tue, 23 May 2017 22:55:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQ7-0000SN-Uh for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQ7-0006wj-13 for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:08 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38448) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQ3-0006st-LP; Tue, 23 May 2017 22:53:03 -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 8A64E80C13; Wed, 24 May 2017 02:53:02 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57E9518B56; Wed, 24 May 2017 02:52:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 8A64E80C13 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 8A64E80C13 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:24 +0800 Message-Id: <20170524025235.32190-6-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:02 +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 v3 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 --- block.c | 10 ++++++---- block/vvfat.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/block.c b/block.c index d98662f..1e5eae7 100644 --- a/block.c +++ b/block.c @@ -1772,7 +1772,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, @@ -1815,9 +1816,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. */ @@ -1829,7 +1831,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 if (bs->open_flags & BDRV_O_INACTIVE) { diff --git a/block/vvfat.c b/block/vvfat.c index 426ca70..599a370 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3091,7 +3091,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.4 From nobody Wed May 1 10:50:07 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 1495594646204945.7624923125843; Tue, 23 May 2017 19:57:26 -0700 (PDT) Received: from localhost ([::1]:52378 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMUH-0003gq-0u for importer@patchew.org; Tue, 23 May 2017 22:57:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34083) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQA-0000V4-I5 for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQ9-0006yj-Qo for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37700) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQ7-0006wn-OG; Tue, 23 May 2017 22:53:07 -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 9D1D24E4CB; Wed, 24 May 2017 02:53:06 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FF605C6CD; Wed, 24 May 2017 02:53:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9D1D24E4CB 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 9D1D24E4CB From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:25 +0800 Message-Id: <20170524025235.32190-7-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:06 +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 v3 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.4 From nobody Wed May 1 10:50:07 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 1495594651577586.8583483188346; Tue, 23 May 2017 19:57:31 -0700 (PDT) Received: from localhost ([::1]:52379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMUM-0003o1-AU for importer@patchew.org; Tue, 23 May 2017 22:57:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQJ-0000be-3F for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQI-00071m-4t for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQD-00070N-CP; Tue, 23 May 2017 22:53: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 44A533B74D; Wed, 24 May 2017 02:53:12 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3861E18B54; Wed, 24 May 2017 02:53:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 44A533B74D 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 44A533B74D From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:26 +0800 Message-Id: <20170524025235.32190-8-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53: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 v3 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 --- 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 c63f4e8..e8f72a1 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3240,8 +3240,6 @@ static BlockJob *do_drive_backup(DriveBackup *backup,= BlockJobTxn *txn, goto out; } =20 - bdrv_set_aio_context(target_bs, aio_context); - if (set_backing_hd) { bdrv_set_backing_hd(target_bs, source, &local_err); if (local_err) { @@ -3326,18 +3324,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.4 From nobody Wed May 1 10:50:07 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 1495594770492901.7987745763844; Tue, 23 May 2017 19:59:30 -0700 (PDT) Received: from localhost ([::1]:52385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMWH-0005XP-4z for importer@patchew.org; Tue, 23 May 2017 22:59:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQK-0000dI-KI for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQK-00072S-0y for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51158) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQI-00071V-0A; Tue, 23 May 2017 22:53:18 -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 DF98580472; Wed, 24 May 2017 02:53:16 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id C6BF518AD5; Wed, 24 May 2017 02:53:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DF98580472 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DF98580472 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:27 +0800 Message-Id: <20170524025235.32190-9-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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.28]); Wed, 24 May 2017 02:53:17 +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 v3 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 --- block/mirror.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/mirror.c b/block/mirror.c index 03e82eb..a3337ee 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1190,6 +1190,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.4 From nobody Wed May 1 10:50:07 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 1495594775353897.9565496039692; Tue, 23 May 2017 19:59:35 -0700 (PDT) Received: from localhost ([::1]:52386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMWM-0005bn-2A for importer@patchew.org; Tue, 23 May 2017 22:59:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQQ-0000hw-Sl for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQN-00073n-SE for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQK-00072Y-OV; Tue, 23 May 2017 22:53:20 -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 A0B46285C1; Wed, 24 May 2017 02:53:19 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7537D5C6CE; Wed, 24 May 2017 02:53:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A0B46285C1 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 A0B46285C1 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:28 +0800 Message-Id: <20170524025235.32190-10-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:19 +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 v3 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 --- block/commit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index e2ee0ff..bbf7768 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.4 From nobody Wed May 1 10:50:07 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 1495595058645562.8046404062861; Tue, 23 May 2017 20:04:18 -0700 (PDT) Received: from localhost ([::1]:52419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMav-0000vQ-3S for importer@patchew.org; Tue, 23 May 2017 23:04:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQT-0000k9-E3 for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQS-00075Y-CP for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:29956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQO-00073g-4N; Tue, 23 May 2017 22:53:24 -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 13B4E80479; Wed, 24 May 2017 02:53:23 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5AC7918AD5; Wed, 24 May 2017 02:53:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13B4E80479 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 13B4E80479 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:29 +0800 Message-Id: <20170524025235.32190-11-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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.28]); Wed, 24 May 2017 02:53:23 +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 v3 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 Reviewed-by: Stefan Hajnoczi --- block/mirror.c | 54 ++++++++++++++++++++++++++++++++---------------------- blockdev.c | 4 ---- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index a3337ee..4eccb8d 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1118,13 +1118,44 @@ static void mirror_start_job(const char *job_id, Bl= ockDriverState *bs, bool auto_complete, const char *filter_node_n= ame, Error **errp) { + AioContext *aio_context, *target_context; MirrorBlockJob *s; BlockDriverState *mirror_top_bs; + BlockBackend *target_blk; bool target_graph_mod; bool target_is_backing; Error *local_err =3D NULL; int ret; =20 + /* No resize for the target either; while the mirror is still running,= a + * consistent read isn't necessarily possible. We could possibly allow + * writes and graph modifications, though it would likely defeat the + * purpose of a mirror, so leave them blocked for now. + * + * In the case of active commit, things look a bit different, though, + * because the target is an already populated backing file in active u= se. + * We can allow anything except resize there.*/ + target_is_backing =3D bdrv_chain_contains(bs, target); + target_graph_mod =3D (backing_mode !=3D MIRROR_LEAVE_BACKING_CHAIN); + target_blk =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 | + BLK_PERM_WRITE | + BLK_PERM_GRAPH_MOD : 0)); + ret =3D blk_insert_bs(target_blk, target, errp); + if (ret < 0) { + blk_unref(target_blk); + return; + } + 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(target_blk, aio_context); + aio_context_release(target_context); + } if (granularity =3D=3D 0) { granularity =3D bdrv_get_default_bitmap_granularity(target); } @@ -1179,28 +1210,7 @@ static void mirror_start_job(const char *job_id, Blo= ckDriverState *bs, s->source =3D bs; s->mirror_top_bs =3D mirror_top_bs; =20 - /* No resize for the target either; while the mirror is still running,= a - * consistent read isn't necessarily possible. We could possibly allow - * writes and graph modifications, though it would likely defeat the - * purpose of a mirror, so leave them blocked for now. - * - * In the case of active commit, things look a bit different, though, - * because the target is an already populated backing file in active u= se. - * We can allow anything except resize there.*/ - 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 | - BLK_PERM_WRITE | - BLK_PERM_GRAPH_MOD : 0)); - ret =3D blk_insert_bs(s->target, target, errp); - if (ret < 0) { - goto fail; - } - + s->target =3D target_blk; 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 e8f72a1..52d81c4 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3545,8 +3545,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, @@ -3597,8 +3595,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.4 From nobody Wed May 1 10:50:07 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 1495594911899157.03300453528664; Tue, 23 May 2017 20:01:51 -0700 (PDT) Received: from localhost ([::1]:52407 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMYY-0007Nv-Fs for importer@patchew.org; Tue, 23 May 2017 23:01:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQU-0000kh-KD for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQT-00076L-Uh for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59874) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQS-000756-1L; Tue, 23 May 2017 22:53:28 -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 E3F7BC056784; Wed, 24 May 2017 02:53:26 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9557718993; Wed, 24 May 2017 02:53:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E3F7BC056784 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 E3F7BC056784 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:30 +0800 Message-Id: <20170524025235.32190-12-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:27 +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 v3 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 --- 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 46a3e3f..074e235 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.4 From nobody Wed May 1 10:50:07 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 1495594911607515.506902758165; Tue, 23 May 2017 20:01:51 -0700 (PDT) Received: from localhost ([::1]:52406 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMYY-0007Nm-7s for importer@patchew.org; Tue, 23 May 2017 23:01:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQb-0000qg-0n for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQa-000797-BS for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33330) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQV-000778-QD; Tue, 23 May 2017 22:53:31 -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 AC6187AE8A; Wed, 24 May 2017 02:53:30 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 612AE5C6CE; Wed, 24 May 2017 02:53:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AC6187AE8A 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 AC6187AE8A From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:31 +0800 Message-Id: <20170524025235.32190-13-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:30 +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 v3 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 --- 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.4 From nobody Wed May 1 10:50:07 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 1495594556413792.8601588172514; Tue, 23 May 2017 19:55:56 -0700 (PDT) Received: from localhost ([::1]:52371 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMSp-0002RB-5a for importer@patchew.org; Tue, 23 May 2017 22:55:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQd-0000sq-80 for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQc-0007A4-Fu for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQa-00078p-CW; Tue, 23 May 2017 22:53:36 -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 44FD47AE81; Wed, 24 May 2017 02:53:35 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 465F118993; Wed, 24 May 2017 02:53:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 44FD47AE81 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 44FD47AE81 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:32 +0800 Message-Id: <20170524025235.32190-14-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:35 +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 v3 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 --- block/block-backend.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index 5492f64..dfe577d 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 { @@ -618,6 +619,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( @@ -1692,6 +1697,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.4 From nobody Wed May 1 10:50:07 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 1495595154516222.69916747344757; Tue, 23 May 2017 20:05:54 -0700 (PDT) Received: from localhost ([::1]:52435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMcT-000271-Av for importer@patchew.org; Tue, 23 May 2017 23:05:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34360) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQi-0000xz-FJ for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQf-0007BF-EV for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52048) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQd-0007AF-Ma; Tue, 23 May 2017 22:53:39 -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 9418285543; Wed, 24 May 2017 02:53:38 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC4DB5C6CD; Wed, 24 May 2017 02:53:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 9418285543 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=famz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 9418285543 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:33 +0800 Message-Id: <20170524025235.32190-15-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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.28]); Wed, 24 May 2017 02:53:38 +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 v3 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 --- 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.4 From nobody Wed May 1 10:50:07 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 1495595053604954.4829556405517; Tue, 23 May 2017 20:04:13 -0700 (PDT) Received: from localhost ([::1]:52418 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMaq-0000s7-4z for importer@patchew.org; Tue, 23 May 2017 23:04:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQk-0000ze-NG for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQj-0007Ck-Vz for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39856) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQg-0007BO-I5; Tue, 23 May 2017 22:53:42 -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 726AF80C1C; Wed, 24 May 2017 02:53:41 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2DE375C6CD; Wed, 24 May 2017 02:53:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 726AF80C1C 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 726AF80C1C From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:34 +0800 Message-Id: <20170524025235.32190-16-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:41 +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 v3 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 --- block/block-backend.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index dfe577d..51c62ea 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1695,8 +1695,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.4 From nobody Wed May 1 10:50:07 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 1495595220832334.94875732794196; Tue, 23 May 2017 20:07:00 -0700 (PDT) Received: from localhost ([::1]:52438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMdW-0002dQ-VK for importer@patchew.org; Tue, 23 May 2017 23:06:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDMQm-00011d-Mb for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDMQl-0007DM-Jx for qemu-devel@nongnu.org; Tue, 23 May 2017 22:53:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42698) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDMQj-0007C5-77; Tue, 23 May 2017 22:53:45 -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 1DD63C0467D7; Wed, 24 May 2017 02:53:44 +0000 (UTC) Received: from lemon.redhat.com (ovpn-12-75.pek2.redhat.com [10.72.12.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B05E18B54; Wed, 24 May 2017 02:53:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1DD63C0467D7 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 1DD63C0467D7 From: Fam Zheng To: qemu-devel@nongnu.org Date: Wed, 24 May 2017 10:52:35 +0800 Message-Id: <20170524025235.32190-17-famz@redhat.com> In-Reply-To: <20170524025235.32190-1-famz@redhat.com> References: <20170524025235.32190-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, 24 May 2017 02:53:44 +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 v3 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 7589383..5811296 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) @@ -548,6 +549,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..1c7b5d2 --- /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); + + error_free_or_abort(&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.4