From nobody Tue May 21 16:12:09 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=1607392086; cv=none; d=zohomail.com; s=zohoarc; b=Aw6B6mdN2i7OIoYUrlbFxEAkBHNTTnZkKP/XDaWG5WhLtRTUtV40a1VXhfxnwa3D4diTDZ3rNnjVOv+bPeEC2mrTXlJNtyzDPJDcUw+u3DdF3FX9MmtyLTgz8oI4EHAhBZ3gqiekVTsfmkZSNN9PKSjxe/a0X0/ur6/zduOnRB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1607392086; 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=Qy0JXhvOEeGpuLvPeAsNXwL6ba1QXqkL6Ff/MnTlCvw=; b=mPgpEW+593/HJcGSvYq0unswAf3HDaQthvXmAkO+eT3QvCt4XcU3v8RY8ebvBZZi5jNZ1ze9yKr63daHMH43fXWmQ6PvRszTbcuLx0o9bDl41jZ7k3uFVEPxqWO0xl0AtGJhQpLinTTVijZBgcOISBpJNfgEqcPK9aEHA3Y5s6c= 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 16073920864951.1972467199598213; Mon, 7 Dec 2020 17:48:06 -0800 (PST) Received: from localhost ([::1]:50406 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kmS6n-0004yI-4u for importer@patchew.org; Mon, 07 Dec 2020 20:48:05 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:45816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kmS5a-0004Y2-8n for qemu-devel@nongnu.org; Mon, 07 Dec 2020 20:46:50 -0500 Received: from smtp.h3c.com ([60.191.123.50]:52111 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 1kmS5O-0006f6-SA for qemu-devel@nongnu.org; Mon, 07 Dec 2020 20:46:50 -0500 Received: from DAG2EX07-IDC.srv.huawei-3com.com ([10.8.0.70]) by h3cspam02-ex.h3c.com with ESMTP id 0B81kOVR001368; Tue, 8 Dec 2020 09:46:24 +0800 (GMT-8) (envelope-from tu.guoyi@h3c.com) Received: from DAG2EX03-BASE.srv.huawei-3com.com (10.8.0.66) by DAG2EX07-IDC.srv.huawei-3com.com (10.8.0.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 8 Dec 2020 09:46:25 +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, 8 Dec 2020 09:46:25 +0800 From: Tuguoyi To: Juan Quintela , "Dr. David Alan Gilbert" Subject: [PATCH v3] migration: Don't allow migration if vm is in POSTMIGRATE Thread-Topic: [PATCH v3] migration: Don't allow migration if vm is in POSTMIGRATE Thread-Index: AdbNA412vEo+hmt0TmuQR+h7GaeR1g== Date: Tue, 8 Dec 2020 01:46:25 +0000 Message-ID: <6b704294ad2e405781c38fb38d68c744@h3c.com> 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 0B81kOVR001368 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: "vsementsov@virtuozzo.com" , "qemu-devel@nongnu.org" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" The following steps will cause qemu assertion failure: - pause vm by executing 'virsh suspend' - create external snapshot of memory and disk using 'virsh snapshot-create-= as' - doing the above operation again will cause qemu crash 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_all(), and during the second migration the bdrv_inactivate_recurse assert that the bs->open_flags is already BDRV_O_INACTIVE enabled which cause crash. As Vladimir suggested, this patch makes migrate_prepare check the state of = vm and return error if it is in RUN_STATE_POSTMIGRATE state. Signed-off-by: Tuguoyi Reported-by: Li Zhang Reviewed-by: Pankaj Gupta Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/migration.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index 87a9b59..5e33962 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2115,6 +2115,12 @@ static bool migrate_prepare(MigrationState *s, bool = blk, bool blk_inc, return false; } =20 + if (runstate_check(RUN_STATE_POSTMIGRATE)) { + error_setg(errp, "Can't migrate the vm that was paused due to " + "previous migration"); + return false; + } + if (migration_is_blocked(errp)) { return false; } --=20 2.7.4 [Patch v2]: https://lists.gnu.org/archive/html/qemu-devel/2020-12/msg01318.= html [Patch v1]: https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg05950.= html