From nobody Sun Feb 8 19:38:09 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642788841345693.9053474023627; Fri, 21 Jan 2022 10:14:01 -0800 (PST) Received: from localhost ([::1]:36052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nAyQC-0006vP-Bn for importer@patchew.org; Fri, 21 Jan 2022 13:14:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41414) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAxO7-00018X-Rt for qemu-devel@nongnu.org; Fri, 21 Jan 2022 12:07:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31050) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nAxO4-0000Z5-9U for qemu-devel@nongnu.org; Fri, 21 Jan 2022 12:07:46 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-CZlOsoCdNaK2I5NZcq7OEw-1; Fri, 21 Jan 2022 12:07:39 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 768BC874980; Fri, 21 Jan 2022 17:07:37 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id D31CC7ED83; Fri, 21 Jan 2022 17:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642784862; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U0/9h+ojJJD5VsAceZBm++9ONBxtrl2G08T5QKb0dZ4=; b=EylEzqtUrjYWmgu/nTCs8GUVoAhaQ5weq4DxGcFUhn/znowRz+tY3J93+2ilWJcyaz7QjI QLoVFvxxlu1KEC4PhUvme7WcwcUpsd5piyOKanIjd59XYILknqJdCYWrsycu9+0mO+QIr0 RwxjZoInlyttBDzSQFno+B+nS2wfwgY= X-MC-Unique: CZlOsoCdNaK2I5NZcq7OEw-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Subject: [PATCH v6 33/33] block.c: assertions to the block layer permissions API Date: Fri, 21 Jan 2022 12:05:44 -0500 Message-Id: <20220121170544.2049944-34-eesposit@redhat.com> In-Reply-To: <20220121170544.2049944-1-eesposit@redhat.com> References: <20220121170544.2049944-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eesposit@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.699, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , qemu-devel@nongnu.org, "Denis V. Lunev" , Eric Blake , Emanuele Giuseppe Esposito , Juan Quintela , Daniel Henrique Barboza , Markus Armbruster , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Stefan Hajnoczi , John Snow , David Gibson , Kevin Wolf , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Hanna Reitz , qemu-ppc@nongnu.org, Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1642788844280100001 Content-Type: text/plain; charset="utf-8" Now that we "covered" the three main cases where the permission API was being used under BQL (fuse, amend and invalidate_cache), we can safely assert for the permission functions implemented in block.c Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/block.c b/block.c index ca16d90627..afa18653d1 100644 --- a/block.c +++ b/block.c @@ -2138,6 +2138,7 @@ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b= , Error **errp) =20 assert(a->bs); assert(a->bs =3D=3D b->bs); + assert(qemu_in_main_thread()); =20 if ((b->perm & a->shared_perm) =3D=3D b->perm) { return true; @@ -2161,6 +2162,7 @@ static bool bdrv_a_allow_b(BdrvChild *a, BdrvChild *b= , Error **errp) static bool bdrv_parent_perms_conflict(BlockDriverState *bs, Error **errp) { BdrvChild *a, *b; + assert(qemu_in_main_thread()); =20 /* * During the loop we'll look at each pair twice. That's correct becau= se @@ -2245,6 +2247,8 @@ static void bdrv_child_set_perm_abort(void *opaque) { BdrvChildSetPermState *s =3D opaque; =20 + assert(qemu_in_main_thread()); + s->child->perm =3D s->old_perm; s->child->shared_perm =3D s->old_shared_perm; } @@ -2258,6 +2262,7 @@ static void bdrv_child_set_perm(BdrvChild *c, uint64_= t perm, uint64_t shared, Transaction *tran) { BdrvChildSetPermState *s =3D g_new(BdrvChildSetPermState, 1); + assert(qemu_in_main_thread()); =20 *s =3D (BdrvChildSetPermState) { .child =3D c, @@ -2442,6 +2447,7 @@ static int bdrv_node_refresh_perm(BlockDriverState *b= s, BlockReopenQueue *q, BdrvChild *c; int ret; uint64_t cumulative_perms, cumulative_shared_perms; + assert(qemu_in_main_thread()); =20 bdrv_get_cumulative_perm(bs, &cumulative_perms, &cumulative_shared_per= ms); =20 @@ -2510,6 +2516,7 @@ static int bdrv_list_refresh_perms(GSList *list, Bloc= kReopenQueue *q, { int ret; BlockDriverState *bs; + assert(qemu_in_main_thread()); =20 for ( ; list; list =3D list->next) { bs =3D list->data; @@ -2581,6 +2588,7 @@ static int bdrv_refresh_perms(BlockDriverState *bs, E= rror **errp) int ret; Transaction *tran =3D tran_new(); g_autoptr(GSList) list =3D bdrv_topological_dfs(NULL, NULL, bs); + assert(qemu_in_main_thread()); =20 ret =3D bdrv_list_refresh_perms(list, NULL, tran, errp); tran_finalize(tran, ret); @@ -2647,6 +2655,7 @@ static void bdrv_filter_default_perms(BlockDriverStat= e *bs, BdrvChild *c, uint64_t perm, uint64_t shared, uint64_t *nperm, uint64_t *nshared) { + assert(qemu_in_main_thread()); *nperm =3D perm & DEFAULT_PERM_PASSTHROUGH; *nshared =3D (shared & DEFAULT_PERM_PASSTHROUGH) | DEFAULT_PERM_UNCHAN= GED; } @@ -2658,6 +2667,7 @@ static void bdrv_default_perms_for_cow(BlockDriverSta= te *bs, BdrvChild *c, uint64_t *nperm, uint64_t *nshared) { assert(role & BDRV_CHILD_COW); + assert(qemu_in_main_thread()); =20 /* * We want consistent read from backing files if the parent needs it. @@ -2694,6 +2704,7 @@ static void bdrv_default_perms_for_storage(BlockDrive= rState *bs, BdrvChild *c, { int flags; =20 + assert(qemu_in_main_thread()); assert(role & (BDRV_CHILD_METADATA | BDRV_CHILD_DATA)); =20 flags =3D bdrv_reopen_get_flags(reopen_queue, bs); @@ -6090,6 +6101,7 @@ static void xdbg_graph_add_edge(XDbgBlockGraphConstru= ctor *gr, void *parent, { BlockPermission qapi_perm; XDbgBlockGraphEdge *edge; + assert(qemu_in_main_thread()); =20 edge =3D g_new0(XDbgBlockGraphEdge, 1); =20 --=20 2.31.1