From nobody Tue Feb 10 19:48:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715071527705221.76209507002636; Tue, 7 May 2024 01:45:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4GPX-0003eI-On; Tue, 07 May 2024 04:42:55 -0400 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 1s4GPO-0003TJ-Kf; Tue, 07 May 2024 04:42:47 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s4GPL-0003Dh-Jf; Tue, 07 May 2024 04:42:45 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id BD3E464BC8; Tue, 7 May 2024 11:42:48 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id AA06EC85B1; Tue, 7 May 2024 11:42:29 +0300 (MSK) Received: (nullmailer pid 1026524 invoked by uid 1000); Tue, 07 May 2024 08:42:29 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Li Zhijian , Fabiano Rosas , Zhang Chen , Peter Xu , Michael Tokarev Subject: [Stable-8.2.4 04/16] migration/colo: Fix bdrv_graph_rdlock_main_loop: Assertion `!qemu_in_coroutine()' failed. Date: Tue, 7 May 2024 11:42:03 +0300 Message-Id: <20240507084226.1026455-4-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 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=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1715071527985100001 Content-Type: text/plain; charset="utf-8" From: Li Zhijian bdrv_activate_all() should not be called from the coroutine context, move it to the QEMU thread colo_process_incoming_thread() with the bql_lock protected. The backtrace is as follows: #4 0x0000561af7948362 in bdrv_graph_rdlock_main_loop () at ../block/graph= -lock.c:260 #5 0x0000561af7907a68 in graph_lockable_auto_lock_mainloop (x=3D0x7fd2981= 0be7b) at /patch/to/qemu/include/block/graph-lock.h:259 #6 0x0000561af79167d1 in bdrv_activate_all (errp=3D0x7fd29810bed0) at ../= block.c:6906 #7 0x0000561af762b4af in colo_incoming_co () at ../migration/colo.c:935 #8 0x0000561af7607e57 in process_incoming_migration_co (opaque=3D0x0) at = ../migration/migration.c:793 #9 0x0000561af7adbeeb in coroutine_trampoline (i0=3D-106876144, i1=3D2204= 2) at ../util/coroutine-ucontext.c:175 #10 0x00007fd2a5cf21c0 in () at /lib64/libc.so.6 Cc: qemu-stable@nongnu.org Cc: Fabiano Rosas Closes: https://gitlab.com/qemu-project/qemu/-/issues/2277 Fixes: 2b3912f135 ("block: Mark bdrv_first_blk() and bdrv_is_root_node() GR= APH_RDLOCK") Signed-off-by: Li Zhijian Reviewed-by: Zhang Chen Tested-by: Zhang Chen Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20240417025634.1014582-1-lizhijian@fujitsu.= com Signed-off-by: Peter Xu (cherry picked from commit 2cc637f1ea08d2a1b19fc5b1a30bc609f948de93) Signed-off-by: Michael Tokarev (Mjt: fixup bql_lock() =3D> qemu_mutex_lock_iothread() for v8.2.0-444-g1958= 01d700c0 "system/cpus: rename qemu_mutex_lock_iothread() to bql_lock()") diff --git a/migration/colo.c b/migration/colo.c index 4447e34914..8f301b7e57 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -830,6 +830,16 @@ static void *colo_process_incoming_thread(void *opaque) return NULL; } =20 + /* Make sure all file formats throw away their mutable metadata */ + qemu_mutex_lock_iothread(); + bdrv_activate_all(&local_err); + if (local_err) { + qemu_mutex_unlock_iothread(); + error_report_err(local_err); + return NULL; + } + qemu_mutex_unlock_iothread(); + failover_init_state(); =20 mis->to_src_file =3D qemu_file_get_return_path(mis->from_src_file); @@ -917,7 +927,6 @@ out: int coroutine_fn colo_incoming_co(void) { MigrationIncomingState *mis =3D migration_incoming_get_current(); - Error *local_err =3D NULL; QemuThread th; =20 assert(qemu_mutex_iothread_locked()); @@ -926,13 +935,6 @@ int coroutine_fn colo_incoming_co(void) return 0; } =20 - /* Make sure all file formats throw away their mutable metadata */ - bdrv_activate_all(&local_err); - if (local_err) { - error_report_err(local_err); - return -EINVAL; - } - qemu_thread_create(&th, "COLO incoming", colo_process_incoming_thread, mis, QEMU_THREAD_JOINABLE); =20 --=20 2.39.2