From patchwork Thu Jun 17 02:47:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1059C48BE8 for ; Thu, 17 Jun 2021 02:55:15 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 214EC6102A for ; Thu, 17 Jun 2021 02:55:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 214EC6102A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiBW-0005L3-5z for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:55:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAV-0003NB-8T for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:11 -0400 Received: from mga02.intel.com ([134.134.136.20]:12080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAR-0000WF-4R for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:11 -0400 IronPort-SDR: 65gGfd1kQEoC1I+Nw1ODBhLSnrO8cebNuHKWoHm6z41SKw6hZLkmJWRUIUUJUTz/MdRruSWgju M5nKEUFEPzJg== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414073" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414073" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:53:59 -0700 IronPort-SDR: HzGyDcsrEos6HP8Fkf24V/WvQeIVvu1YvENReHsUfYxpmNSkI/J+ZRfcELzACw9+nGILHNrni4 ipGkzwP1tx/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485121914" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:53:57 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 1/7] Some minor optimizations for COLO Date: Thu, 17 Jun 2021 10:47:09 +0800 Message-Id: <1623898035-18533-2-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Rao, Lei" Signed-off-by: Lei Rao Reviewed-by: Dr. David Alan Gilbert --- 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 79fa1f6..616dc00 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); /* * Wake up COLO thread which may blocked in recv() or send(), diff --git a/net/colo-compare.c b/net/colo-compare.c index b100e7b..4a64a5d 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; } - return !memcmp(str, buf, strlen(str)); + return !memcmp(str, buf, packet_len); } static void notify_remote_frame(CompareState *s) From patchwork Thu Jun 17 02:47:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58FC8C48BE5 for ; Thu, 17 Jun 2021 02:56:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 185F96101A for ; Thu, 17 Jun 2021 02:56:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 185F96101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiCo-0000yk-9X for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:56:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAX-0003Oa-5e for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:14 -0400 Received: from mga02.intel.com ([134.134.136.20]:12085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAT-0000Yo-45 for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:12 -0400 IronPort-SDR: olMT3FqYWu2/KVqyTmGfBSNMdazmTAsU20cMThmhcJgi4m6jMG3qz2ZolUPbMfGYkMFrtNUCZT xxmGKUYaW7kw== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414076" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414076" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:03 -0700 IronPort-SDR: 3HgTLM7SF6E9fgxNSInw3sVFZtv2KLBhBYc24Q7TqJvdcRgcWfzMZWO9xw4GUX6LqPf2G1wOe/ dDY5stQ9twpA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485121944" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:00 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 2/7] Fixed qemu crash when guest power off in COLO mode Date: Thu, 17 Jun 2021 10:47:10 +0800 Message-Id: <1623898035-18533-3-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50 1 0x00007faa3d613859 in __GI_abort () at abort.c:79 2 0x000055c5a21268fd in runstate_set (new_state=RUN_STATE_RUNNING) at vl.c:723 3 0x000055c5a1f8cae4 in vm_prepare_start () at /home/workspace/colo-qemu/cpus.c:2206 4 0x000055c5a1f8cb1b in vm_start () at /home/workspace/colo-qemu/cpus.c:2213 5 0x000055c5a2332bba in migration_iteration_finish (s=0x55c5a4658810) at migration/migration.c:3376 6 0x000055c5a2332f3b in migration_thread (opaque=0x55c5a4658810) at migration/migration.c:3527 7 0x000055c5a251d68a in qemu_thread_start (args=0x55c5a5491a70) at util/qemu-thread-posix.c:519 8 0x00007faa3d7e9609 in start_thread (arg=) at pthread_create.c:477 9 0x00007faa3d710293 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Signed-off-by: Lei Rao --- migration/migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 4228635..c2c84c7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -3561,7 +3561,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); From patchwork Thu Jun 17 02:47:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326409 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B37D9C48BE5 for ; Thu, 17 Jun 2021 02:58:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7A4B06112D for ; Thu, 17 Jun 2021 02:58:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7A4B06112D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:43172 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiEp-0004mE-C1 for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37478) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAc-0003T2-Pn for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:20 -0400 Received: from mga02.intel.com ([134.134.136.20]:12066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAT-0000Pu-1N for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:18 -0400 IronPort-SDR: 2it6plXCZEjHRbPVY6bPcQ8tKdiPVXZ6bW1ubxuJE8FqevzURahJvZotMPZ6vStyYy6kygclgh JUvt2hWz8XPg== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414084" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414084" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:06 -0700 IronPort-SDR: 3agVnx3SfQgMNv0FLsMirnDU7soUnThECDK5jd17giBh4hJnHZH8yq98d028u4mpwnQ9EDukU1 +5xAZwUdHzXA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485121960" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:04 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 3/7] Fixed SVM hang when do failover before PVM crash Date: Thu, 17 Jun 2021 10:47:11 +0800 Message-Id: <1623898035-18533-4-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Rao, Lei" This patch fixed as follows: Thread 1 (Thread 0x7f34ee738d80 (LWP 11212)): #0 __pthread_clockjoin_ex (threadid=139847152957184, thread_return=0x7f30b1febf30, clockid=, abstime=, block=) at pthread_join_common.c:145 #1 0x0000563401998e36 in qemu_thread_join (thread=0x563402d66610) at util/qemu-thread-posix.c:587 #2 0x00005634017a79fa in process_incoming_migration_co (opaque=0x0) at migration/migration.c:502 #3 0x00005634019b59c9 in coroutine_trampoline (i0=63395504, i1=22068) at util/coroutine-ucontext.c:115 #4 0x00007f34ef860660 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__start_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=futex@entry=0x56340218ffa0 , private=0) at lowlevellock.c:52 #1 0x00007f34efa000a3 in _GI__pthread_mutex_lock (mutex=0x56340218ffa0 ) at ../nptl/pthread_mutex_lock.c:80 #2 0x0000563401997f99 in qemu_mutex_lock_impl (mutex=0x56340218ffa0 , file=0x563401b7a80e "migration/colo.c", line=806) at util/qemu-thread-posix.c:78 #3 0x0000563401407144 in qemu_mutex_lock_iothread_impl (file=0x563401b7a80e "migration/colo.c", line=806) at /home/workspace/colo-qemu/cpus.c:1899 #4 0x00005634017ba8e8 in colo_process_incoming_thread (opaque=0x563402d664c0) at migration/colo.c:806 #5 0x0000563401998b72 in qemu_thread_start (args=0x5634039f8370) at util/qemu-thread-posix.c:519 #6 0x00007f34ef9fd609 in start_thread (arg=) at pthread_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 = {lock = {_data = {lock = 2, __count = 0, __owner = 11212, __nusers = 9, __kind = 0, __spins = 0, __elision = 0, __list = {_prev = 0x0, __next = 0x0}}, __size = "\002\000\000\000\000\000\000\000\314+\000\000\t", '\000' , __align = 2}, file = 0x563401c07e4b "util/main-loop.c", line = 240, initialized = true} From the call trace, we can see it is a deadlock bug. and the QEMU main thread 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 should release the qemu_global_mutex before waiting colo thread ends. Signed-off-by: Lei Rao Reviewed-by: Li Zhijian --- migration/migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/migration.c b/migration/migration.c index c2c84c7..6debb8b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -593,8 +593,10 @@ static void process_incoming_migration_co(void *opaque) mis->have_colo_incoming_thread = true; qemu_coroutine_yield(); + 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(); } From patchwork Thu Jun 17 02:47:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E371C48BE8 for ; Thu, 17 Jun 2021 02:57:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F22E86112D for ; Thu, 17 Jun 2021 02:57:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F22E86112D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiE1-0003Kq-3f for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAb-0003Rm-I6 for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:17 -0400 Received: from mga02.intel.com ([134.134.136.20]:12080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAW-0000WF-8H for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:17 -0400 IronPort-SDR: bLHgxVLaxY6IjAXUhryxHK7/wdUYJpefBB35+NoA7J90rUP6/a79YDZKVjIcvnsIZBWwxkABxI jAKNzWxhY2Ow== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414092" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414092" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:10 -0700 IronPort-SDR: 8V5XrbXKSKf/yNBj5igBXZvG6SM3Safgj0GJNfUBgCu7SkZcOr6gqG1JcThSAMB3X9mX/J1H7o mnr7xS9MVdwQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485121984" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:07 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 4/7] colo: fixed 'Segmentation fault' when the simplex mode PVM poweroff Date: Thu, 17 Jun 2021 10:47:12 +0800 Message-Id: <1623898035-18533-5-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org, Like Xu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: "Rao, Lei" When a PVM completed its SVM failover steps and begins to run in the simplex mode, QEMU would encounter a 'Segmentation fault' if the guest poweroff with the following calltrace: Program received signal SIGSEGV, Segmentation fault. This is because primary_vm_do_failover() would call "qemu_file_shutdown (s->rp_state.from_dst_file);" and later the migration_shutdown() would do it again. So, we should set the s->rp_state.from_dst_file to NULL. Signed-off-by: Like Xu Signed-off-by: Lei Rao --- migration/colo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 616dc00..c25e488 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -156,14 +156,15 @@ static void primary_vm_do_failover(void) /* * Wake up COLO thread which may blocked in recv() or send(), - * The s->rp_state.from_dst_file and s->to_dst_file may use the - * same fd, but we still shutdown the fd for twice, it is harmless. + * The s->to_dst_file may use the same fd, but we still shutdown + * the fd for twice, it is harmless. */ if (s->to_dst_file) { qemu_file_shutdown(s->to_dst_file); } if (s->rp_state.from_dst_file) { qemu_file_shutdown(s->rp_state.from_dst_file); + s->rp_state.from_dst_file = NULL; } old_state = failover_set_state(FAILOVER_STATUS_ACTIVE, From patchwork Thu Jun 17 02:47:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5A28C48BE5 for ; Thu, 17 Jun 2021 02:55:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3E962611CA for ; Thu, 17 Jun 2021 02:55:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3E962611CA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiBf-0005cr-Ey for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:55:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAk-0003Zv-Tz for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:12085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAY-0000Yo-On for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:26 -0400 IronPort-SDR: +9Lprl/cebPdlpkzmcYtTaBIw8nJqyRTYX9xisL95y+dBf5h7DRhVIelfSD3g8MJhYfr+uwtoH 7+Jj7CjmzCLA== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414095" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414095" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:13 -0700 IronPort-SDR: rSJPXVuu+SCD/waiHj0I0/14nN3XuKv3e0jkbcR+tkHm+QLZZiBZZ8FO5rHMgkSxfwcXfibKmq 1j5MMu/5+CBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485121991" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:11 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 5/7] Removed the qemu_fclose() in colo_process_incoming_thread Date: Thu, 17 Jun 2021 10:47:13 +0800 Message-Id: <1623898035-18533-6-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- migration/colo.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index c25e488..e2ab349 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 = NULL; - } rcu_unregister_thread(); return NULL; From patchwork Thu Jun 17 02:47:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326411 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F236EC48BE5 for ; Thu, 17 Jun 2021 02:59:47 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AFBBF613E4 for ; Thu, 17 Jun 2021 02:59:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AFBBF613E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiFu-0006Co-Sr for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:59:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37518) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAk-0003Yu-FA for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:26 -0400 Received: from mga02.intel.com ([134.134.136.20]:12080) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAc-0000WF-4O for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:26 -0400 IronPort-SDR: snXQSQqCYLZBe/+boKdEPUW3n+AYBHxdjDEOASyhH+CsBcFUW4vAORZ/ctAUc8yT0sz3xk62m3 PbXKZBkHyJsw== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414098" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414098" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:17 -0700 IronPort-SDR: U2XXZSvjLVnOy5UnOL/Nkyrw1MawMgJpgjS79vxS1sY3QKpnTuuYf6a6Y5wJOD6/mXjgHBubtf ABYGVhJFrJOQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485122000" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:14 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 6/7] Changed the last-mode to none of first start COLO Date: Thu, 17 Jun 2021 10:47:14 +0800 Message-Id: <1623898035-18533-7-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- migration/colo.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index e2ab349..69a2501 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -206,7 +206,7 @@ void colo_do_failover(void) vm_stop_force_state(RUN_STATE_COLO); } - switch (get_colo_mode()) { + switch (last_colo_mode = get_colo_mode()) { case COLO_MODE_PRIMARY: primary_vm_do_failover(); break; @@ -531,8 +531,7 @@ static void colo_process_checkpoint(MigrationState *s) Error *local_err = NULL; int ret; - last_colo_mode = get_colo_mode(); - if (last_colo_mode != COLO_MODE_PRIMARY) { + if (get_colo_mode() != 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); - last_colo_mode = get_colo_mode(); - if (last_colo_mode != COLO_MODE_SECONDARY) { + if (get_colo_mode() != COLO_MODE_SECONDARY) { error_report("COLO mode must be COLO_MODE_SECONDARY"); return NULL; } From patchwork Thu Jun 17 02:47:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rao, Lei" X-Patchwork-Id: 12326405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DA16C48BE8 for ; Thu, 17 Jun 2021 02:56:40 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 669E36101A for ; Thu, 17 Jun 2021 02:56:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 669E36101A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:37754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltiCs-00018w-Pc for qemu-devel@archiver.kernel.org; Wed, 16 Jun 2021 22:56:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAl-0003b2-CS for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:27 -0400 Received: from mga02.intel.com ([134.134.136.20]:12066) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltiAg-0000Pu-2l for qemu-devel@nongnu.org; Wed, 16 Jun 2021 22:54:27 -0400 IronPort-SDR: TOhPJaXEAt4Ug5M3bfszuDBzELSgUaNud409i9qG1wkT36ugi5UsgmFHiFqqibPCXq8uiKOqFs 7Xb8lHq4t2LQ== X-IronPort-AV: E=McAfee;i="6200,9189,10017"; a="193414107" X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="193414107" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Jun 2021 19:54:20 -0700 IronPort-SDR: IDvcIGLkx1skp1pYjbHntnJ4fQmmmADRggrUMosnv+QiTwA2vE7AES7KTqTsfKNmLEZHjJs8HQ jsPAzJENfpyg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,278,1616482800"; d="scan'208";a="485122013" Received: from unknown (HELO localhost.localdomain.bj.intel.com) ([10.238.157.59]) by orsmga001.jf.intel.com with ESMTP; 16 Jun 2021 19:54:18 -0700 From: Lei Rao To: chen.zhang@intel.com, lizhijian@cn.fujitsu.com, jasowang@redhat.com, zhang.zhanghailiang@huawei.com, quintela@redhat.com, dgilbert@redhat.com, lukasstraub2@web.de Subject: [PATCH 7/7] Optimized the function of fill_connection_key. Date: Thu, 17 Jun 2021 10:47:15 +0800 Message-Id: <1623898035-18533-8-git-send-email-lei.rao@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1623898035-18533-1-git-send-email-lei.rao@intel.com> References: <1623898035-18533-1-git-send-email-lei.rao@intel.com> Received-SPF: pass client-ip=134.134.136.20; envelope-from=lei.rao@intel.com; helo=mga02.intel.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: like.xu.linux@gmail.com, "Rao, Lei" , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 4a64a5d..6a1354d 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -264,7 +264,7 @@ static int packet_enqueue(CompareState *s, int mode, Connection **con) pkt = NULL; return -1; } - fill_connection_key(pkt, &key); + fill_connection_key(pkt, &key, 0); conn = connection_get(s->connection_track_table, &key, diff --git a/net/colo.c b/net/colo.c index 3a3e6e8..5e7232c 100644 --- a/net/colo.c +++ b/net/colo.c @@ -83,19 +83,26 @@ int parse_packet_early(Packet *pkt) return 0; } -void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, Packet *pkt) +void extract_ip_and_port(uint32_t tmp_ports, ConnectionKey *key, + Packet *pkt, int reverse) { + if (reverse) { + key->src = pkt->ip->ip_dst; + key->dst = pkt->ip->ip_src; + key->src_port = ntohs(tmp_ports & 0xffff); + key->dst_port = ntohs(tmp_ports >> 16); + } else { key->src = pkt->ip->ip_src; key->dst = pkt->ip->ip_dst; key->src_port = ntohs(tmp_ports >> 16); key->dst_port = ntohs(tmp_ports & 0xffff); + } } -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 = 0; - memset(key, 0, sizeof(*key)); key->ip_proto = pkt->ip->ip_p; switch (key->ip_proto) { @@ -106,29 +113,15 @@ void fill_connection_key(Packet *pkt, ConnectionKey *key) case IPPROTO_SCTP: case IPPROTO_UDPLITE: tmp_ports = *(uint32_t *)(pkt->transport_header); - extract_ip_and_port(tmp_ports, key, pkt); break; case IPPROTO_AH: tmp_ports = *(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 = key->src; - key->src = key->dst; - key->dst = tmp_ip; - tmp_port = key->src_port; - key->src_port = key->dst_port; - key->dst_port = tmp_port; + extract_ip_and_port(tmp_ports, key, pkt, reverse); } Connection *connection_new(ConnectionKey *key) diff --git a/net/colo.h b/net/colo.h index d91cd24..5f4d502 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 *pkt); -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 cb3a96c..bf05023 100644 --- a/net/filter-rewriter.c +++ b/net/filter-rewriter.c @@ -279,15 +279,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterState *nf, */ if (pkt && is_tcp_packet(pkt)) { - fill_connection_key(pkt, &key); - - if (sender == nf->netdev) { - /* - * We need make tcp TX and RX packet - * into one connection. - */ - reverse_connection_key(&key); - } + fill_connection_key(pkt, &key, sender == nf->netdev); /* After failover we needn't change new TCP packet */ if (s->failover_mode &&