From nobody Thu Nov 6 16:10:10 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.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 1489417433937298.85594022453756; Mon, 13 Mar 2017 08:03:53 -0700 (PDT) Received: from localhost ([::1]:52543 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRVl-0003VN-OG for importer@patchew.org; Mon, 13 Mar 2017 11:03:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNj-0005no-K8 for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNi-0002we-Ps for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35292) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNd-0002uE-Mb; Mon, 13 Mar 2017 10:55:25 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C83D164DAD; Mon, 13 Mar 2017 14:55:25 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUZ009408; Mon, 13 Mar 2017 10:55:24 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:03 +0100 Message-Id: <1489416908-3771-8-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 13 Mar 2017 14:55: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] [PULL 07/12] block: Remove check_new_perm from bdrv_replace_child() 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, 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" All callers pass false now, so the parameter can go away again. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake --- block.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/block.c b/block.c index b404ef2..dd38e71 100644 --- a/block.c +++ b/block.c @@ -1756,8 +1756,18 @@ static void bdrv_replace_child_noperm(BdrvChild *chi= ld, } } =20 -static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs, - bool check_new_perm) +/* + * Updates @child to change its reference to point to @new_bs, including + * checking and applying the necessary permisson updates both to the old n= ode + * and to @new_bs. + * + * NULL is passed as @new_bs for removing the reference before freeing @ch= ild. + * + * If @new_bs is not NULL, bdrv_check_perm() must be called beforehand, as= this + * function uses bdrv_set_perm() to update the permissions according to th= e new + * reference that @new_bs gets. + */ +static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs) { BlockDriverState *old_bs =3D child->bs; uint64_t perm, shared_perm; @@ -1775,9 +1785,6 @@ static void bdrv_replace_child(BdrvChild *child, Bloc= kDriverState *new_bs, =20 if (new_bs) { bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm); - if (check_new_perm) { - bdrv_check_perm(new_bs, perm, shared_perm, NULL, &error_abort); - } bdrv_set_perm(new_bs, perm, shared_perm); } } @@ -1808,7 +1815,7 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *c= hild_bs, }; =20 /* This performs the matching bdrv_set_perm() for the above check. */ - bdrv_replace_child(child, child_bs, false); + bdrv_replace_child(child, child_bs); =20 return child; } @@ -1845,7 +1852,7 @@ static void bdrv_detach_child(BdrvChild *child) child->next.le_prev =3D NULL; } =20 - bdrv_replace_child(child, NULL, false); + bdrv_replace_child(child, NULL); =20 g_free(child->name); g_free(child); --=20 1.8.3.1