From nobody Tue Apr 15 03:54:48 2025 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.zohomail.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 1506436569613537.3227954812637; Tue, 26 Sep 2017 07:36:09 -0700 (PDT) Received: from localhost ([::1]:47853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwqxq-0004pM-Lm for importer@patchew.org; Tue, 26 Sep 2017 10:35:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dwqkl-0001oO-PM for qemu-devel@nongnu.org; Tue, 26 Sep 2017 10:22:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dwqkd-0005ZJ-Jn for qemu-devel@nongnu.org; Tue, 26 Sep 2017 10:22:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46780) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dwqkS-0005Od-PP; Tue, 26 Sep 2017 10:22:08 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFE5B267FB; Tue, 26 Sep 2017 14:22:07 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-117-39.ams2.redhat.com [10.36.117.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6195C5C66F; Tue, 26 Sep 2017 14:22:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFE5B267FB 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=fail smtp.mailfrom=kwolf@redhat.com From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 26 Sep 2017 16:21:23 +0200 Message-Id: <20170926142133.2498-15-kwolf@redhat.com> In-Reply-To: <20170926142133.2498-1-kwolf@redhat.com> References: <20170926142133.2498-1-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 26 Sep 2017 14:22: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] [PULL 14/24] block: Add reopen queue to bdrv_check_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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org 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" In the context of bdrv_reopen(), we'll have to look at the state of the graph as it will be after the reopen. This interface addition is in preparation for the change. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/block.c b/block.c index c7724c85e3..0b499fda4c 100644 --- a/block.c +++ b/block.c @@ -1531,7 +1531,8 @@ static int bdrv_fill_options(QDict **options, const c= har *filename, return 0; } =20 -static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t sha= red, +static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, + uint64_t perm, uint64_t shared, GSList *ignore_children, Error **errp); static void bdrv_child_abort_perm_update(BdrvChild *c); static void bdrv_child_set_perm(BdrvChild *c, uint64_t perm, uint64_t shar= ed); @@ -1562,7 +1563,8 @@ static void bdrv_child_perm(BlockDriverState *bs, Blo= ckDriverState *child_bs, * A call to this function must always be followed by a call to bdrv_set_p= erm() * or bdrv_abort_perm_update(). */ -static int bdrv_check_perm(BlockDriverState *bs, uint64_t cumulative_perms, +static int bdrv_check_perm(BlockDriverState *bs, BlockReopenQueue *q, + uint64_t cumulative_perms, uint64_t cumulative_shared_perms, GSList *ignore_children, Error **errp) { @@ -1597,11 +1599,11 @@ static int bdrv_check_perm(BlockDriverState *bs, ui= nt64_t cumulative_perms, /* Check all children */ QLIST_FOREACH(c, &bs->children, next) { uint64_t cur_perm, cur_shared; - bdrv_child_perm(bs, c->bs, c, c->role, NULL, + bdrv_child_perm(bs, c->bs, c, c->role, q, cumulative_perms, cumulative_shared_perms, &cur_perm, &cur_shared); - ret =3D bdrv_child_check_perm(c, cur_perm, cur_shared, ignore_chil= dren, - errp); + ret =3D bdrv_child_check_perm(c, q, cur_perm, cur_shared, + ignore_children, errp); if (ret < 0) { return ret; } @@ -1727,7 +1729,8 @@ char *bdrv_perm_names(uint64_t perm) * * Needs to be followed by a call to either bdrv_set_perm() or * bdrv_abort_perm_update(). */ -static int bdrv_check_update_perm(BlockDriverState *bs, uint64_t new_used_= perm, +static int bdrv_check_update_perm(BlockDriverState *bs, BlockReopenQueue *= q, + uint64_t new_used_perm, uint64_t new_shared_perm, GSList *ignore_children, Error **errp) { @@ -1769,19 +1772,20 @@ static int bdrv_check_update_perm(BlockDriverState = *bs, uint64_t new_used_perm, cumulative_shared_perms &=3D c->shared_perm; } =20 - return bdrv_check_perm(bs, cumulative_perms, cumulative_shared_perms, + return bdrv_check_perm(bs, q, cumulative_perms, cumulative_shared_perm= s, ignore_children, errp); } =20 /* Needs to be followed by a call to either bdrv_child_set_perm() or * bdrv_child_abort_perm_update(). */ -static int bdrv_child_check_perm(BdrvChild *c, uint64_t perm, uint64_t sha= red, +static int bdrv_child_check_perm(BdrvChild *c, BlockReopenQueue *q, + uint64_t perm, uint64_t shared, GSList *ignore_children, Error **errp) { int ret; =20 ignore_children =3D g_slist_prepend(g_slist_copy(ignore_children), c); - ret =3D bdrv_check_update_perm(c->bs, perm, shared, ignore_children, e= rrp); + ret =3D bdrv_check_update_perm(c->bs, q, perm, shared, ignore_children= , errp); g_slist_free(ignore_children); =20 return ret; @@ -1809,7 +1813,7 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t pe= rm, uint64_t shared, { int ret; =20 - ret =3D bdrv_child_check_perm(c, perm, shared, NULL, errp); + ret =3D bdrv_child_check_perm(c, NULL, perm, shared, NULL, errp); if (ret < 0) { bdrv_child_abort_perm_update(c); return ret; @@ -1950,7 +1954,7 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs) * because we're just taking a parent away, so we're loosening * restrictions. */ bdrv_get_cumulative_perm(old_bs, &perm, &shared_perm); - bdrv_check_perm(old_bs, perm, shared_perm, NULL, &error_abort); + bdrv_check_perm(old_bs, NULL, perm, shared_perm, NULL, &error_abor= t); bdrv_set_perm(old_bs, perm, shared_perm); } =20 @@ -1969,7 +1973,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, BdrvChild *child; int ret; =20 - ret =3D bdrv_check_update_perm(child_bs, perm, shared_perm, NULL, errp= ); + ret =3D bdrv_check_update_perm(child_bs, NULL, perm, shared_perm, NULL= , errp); if (ret < 0) { bdrv_abort_perm_update(child_bs); return NULL; @@ -3184,7 +3188,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockD= riverState *to, =20 /* Check whether the required permissions can be granted on @to, ignor= ing * all BdrvChild in @list so that they can't block themselves. */ - ret =3D bdrv_check_update_perm(to, perm, shared, list, errp); + ret =3D bdrv_check_update_perm(to, NULL, perm, shared, list, errp); if (ret < 0) { bdrv_abort_perm_update(to); goto out; @@ -4054,7 +4058,7 @@ void bdrv_invalidate_cache(BlockDriverState *bs, Erro= r **errp) =20 /* Update permissions, they may differ for inactive nodes */ bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - ret =3D bdrv_check_perm(bs, perm, shared_perm, NULL, &local_err); + ret =3D bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &local_err); if (ret < 0) { bs->open_flags |=3D BDRV_O_INACTIVE; error_propagate(errp, local_err); @@ -4121,7 +4125,7 @@ static int bdrv_inactivate_recurse(BlockDriverState *= bs, =20 /* Update permissions, they may differ for inactive nodes */ bdrv_get_cumulative_perm(bs, &perm, &shared_perm); - bdrv_check_perm(bs, perm, shared_perm, NULL, &error_abort); + bdrv_check_perm(bs, NULL, perm, shared_perm, NULL, &error_abort); bdrv_set_perm(bs, perm, shared_perm); } =20 --=20 2.13.5