From patchwork Wed Nov 16 13:53:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704649 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Y1CeMPqv; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4YT094nz20KC for ; Thu, 17 Nov 2022 01:04:45 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrI-0007cA-UA; Wed, 16 Nov 2022 08:53:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrG-0007UO-Ct for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrE-0002ii-KI for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606819; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YSBmp9TWRoxCrsN4SW7/9XhtxuOKnwbj3jjC4erRstI=; b=Y1CeMPqvyKDdbwNvI3kHnVQuMRuWvSZLlL4fuUGrXE5ihD4PFvuqPXpxaJe0UMDZ17PTHT B8UV/TuSNulODUa780omXf9sO8VmbDYRdQOlfRQNjGn8qemCz0Ou9zzB6i7oc/8fIzgK1T TaARy5nCGIfs+/8kM3mFe79pe/sSGmI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-D35UY6UPPB-pxErARoNmgg-1; Wed, 16 Nov 2022 08:53:35 -0500 X-MC-Unique: D35UY6UPPB-pxErARoNmgg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 498371C09B71; Wed, 16 Nov 2022 13:53:35 +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 F19DE40E80E4; Wed, 16 Nov 2022 13:53:34 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 1/6] block: assert that bdrv_co_create is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:26 -0500 Message-Id: <20221116135331.3052923-2-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This function is either called by bdrv_create(), which always takes care of creating a new coroutine, or by bdrv_create_file(), which is only called by BlockDriver->bdrv_co_create_opts callbacks, invoked by bdrv_co_create(). Protecting bdrv_co_create() implies that BlockDriver->bdrv_co_create_opts is always called with graph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 1 + include/block/block_int-common.h | 1 + 2 files changed, 2 insertions(+) diff --git a/block.c b/block.c index c7611bed9e..e54ed300d7 100644 --- a/block.c +++ b/block.c @@ -537,6 +537,7 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const char *filename, assert(qemu_in_coroutine()); assert(*errp == NULL); assert(drv); + assert_bdrv_graph_readable(); if (!drv->bdrv_co_create_opts) { error_setg(errp, "Driver '%s' does not support image creation", diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index db97d61836..d45961a1d1 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -253,6 +253,7 @@ struct BlockDriver { int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, Error **errp); + /* Called with graph rdlock taken */ int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv, const char *filename, QemuOpts *opts, From patchwork Wed Nov 16 13:53:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=YfPbvYO8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4LN1pFGz23n9 for ; Thu, 17 Nov 2022 00:55:08 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrL-0007if-E8; Wed, 16 Nov 2022 08:53:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrH-0007Y4-Oz for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrF-0002jY-N6 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QH/+/7UJYS5MtViHT79nNUCSFC9rW6fu+qCQmkWOUeI=; b=YfPbvYO8EMnfVsKYVwmSolzmX9h6H2K83iexc0bR2JYBBmXt87i3Fc57zp4zegEBAaNXfx HwfgzXoUINqbwH0kf+US0iWpKOlCl3cI5+hbIqRYmocrElgVM58nOu+SEJMWfNf7h2G0jj 9Gi2t1ufI6irlEiM7LMN+HbdN0osG0g= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-172-afC2oFH9MFiU6PQnct7Kog-1; Wed, 16 Nov 2022 08:53:36 -0500 X-MC-Unique: afC2oFH9MFiU6PQnct7Kog-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D5E43C10688; Wed, 16 Nov 2022 13:53:35 +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 5277340E80E3; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 2/6] block: assert that BlockDriver->bdrv_co_{amend/create} are called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:27 -0500 Message-Id: <20221116135331.3052923-3-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Both functions are only called by Job->run() callbacks, therefore they must take the lock in the *_run() implementation. Signed-off-by: Emanuele Giuseppe Esposito --- block/amend.c | 1 + block/create.c | 1 + include/block/block_int-common.h | 2 ++ 3 files changed, 4 insertions(+) diff --git a/block/amend.c b/block/amend.c index f696a006e3..a155b6889b 100644 --- a/block/amend.c +++ b/block/amend.c @@ -45,6 +45,7 @@ static int coroutine_fn blockdev_amend_run(Job *job, Error **errp) { BlockdevAmendJob *s = container_of(job, BlockdevAmendJob, common); int ret; + GRAPH_RDLOCK_GUARD(); job_progress_set_remaining(&s->common, 1); ret = s->bs->drv->bdrv_co_amend(s->bs, s->opts, s->force, errp); diff --git a/block/create.c b/block/create.c index 4df43f11f4..4048d71265 100644 --- a/block/create.c +++ b/block/create.c @@ -43,6 +43,7 @@ static int coroutine_fn blockdev_create_run(Job *job, Error **errp) int ret; GLOBAL_STATE_CODE(); + GRAPH_RDLOCK_GUARD(); job_progress_set_remaining(&s->common, 1); ret = s->drv->bdrv_co_create(s->opts, errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index d45961a1d1..1e9bb91c98 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -251,6 +251,7 @@ struct BlockDriver { Error **errp); void (*bdrv_close)(BlockDriverState *bs); + /* Called with graph rdlock taken */ int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, Error **errp); /* Called with graph rdlock taken */ @@ -471,6 +472,7 @@ struct BlockDriver { int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filename); + /* Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, BlockdevAmendOptions *opts, bool force, From patchwork Wed Nov 16 13:53:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704632 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=VK0jKvRo; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4RD3Vjpz23nC for ; Thu, 17 Nov 2022 00:59:20 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrJ-0007dc-JZ; Wed, 16 Nov 2022 08:53:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrH-0007YG-QJ for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrF-0002j5-CV for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ro20h428+MmQ1aHxt24h1z4UYKTh74mpEKt522DW974=; b=VK0jKvRoNZHhzKL6wrEJJtVtf3o0kza3BLZVtUuA5moN52sip63+TFlBEjlAzSO0USNPU5 pg6jcdGsDAASo7ULfoW355QbBrjTwL6pgPKcyrk3UvQ2YB9fd0NlZu/gA8vkR4SPNCOxKa V6k4GTSIbVK1WD7IwPRtM6XNiCw94bY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-nseocApXNtKdLI62IGyCBg-1; Wed, 16 Nov 2022 08:53:36 -0500 X-MC-Unique: nseocApXNtKdLI62IGyCBg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F142B3801F5A; Wed, 16 Nov 2022 13:53:35 +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 A69B140E80E3; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 3/6] block: assert that BlockDriver->bdrv_co_copy_range_{from/to} is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:28 -0500 Message-Id: <20221116135331.3052923-4-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The only non-protected caller is convert_co_copy_range(), all other callers are BlockDriver callbacks that already take the rdlock. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 2 ++ block/io.c | 5 +++++ include/block/block_int-common.h | 4 ++++ qemu-img.c | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 9e1c689e84..6f0dd15808 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2631,6 +2631,8 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in, if (r) { return r; } + + GRAPH_RDLOCK_GUARD(); return bdrv_co_copy_range(blk_in->root, off_in, blk_out->root, off_out, bytes, read_flags, write_flags); diff --git a/block/io.c b/block/io.c index 831f277e85..62c0b3a390 100644 --- a/block/io.c +++ b/block/io.c @@ -3165,6 +3165,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( { BdrvTrackedRequest req; int ret; + assert_bdrv_graph_readable(); /* TODO We can support BDRV_REQ_NO_FALLBACK here */ assert(!(read_flags & BDRV_REQ_NO_FALLBACK)); @@ -3246,6 +3247,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, @@ -3263,6 +3265,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, @@ -3275,6 +3278,8 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); + return bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 1e9bb91c98..9e441cb93b 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -574,6 +574,8 @@ struct BlockDriver { * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_copy_range_from)(BlockDriverState *bs, BdrvChild *src, @@ -592,6 +594,8 @@ struct BlockDriver { * * See the comment of bdrv_co_copy_range for the parameter and return value * semantics. + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_copy_range_to)(BlockDriverState *bs, BdrvChild *src, diff --git a/qemu-img.c b/qemu-img.c index 33703a6d92..2086cf6eed 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2027,7 +2027,9 @@ retry: if (s->ret == -EINPROGRESS) { if (copy_range) { - ret = convert_co_copy_range(s, sector_num, n); + WITH_GRAPH_RDLOCK_GUARD() { + ret = convert_co_copy_range(s, sector_num, n); + } if (ret) { s->copy_range = false; goto retry; From patchwork Wed Nov 16 13:53:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704650 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Dr1jaqMa; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4bC0JDjz23nB for ; Thu, 17 Nov 2022 01:06:15 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrI-0007cC-U2; Wed, 16 Nov 2022 08:53:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrG-0007Uc-Fl for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrE-0002ih-HY for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NNpqTpAQbuZtCAGRbUHSH2DtrE1j72lEjkUIqHAQEgE=; b=Dr1jaqMaLXowBE2a+UngA0nuz4fKOrKOe/Itis1c6EAca5l79I692JdZTq0zedRZjz2mgh Dt+Q6e21HqD1A+w3f8ETJPW4bo0fqaHugawUSk48JlRRlbYIg9tpCbXhBoDXyH6472SY6t QSq6MzhAsclDh46SBIB+AjcDoA3hmoA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-rSIcNVqQOi2vVx4yrjz13g-1; Wed, 16 Nov 2022 08:53:36 -0500 X-MC-Unique: rSIcNVqQOi2vVx4yrjz13g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51B55811E7A; Wed, 16 Nov 2022 13:53:36 +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 067BD40C6EC3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 4/6] block/dirty-bitmap: assert that BlockDriver->bdrv_co_*_dirty_bitmap are always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:29 -0500 Message-Id: <20221116135331.3052923-5-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The only callers are the respective bdrv_*_dirty_bitmap() functions that take care of creating a new coroutine (that already takes the graph rdlock). Signed-off-by: Emanuele Giuseppe Esposito --- block/dirty-bitmap.c | 2 ++ include/block/block_int-common.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 21cf592889..92c70a7282 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -392,6 +392,7 @@ int coroutine_fn bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, Error **errp) { + assert_bdrv_graph_readable(); if (bs->drv && bs->drv->bdrv_co_remove_persistent_dirty_bitmap) { return bs->drv->bdrv_co_remove_persistent_dirty_bitmap(bs, name, errp); } @@ -413,6 +414,7 @@ bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name, uint32_t granularity, Error **errp) { BlockDriver *drv = bs->drv; + assert_bdrv_graph_readable(); if (!drv) { error_setg_errno(errp, ENOMEDIUM, diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 9e441cb93b..3064822508 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -789,9 +789,11 @@ struct BlockDriver { void (*bdrv_drain_end)(BlockDriverState *bs); bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs); + /* Called with graph rdlock held. */ bool coroutine_fn (*bdrv_co_can_store_new_dirty_bitmap)( BlockDriverState *bs, const char *name, uint32_t granularity, Error **errp); + /* Called with graph rdlock held. */ int coroutine_fn (*bdrv_co_remove_persistent_dirty_bitmap)( BlockDriverState *bs, const char *name, Error **errp); }; From patchwork Wed Nov 16 13:53:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704627 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KeRVNPh/; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4KZ5bw4z23nB for ; Thu, 17 Nov 2022 00:54:26 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrG-0007Ud-JM; Wed, 16 Nov 2022 08:53:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrF-0007Pq-6s for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrD-0002hy-63 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606818; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dmIaFsLSCEXhvHzxeUI8wryLJNEgtrYu1PgD6PMFDew=; b=KeRVNPh/A3sxqKMJD+9/nHAjISO/GXUyH7XZu9bR+ATIBu/cba1a2+heqdSQBnYYALt6s2 gsV7mhqsiUOwDQ4ofOqUU4IYk4m5bSSPgp7DO5Hix2RQT1gG/FXvK+6DM65Rnv/bJf+Wfp B//fZxJgG4N8zhp0vfFIk2Dz4DkOghk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-399-4q-QmLdYOhOZcDcL7g6rqQ-1; Wed, 16 Nov 2022 08:53:37 -0500 X-MC-Unique: 4q-QmLdYOhOZcDcL7g6rqQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5A9F857F92; Wed, 16 Nov 2022 13:53:36 +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 5A63E40E80E3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 5/6] block/io: assert that BlockDriver->bdrv_co_*_snapshot_* are always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:30 -0500 Message-Id: <20221116135331.3052923-6-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The only callers are other callback functions that already run with the graph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block/io.c | 2 ++ include/block/block_int-common.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/block/io.c b/block/io.c index 62c0b3a390..7d1d0c48b0 100644 --- a/block/io.c +++ b/block/io.c @@ -3449,6 +3449,7 @@ bdrv_co_preadv_snapshot(BdrvChild *child, int64_t offset, int64_t bytes, BlockDriver *drv = bs->drv; int ret; IO_CODE(); + assert_bdrv_graph_readable(); if (!drv) { return -ENOMEDIUM; @@ -3474,6 +3475,7 @@ bdrv_co_snapshot_block_status(BlockDriverState *bs, BlockDriver *drv = bs->drv; int ret; IO_CODE(); + assert_bdrv_graph_readable(); if (!drv) { return -ENOMEDIUM; diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 3064822508..03bd28e3c9 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -652,9 +652,12 @@ struct BlockDriver { * - be able to select a specific snapshot * - receive the snapshot's actual length (which may differ from bs's * length) + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_preadv_snapshot)(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); + /* Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_snapshot_block_status)(BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file); From patchwork Wed Nov 16 13:53:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 1704634 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Xm+0RCJw; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NC4Rz0V7Xz23n9 for ; Thu, 17 Nov 2022 00:59:59 +1100 (AEDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrK-0007gO-Kb; Wed, 16 Nov 2022 08:53:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrH-0007YB-Q9 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ovIrF-0002j1-7d for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aRNlHc5dNco8sL82R2DreaesGOuYlSclpQ+GSk1CEkU=; b=Xm+0RCJwNJ2LIyA1/R8YeIGyLMiKdpvCKmV6deay7vVB2tRTUg1Xoj0GDFY5B75rDKM7p4 aUNLxfVH2PG1L2L89Xn91+fYpA+vD2qvZut/qmrsq91acL1lSMnjf60qhBbfXqT5APfSTR eKRJ4eTHip7utS0smCVLjkBDEjnNLas= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-550-owxhRB9nNuy7SGfRHTV4GA-1; Wed, 16 Nov 2022 08:53:37 -0500 X-MC-Unique: owxhRB9nNuy7SGfRHTV4GA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06955185A7A9; Wed, 16 Nov 2022 13:53: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 AF5C940E80E3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 6/6] block: assert that BlockDriver->bdrv_co_delete_file is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:31 -0500 Message-Id: <20221116135331.3052923-7-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-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: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The only callers are other callback functions that already run with the graph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 1 + include/block/block_int-common.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index e54ed300d7..1a6ae08879 100644 --- a/block.c +++ b/block.c @@ -747,6 +747,7 @@ int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp) IO_CODE(); assert(bs != NULL); + assert_bdrv_graph_readable(); if (!bs->drv) { error_setg(errp, "Block node '%s' is not opened", bs->filename); diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h index 03bd28e3c9..20308376c6 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -681,7 +681,7 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_flush)(BlockDriverState *bs); - /* Delete a created file. */ + /* Delete a created file. Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_delete_file)(BlockDriverState *bs, Error **errp);