From nobody Sun May 5 07:44:58 2024 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 ARC-Seal: i=1; a=rsa-sha256; t=1606212598; cv=none; d=zohomail.com; s=zohoarc; b=gXONuF56zeiTHB2aFRPmXiJZIvXIEcqOuRJQJ7oluhXPzp/FTroFN1czUj0i7vZ4qEIXZKNmL/W6PCPHqxoLPL2kqQXd4Lrajcg/LB5eRVvqIOQl2JJHwmkk2c6IeC60kBRvElzXnFV2+YwNTJZtl6gV9e8wkeOZY5hUNaJ4Aqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606212598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=g+PdHXXs/IHJz34NNdazShy0rmBdo1UYrd8RP6QDc8A=; b=GdEwAJXUhNh7+TvdC0B5h1Rb9ZP8Tx0raMqPQ4BbJ+65+2H0eQRA+SC1j2TP2OOlOhD6PjJ6GW6F3yMw5AdUnUcFh0t1PiHREC6vw22ZgLjJ8cX3sLWWMMXNPZVCZRAFsLrApr4ddEwsDXK8UxT3F2weUkAddGGlnHlED4LYsew= ARC-Authentication-Results: i=1; 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 1606212598338836.8231089863588; Tue, 24 Nov 2020 02:09:58 -0800 (PST) Received: from localhost ([::1]:55380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khVGn-00062i-3q for importer@patchew.org; Tue, 24 Nov 2020 05:09:57 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:54240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khVCV-0003SD-Jl; Tue, 24 Nov 2020 05:05:32 -0500 Received: from smtp.h3c.com ([60.191.123.50]:61097 helo=h3cspam02-ex.h3c.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khVCH-0003Fq-SZ; Tue, 24 Nov 2020 05:05:31 -0500 Received: from DAG2EX09-IDC.srv.huawei-3com.com ([10.8.0.72]) by h3cspam02-ex.h3c.com with ESMTP id 0AOA4kBs046634; Tue, 24 Nov 2020 18:04:46 +0800 (GMT-8) (envelope-from tu.guoyi@h3c.com) Received: from DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) by DAG2EX09-IDC.srv.huawei-3com.com (10.8.0.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 24 Nov 2020 18:04:49 +0800 Received: from DAG2EX03-BASE.srv.huawei-3com.com ([fe80::5d18:e01c:bbbd:c074]) by DAG2EX03-BASE.srv.huawei-3com.com ([fe80::5d18:e01c:bbbd:c074%7]) with mapi id 15.01.2106.002; Tue, 24 Nov 2020 18:04:49 +0800 From: Tuguoyi To: Kevin Wolf , Max Reitz , "qemu-block@nongnu.org" Subject: [PATCH] block: Don't inactivate bs if it is aleady inactive Thread-Topic: [PATCH] block: Don't inactivate bs if it is aleady inactive Thread-Index: AdbCSQxswlhoF8V3RjCLABUwyacY/A== Date: Tue, 24 Nov 2020 10:04:48 +0000 Message-ID: Accept-Language: en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.125.108.131] x-sender-location: DAG2 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-DNSRBL: X-MAIL: h3cspam02-ex.h3c.com 0AOA4kBs046634 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=60.191.123.50; envelope-from=tu.guoyi@h3c.com; helo=h3cspam02-ex.h3c.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "qemu-devel@nongnu.org" , Wangyong Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The following steps will cause qemu assertion failure: - pause vm - save memory snapshot into local file through fd migration - do the above operation again will cause qemu assertion failure The backtrace looks like: #0 0x00007fbf958c5c37 in raise () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00007fbf958c9028 in abort () from /lib/x86_64-linux-gnu/libc.so.6 #2 0x00007fbf958bebf6 in ?? () from /lib/x86_64-linux-gnu/libc.so.6 #3 0x00007fbf958beca2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.= so.6 #4 0x000055ca8decd39d in bdrv_inactivate_recurse (bs=3D0x55ca90c80400) at = /build/qemu-5.0/block.c:5724 #5 0x000055ca8dece967 in bdrv_inactivate_all () at /build//qemu-5.0/block.= c:5792 #6 0x000055ca8de5539d in qemu_savevm_state_complete_precopy_non_iterable (= inactivate_disks=3Dtrue, in_postcopy=3Dfalse, f=3D0x55ca907044b0) at /build/qemu-5.0/migration/savevm.c:1401 #7 qemu_savevm_state_complete_precopy (f=3D0x55ca907044b0, iterable_only= =3Diterable_only@entry=3Dfalse, inactivate_disks=3Dinactivate_disks@entry= =3Dtrue) at /build/qemu-5.0/migration/savevm.c:1453 #8 0x000055ca8de4f581 in migration_completion (s=3D0x55ca8f64d9f0) at /bui= ld/qemu-5.0/migration/migration.c:2941 #9 migration_iteration_run (s=3D0x55ca8f64d9f0) at /build/qemu-5.0/migrati= on/migration.c:3295 #10 migration_thread (opaque=3Dopaque@entry=3D0x55ca8f64d9f0) at /build/qem= u-5.0/migration/migration.c:3459 #11 0x000055ca8dfc6716 in qemu_thread_start (args=3D) at /bu= ild/qemu-5.0/util/qemu-thread-posix.c:519 #12 0x00007fbf95c5f184 in start_thread () from /lib/x86_64-linux-gnu/libpth= read.so.0 #13 0x00007fbf9598cbed in clone () from /lib/x86_64-linux-gnu/libc.so.6 When the first migration completes, bs->open_flags will set BDRV_O_INACTIVE= flag by bdrv_inactivate_recurse(), and during the second migration the bdrv_inactivate_recurse assert that the bs->open_flags is already BDRV_O_IN= ACTIVE enabled which cause crash. This patch just make the bdrv_inactivate_all() to don't inactivate the bs i= f it is already inactive Signed-off-by: Tuguoyi --- block.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index f1cedac..02361e1 100644 --- a/block.c +++ b/block.c @@ -5938,6 +5938,11 @@ static int bdrv_inactivate_recurse(BlockDriverState = *bs) return 0; } =20 +static bool bdrv_is_inactive(BlockDriverState *bs) +{ + return bs->open_flags & BDRV_O_INACTIVE; +} + int bdrv_inactivate_all(void) { BlockDriverState *bs =3D NULL; @@ -5958,7 +5963,7 @@ int bdrv_inactivate_all(void) /* Nodes with BDS parents are covered by recursion from the last * parent that gets inactivated. Don't inactivate them a second * time if that has already happened. */ - if (bdrv_has_bds_parent(bs, false)) { + if (bdrv_has_bds_parent(bs, false) || bdrv_is_inactive(bs)) { continue; } ret =3D bdrv_inactivate_recurse(bs); --=20 2.7.4 -- Best regards, Guoyi