From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163575401813417.38310574450429; Mon, 1 Nov 2021 01:06:58 -0700 (PDT) Received: from localhost ([::1]:41460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSLJ-0005uX-5Z for importer@patchew.org; Mon, 01 Nov 2021 04:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60904) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJs-0003BJ-2q for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:28 -0400 Received: from mga11.intel.com ([192.55.52.93]:46959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJl-0004Gy-M9 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:26 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:16 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:13 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="228421360" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="228421360" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541503" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 1/7] Some minor optimizations for COLO Date: Mon, 1 Nov 2021 15:56:59 +0800 Message-Id: <1635753425-11756-2-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.93; envelope-from=lei.rao@intel.com; helo=mga11.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754020338100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" Signed-off-by: Lei Rao Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/colo.c | 2 +- net/colo-compare.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 79fa1f6619..616dc00af7 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -152,7 +152,7 @@ static void primary_vm_do_failover(void) * kick COLO thread which might wait at * qemu_sem_wait(&s->colo_checkpoint_sem). */ - colo_checkpoint_notify(migrate_get_current()); + colo_checkpoint_notify(s); =20 /* * Wake up COLO thread which may blocked in recv() or send(), diff --git a/net/colo-compare.c b/net/colo-compare.c index b100e7b51f..4a64a5d386 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -170,7 +170,7 @@ static bool packet_matches_str(const char *str, return false; } =20 - return !memcmp(str, buf, strlen(str)); + return !memcmp(str, buf, packet_len); } =20 static void notify_remote_frame(CompareState *s) --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754018533253.55120130597868; Mon, 1 Nov 2021 01:06:58 -0700 (PDT) Received: from localhost ([::1]:41512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSLJ-0005wD-Jx for importer@patchew.org; Mon, 01 Nov 2021 04:06:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60918) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJu-0003Bu-IH for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:30 -0400 Received: from mga11.intel.com ([192.55.52.93]:46961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJo-0004Id-JK for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:29 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:21 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:18 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="228421366" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="228421366" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541535" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 2/7] Fixed qemu crash when guest power off in COLO mode Date: Mon, 1 Nov 2021 15:57:00 +0800 Message-Id: <1635753425-11756-3-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.93; envelope-from=lei.rao@intel.com; helo=mga11.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754020473100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" This patch fixes the following: qemu-system-x86_64: invalid runstate transition: 'shutdown' -> 'running' Aborted (core dumped) The gdb bt as following: 0 __GI_raise (sig=3Dsig@entry=3D6) at ../sysdeps/unix/sysv/linux/raise.c:50 1 0x00007faa3d613859 in __GI_abort () at abort.c:79 2 0x000055c5a21268fd in runstate_set (new_state=3DRUN_STATE_RUNNING) at vl= .c:723 3 0x000055c5a1f8cae4 in vm_prepare_start () at /home/workspace/colo-qemu/c= pus.c:2206 4 0x000055c5a1f8cb1b in vm_start () at /home/workspace/colo-qemu/cpus.c:22= 13 5 0x000055c5a2332bba in migration_iteration_finish (s=3D0x55c5a4658810) at= migration/migration.c:3376 6 0x000055c5a2332f3b in migration_thread (opaque=3D0x55c5a4658810) at migr= ation/migration.c:3527 7 0x000055c5a251d68a in qemu_thread_start (args=3D0x55c5a5491a70) at util/= qemu-thread-posix.c:519 8 0x00007faa3d7e9609 in start_thread (arg=3D) at pthread_cr= eate.c:477 9 0x00007faa3d710293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clon= e.S:95 Signed-off-by: Lei Rao Reviewed-by: Juan Quintela --- migration/migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 9172686b89..e5b38a492f 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3616,7 +3616,9 @@ static void migration_iteration_finish(MigrationState= *s) case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: if (s->vm_was_running) { - vm_start(); + if (!runstate_check(RUN_STATE_SHUTDOWN)) { + vm_start(); + } } else { if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { runstate_set(RUN_STATE_POSTMIGRATE); --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754155913819.070548826639; Mon, 1 Nov 2021 01:09:15 -0700 (PDT) Received: from localhost ([::1]:49890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSNX-00033X-17 for importer@patchew.org; Mon, 01 Nov 2021 04:09:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60970) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJz-0003NP-Nr for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:35 -0400 Received: from mga11.intel.com ([192.55.52.93]:46959) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJt-0004Gy-A7 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:35 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:25 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:22 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="228421380" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="228421380" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541548" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 3/7] Fixed SVM hang when do failover before PVM crash Date: Mon, 1 Nov 2021 15:57:01 +0800 Message-Id: <1635753425-11756-4-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.93; envelope-from=lei.rao@intel.com; helo=mga11.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754157511100002 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" This patch fixed as follows: Thread 1 (Thread 0x7f34ee738d80 (LWP 11212)): #0 __pthread_clockjoin_ex (threadid=3D139847152957184, thread_return=3D= 0x7f30b1febf30, clockid=3D, abstime=3D, block= =3D) at pthread_join_common.c:145 #1 0x0000563401998e36 in qemu_thread_join (thread=3D0x563402d66610) at = util/qemu-thread-posix.c:587 #2 0x00005634017a79fa in process_incoming_migration_co (opaque=3D0x0) a= t migration/migration.c:502 #3 0x00005634019b59c9 in coroutine_trampoline (i0=3D63395504, i1=3D2206= 8) at util/coroutine-ucontext.c:115 #4 0x00007f34ef860660 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__s= tart_context.S:91 from /lib/x86_64-linux-gnu/libc.so.6 #5 0x00007f30b21ee730 in ?? () #6 0x0000000000000000 in ?? () Thread 13 (Thread 0x7f30b3dff700 (LWP 11747)): #0 __lll_lock_wait (futex=3Dfutex@entry=3D0x56340218ffa0 , private=3D0) at lowlevellock.c:52 #1 0x00007f34efa000a3 in _GI__pthread_mutex_lock (mutex=3D0x56340218ff= a0 ) at ../nptl/pthread_mutex_lock.c:80 #2 0x0000563401997f99 in qemu_mutex_lock_impl (mutex=3D0x56340218ffa0 = , file=3D0x563401b7a80e "migration/colo.c", line=3D806) = at util/qemu-thread-posix.c:78 #3 0x0000563401407144 in qemu_mutex_lock_iothread_impl (file=3D0x56340= 1b7a80e "migration/colo.c", line=3D806) at /home/workspace/colo-qemu/cpus.c= :1899 #4 0x00005634017ba8e8 in colo_process_incoming_thread (opaque=3D0x5634= 02d664c0) at migration/colo.c:806 #5 0x0000563401998b72 in qemu_thread_start (args=3D0x5634039f8370) at = util/qemu-thread-posix.c:519 #6 0x00007f34ef9fd609 in start_thread (arg=3D) at pthre= ad_create.c:477 #7 0x00007f34ef924293 in clone () at ../sysdeps/unix/sysv/linux/x86_64= /clone.S:95 The QEMU main thread is holding the lock: (gdb) p qemu_global_mutex $1 =3D {lock =3D {_data =3D {lock =3D 2, __count =3D 0, __owner =3D 112= 12, __nusers =3D 9, __kind =3D 0, __spins =3D 0, __elision =3D 0, __list = =3D {_prev =3D 0x0, __next =3D 0x0}}, __size =3D "\002\000\000\000\000\000\000\000\314+\000\000\t", '\000' <= repeats 26 times>, __align =3D 2}, file =3D 0x563401c07e4b "util/main-loop.= c", line =3D 240, initialized =3D true} From the call trace, we can see it is a deadlock bug. and the QEMU main thr= ead holds the global mutex to wait until the COLO thread ends. and the colo= thread wants to acquire the global mutex, which will cause a deadlock. So, we shou= ld release the qemu_global_mutex before waiting colo thread ends. Signed-off-by: Lei Rao Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index e5b38a492f..811097c423 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -587,8 +587,10 @@ static void process_incoming_migration_co(void *opaque) mis->have_colo_incoming_thread =3D true; qemu_coroutine_yield(); =20 + qemu_mutex_unlock_iothread(); /* Wait checkpoint incoming thread exit before free resource */ qemu_thread_join(&mis->colo_incoming_thread); + qemu_mutex_lock_iothread(); /* We hold the global iothread lock, so it is safe here */ colo_release_ram_cache(); } --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754089579392.1849265029937; Mon, 1 Nov 2021 01:08:09 -0700 (PDT) Received: from localhost ([::1]:45458 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSMS-00006s-KA for importer@patchew.org; Mon, 01 Nov 2021 04:08:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJy-0003Jb-Oj for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:34 -0400 Received: from mga11.intel.com ([192.55.52.93]:46978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSJv-0004NE-9a for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:33 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:29 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:26 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="228421398" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="228421398" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541588" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 4/7] colo: fixed 'Segmentation fault' when the simplex mode PVM poweroff Date: Mon, 1 Nov 2021 15:57:02 +0800 Message-Id: <1635753425-11756-5-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.93; envelope-from=lei.rao@intel.com; helo=mga11.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754090411100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" The GDB statck is as follows: Program terminated with signal SIGSEGV, Segmentation fault. 0 object_class_dynamic_cast (class=3D0x55c8f5d2bf50, typename=3D0x55c8f2f7= 379e "qio-channel") at qom/object.c:832 if (type->class->interfaces && [Current thread is 1 (Thread 0x7f756e97eb00 (LWP 1811577))] (gdb) bt 0 object_class_dynamic_cast (class=3D0x55c8f5d2bf50, typename=3D0x55c8f2f7= 379e "qio-channel") at qom/object.c:832 1 0x000055c8f2c3dd14 in object_dynamic_cast (obj=3D0x55c8f543ac00, typenam= e=3D0x55c8f2f7379e "qio-channel") at qom/object.c:763 2 0x000055c8f2c3ddce in object_dynamic_cast_assert (obj=3D0x55c8f543ac00, = typename=3D0x55c8f2f7379e "qio-channel", file=3D0x55c8f2f73780 "migration/qemu-file-channel.c", line=3D117, func= =3D0x55c8f2f73800 <__func__.18724> "channel_shutdown") at qom/object.c:786 3 0x000055c8f2bbc6ac in channel_shutdown (opaque=3D0x55c8f543ac00, rd=3Dtr= ue, wr=3Dtrue, errp=3D0x0) at migration/qemu-file-channel.c:117 4 0x000055c8f2bba56e in qemu_file_shutdown (f=3D0x7f7558070f50) at migrati= on/qemu-file.c:67 5 0x000055c8f2ba5373 in migrate_fd_cancel (s=3D0x55c8f4ccf3f0) at migratio= n/migration.c:1699 6 0x000055c8f2ba1992 in migration_shutdown () at migration/migration.c:187 7 0x000055c8f29a5b77 in main (argc=3D69, argv=3D0x7fff3e9e8c08, envp=3D0x7= fff3e9e8e38) at vl.c:4512 The root cause is that we still want to shutdown the from_dst_file in migrate_fd_cancel() after qemu_close in colo_process_checkpoint(). So, we should set the s->rp_state.from_dst_file =3D NULL after qemu_close(). Signed-off-by: Lei Rao Reviewed-by: Juan Quintela --- migration/colo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/colo.c b/migration/colo.c index 616dc00af7..907241ab5c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -640,6 +640,7 @@ out: */ if (s->rp_state.from_dst_file) { qemu_fclose(s->rp_state.from_dst_file); + s->rp_state.from_dst_file =3D NULL; } } =20 --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754155194241.60777061565852; Mon, 1 Nov 2021 01:09:15 -0700 (PDT) Received: from localhost ([::1]:49786 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSNW-0002zH-6m for importer@patchew.org; Mon, 01 Nov 2021 04:09:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK2-0003Vb-IH for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:38 -0400 Received: from mga14.intel.com ([192.55.52.115]:3675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK0-0004O6-Ln for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:38 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:35 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:32 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="231231355" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="231231355" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541619" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 5/7] Removed the qemu_fclose() in colo_process_incoming_thread Date: Mon, 1 Nov 2021 15:57:03 +0800 Message-Id: <1635753425-11756-6-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.115; envelope-from=lei.rao@intel.com; helo=mga14.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754157504100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" After the live migration, the related fd will be cleanup in migration_incoming_state_destroy(). So, the qemu_close() in colo_process_incoming_thread is not necessary. Signed-off-by: Lei Rao Reviewed-by: Juan Quintela --- migration/colo.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 907241ab5c..71fc82a040 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -919,11 +919,6 @@ out: /* Hope this not to be too long to loop here */ qemu_sem_wait(&mis->colo_incoming_sem); qemu_sem_destroy(&mis->colo_incoming_sem); - /* Must be called after failover BH is completed */ - if (mis->to_src_file) { - qemu_fclose(mis->to_src_file); - mis->to_src_file =3D NULL; - } =20 rcu_unregister_thread(); return NULL; --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754185491518.8456888142528; Mon, 1 Nov 2021 01:09:45 -0700 (PDT) Received: from localhost ([::1]:52650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSO0-0004st-Hw for importer@patchew.org; Mon, 01 Nov 2021 04:09:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK5-0003fL-D2 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:41 -0400 Received: from mga14.intel.com ([192.55.52.115]:3675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK3-0004O6-FQ for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:41 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:38 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:35 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="231231360" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="231231360" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541637" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 6/7] Changed the last-mode to none of first start COLO Date: Mon, 1 Nov 2021 15:57:04 +0800 Message-Id: <1635753425-11756-7-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.115; envelope-from=lei.rao@intel.com; helo=mga14.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754187359100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" When we first stated the COLO, the last-mode is as follows: { "execute": "query-colo-status" } {"return": {"last-mode": "primary", "mode": "primary", "reason": "none"}} The last-mode is unreasonable. After the patch, will be changed to the following: { "execute": "query-colo-status" } {"return": {"last-mode": "none", "mode": "primary", "reason": "none"}} Signed-off-by: Lei Rao Reviewed-by: Juan Quintela --- migration/colo.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 71fc82a040..e3b1f136f4 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -205,7 +205,7 @@ void colo_do_failover(void) vm_stop_force_state(RUN_STATE_COLO); } =20 - switch (get_colo_mode()) { + switch (last_colo_mode =3D get_colo_mode()) { case COLO_MODE_PRIMARY: primary_vm_do_failover(); break; @@ -530,8 +530,7 @@ static void colo_process_checkpoint(MigrationState *s) Error *local_err =3D NULL; int ret; =20 - last_colo_mode =3D get_colo_mode(); - if (last_colo_mode !=3D COLO_MODE_PRIMARY) { + if (get_colo_mode() !=3D COLO_MODE_PRIMARY) { error_report("COLO mode must be COLO_MODE_PRIMARY"); return; } @@ -830,8 +829,7 @@ void *colo_process_incoming_thread(void *opaque) migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO); =20 - last_colo_mode =3D get_colo_mode(); - if (last_colo_mode !=3D COLO_MODE_SECONDARY) { + if (get_colo_mode() !=3D COLO_MODE_SECONDARY) { error_report("COLO mode must be COLO_MODE_SECONDARY"); return NULL; } --=20 2.30.2 From nobody Sun Feb 8 19:12:49 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; dmarc=fail(p=none dis=none) header.from=intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1635754236741697.2283242481753; Mon, 1 Nov 2021 01:10:36 -0700 (PDT) Received: from localhost ([::1]:55172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mhSOp-0006Yk-S3 for importer@patchew.org; Mon, 01 Nov 2021 04:10:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK9-0003mb-C4 for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:48 -0400 Received: from mga14.intel.com ([192.55.52.115]:3675) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhSK7-0004O6-LF for qemu-devel@nongnu.org; Mon, 01 Nov 2021 04:05:45 -0400 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2021 01:05:42 -0700 Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.156.105]) by orsmga007.jf.intel.com with ESMTP; 01 Nov 2021 01:05:39 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10154"; a="231231371" X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="231231371" X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,198,1631602800"; d="scan'208";a="488541652" From: "Rao, Lei" To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, lukasstraub2@web.de, dgilbert@redhat.com Subject: [PATCH v2 7/7] Optimized the function of fill_connection_key. Date: Mon, 1 Nov 2021 15:57:05 +0800 Message-Id: <1635753425-11756-8-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1635753425-11756-1-git-send-email-lei.rao@intel.com> References: <1635753425-11756-1-git-send-email-lei.rao@intel.com> 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=192.55.52.115; envelope-from=lei.rao@intel.com; helo=mga14.intel.com 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: , Cc: "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1635754237142100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Rao, Lei" Remove some unnecessary code to improve the performance of the filter-rewriter module. Signed-off-by: Lei Rao Reviewed-by: Zhang Chen Reviewed-by: Juan Quintela --- net/colo-compare.c | 2 +- net/colo.c | 31 ++++++++++++------------------- net/colo.h | 6 +++--- net/filter-rewriter.c | 10 +--------- 4 files changed, 17 insertions(+), 32 deletions(-) diff --git a/net/colo-compare.c b/net/colo-compare.c index 4a64a5d386..6a1354dcb1 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -264,7 +264,7 @@ static int packet_enqueue(CompareState *s, int mode, Co= nnection **con) pkt =3D NULL; return -1; } - fill_connection_key(pkt, &key); + fill_connection_key(pkt, &key, 0); =20 conn =3D connection_get(s->connection_track_table, &key, diff --git a/net/colo.c b/net/colo.c index 3a3e6e89a0..5e7232ce47 100644 --- a/net/colo.c +++ b/net/colo.c @@ -83,19 +83,26 @@ int parse_packet_early(Packet *pkt) return 0; } =20 -void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *p= kt) +void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, + Packet *pkt, int reverse) { + if (reverse) { + key->src =3D pkt->ip->ip_dst; + key->dst =3D pkt->ip->ip_src; + key->src_port =3D ntohs(tmp_ports & 0xffff); + key->dst_port =3D ntohs(tmp_ports >> 16); + } else { key->src =3D pkt->ip->ip_src; key->dst =3D pkt->ip->ip_dst; key->src_port =3D ntohs(tmp_ports >> 16); key->dst_port =3D ntohs(tmp_ports & 0xffff); + } } =20 -void fill_connection_key(Packet *pkt, ConnectionKey *key) +void fill_connection_key(Packet *pkt, ConnectionKey *key, int reverse) { - uint32_t tmp_ports; + uint32_t tmp_ports =3D 0; =20 - memset(key, 0, sizeof(*key)); key->ip_proto =3D pkt->ip->ip_p; =20 switch (key->ip_proto) { @@ -106,29 +113,15 @@ void fill_connection_key(Packet *pkt, ConnectionKey *= key) case IPPROTO_SCTP: case IPPROTO_UDPLITE: tmp_ports =3D *(uint32_t *)(pkt->transport_header); - extract_ip_and_port(tmp_ports, key, pkt); break; case IPPROTO_AH: tmp_ports =3D *(uint32_t *)(pkt->transport_header + 4); - extract_ip_and_port(tmp_ports, key, pkt); break; default: break; } -} - -void reverse_connection_key(ConnectionKey *key) -{ - struct in_addr tmp_ip; - uint16_t tmp_port; - - tmp_ip =3D key->src; - key->src =3D key->dst; - key->dst =3D tmp_ip; =20 - tmp_port =3D key->src_port; - key->src_port =3D key->dst_port; - key->dst_port =3D tmp_port; + extract_ip_and_port(tmp_ports, key, pkt, reverse); } =20 Connection *connection_new(ConnectionKey *key) diff --git a/net/colo.h b/net/colo.h index d91cd245c4..5f4d502df3 100644 --- a/net/colo.h +++ b/net/colo.h @@ -89,9 +89,9 @@ typedef struct Connection { uint32_t connection_key_hash(const void *opaque); int connection_key_equal(const void *opaque1, const void *opaque2); int parse_packet_early(Packet *pkt); -void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *p= kt); -void fill_connection_key(Packet *pkt, ConnectionKey *key); -void reverse_connection_key(ConnectionKey *key); +void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, + Packet *pkt, int reverse); +void fill_connection_key(Packet *pkt, ConnectionKey *key, int reverse); Connection *connection_new(ConnectionKey *key); void connection_destroy(void *opaque); Connection *connection_get(GHashTable *connection_track_table, diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c index cb3a96cde1..bf05023dc3 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -279,15 +279,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterStat= e *nf, */ if (pkt && is_tcp_packet(pkt)) { =20 - fill_connection_key(pkt, &key); - - if (sender =3D=3D nf->netdev) { - /* - * We need make tcp TX and RX packet - * into one connection. - */ - reverse_connection_key(&key); - } + fill_connection_key(pkt, &key, sender =3D=3D nf->netdev); =20 /* After failover we needn't change new TCP packet */ if (s->failover_mode && --=20 2.30.2