From patchwork Thu Feb 28 16:55:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833463 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E331139A for ; Thu, 28 Feb 2019 16:59:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35AE02F2C0 for ; Thu, 28 Feb 2019 16:59:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A0142F2E2; Thu, 28 Feb 2019 16:59:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E3D412F2C0 for ; Thu, 28 Feb 2019 16:59:58 +0000 (UTC) Received: from localhost ([127.0.0.1]:42952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP2L-0005HC-OZ for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 11:59:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP12-0005G2-Tz for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP11-0007G0-BV for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:36 -0500 Received: from mga17.intel.com ([192.55.52.151]:63409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP11-0007Dq-2Z for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:35 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431760" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:30 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:02 +0800 Message-Id: <20190228165508.21594-2-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 1/7] Migration/colo.c: Fix double close bug when occur COLO failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen In migration_incoming_state_destroy(void) will check the mis->to_src_file to double close the mis->to_src_file when occur COLO failover. Signed-off-by: Zhang Chen Reviewed-by: Dr. David Alan Gilbert --- migration/colo.c | 1 + 1 file changed, 1 insertion(+) diff --git a/migration/colo.c b/migration/colo.c index 398b239d1c..a916dc178c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -872,6 +872,7 @@ out: /* Must be called after failover BH is completed */ if (mis->to_src_file) { qemu_fclose(mis->to_src_file); + mis->to_src_file = NULL; } migration_incoming_disable_colo(); From patchwork Thu Feb 28 16:55:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB5A217E9 for ; Thu, 28 Feb 2019 17:03:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3F092F5E2 for ; Thu, 28 Feb 2019 17:03:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B83D02F5D7; Thu, 28 Feb 2019 17:03:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71E942F5DF for ; Thu, 28 Feb 2019 17:03:13 +0000 (UTC) Received: from localhost ([127.0.0.1]:43039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP5U-0000Uq-La for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:03:12 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP14-0005H8-U4 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP13-0007Go-AF for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:38 -0500 Received: from mga17.intel.com ([192.55.52.151]:63406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP12-0007D6-Uu for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:37 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431765" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:32 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:03 +0800 Message-Id: <20190228165508.21594-3-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 2/7] Migration/colo.c: Fix COLO failover status error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen When finished COLO failover, the status is FAILOVER_STATUS_COMPLETED. The origin codes misunderstand the FAILOVER_STATUS_REQUIRE. Signed-off-by: Zhang Chen --- migration/colo.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index a916dc178c..a13acac192 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -121,6 +121,7 @@ static void secondary_vm_do_failover(void) } /* Notify COLO incoming thread that failover work is finished */ qemu_sem_post(&mis->colo_incoming_sem); + /* For Secondary VM, jump to incoming co */ if (mis->migration_incoming_co) { qemu_coroutine_enter(mis->migration_incoming_co); @@ -262,7 +263,7 @@ COLOStatus *qmp_query_colo_status(Error **errp) case FAILOVER_STATUS_NONE: s->reason = COLO_EXIT_REASON_NONE; break; - case FAILOVER_STATUS_REQUIRE: + case FAILOVER_STATUS_COMPLETED: s->reason = COLO_EXIT_REASON_REQUEST; break; default: @@ -582,7 +583,7 @@ out: qapi_event_send_colo_exit(COLO_MODE_PRIMARY, COLO_EXIT_REASON_ERROR); break; - case FAILOVER_STATUS_REQUIRE: + case FAILOVER_STATUS_COMPLETED: qapi_event_send_colo_exit(COLO_MODE_PRIMARY, COLO_EXIT_REASON_REQUEST); break; @@ -854,7 +855,7 @@ out: qapi_event_send_colo_exit(COLO_MODE_SECONDARY, COLO_EXIT_REASON_ERROR); break; - case FAILOVER_STATUS_REQUIRE: + case FAILOVER_STATUS_COMPLETED: qapi_event_send_colo_exit(COLO_MODE_SECONDARY, COLO_EXIT_REASON_REQUEST); break; From patchwork Thu Feb 28 16:55:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4095617EF for ; Thu, 28 Feb 2019 17:06:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F7D2F573 for ; Thu, 28 Feb 2019 17:06:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 173282F58A; Thu, 28 Feb 2019 17:06:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C63082F573 for ; Thu, 28 Feb 2019 17:06:25 +0000 (UTC) Received: from localhost ([127.0.0.1]:43080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP8a-0001jF-6y for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:06:24 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP16-0005Ir-S9 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP14-0007I0-Ux for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:40 -0500 Received: from mga17.intel.com ([192.55.52.151]:63409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP13-0007Dq-A8 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431774" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:34 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:04 +0800 Message-Id: <20190228165508.21594-4-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 3/7] Migration/colo.c: Make COLO node running after failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen Delay to close COLO for auto start VM after failover. Signed-off-by: Zhang Chen Reviewed-by: Dr. David Alan Gilbert --- migration/colo.c | 1 - migration/migration.c | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/migration/colo.c b/migration/colo.c index a13acac192..89325952c7 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -875,7 +875,6 @@ out: qemu_fclose(mis->to_src_file); mis->to_src_file = NULL; } - migration_incoming_disable_colo(); rcu_unregister_thread(); return NULL; diff --git a/migration/migration.c b/migration/migration.c index 37e06b76dc..cec5f529c3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -383,6 +383,9 @@ static void process_incoming_migration_bh(void *opaque) } else { runstate_set(RUN_STATE_PAUSED); } + } else if (migration_incoming_colo_enabled()) { + migration_incoming_disable_colo(); + vm_start(); } else { runstate_set(global_state_get_runstate()); } From patchwork Thu Feb 28 16:55:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E521F15AC for ; Thu, 28 Feb 2019 17:03:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE1EE2F5DC for ; Thu, 28 Feb 2019 17:03:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC1B92F5E2; Thu, 28 Feb 2019 17:03:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6A1782F5DC for ; Thu, 28 Feb 2019 17:03:11 +0000 (UTC) Received: from localhost ([127.0.0.1]:43037 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP5S-0000Th-RV for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:03:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56923) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP1A-0005MG-Oy for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP19-0007JM-0s for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:44 -0500 Received: from mga17.intel.com ([192.55.52.151]:63406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP16-0007D6-SJ for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:42 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:38 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431783" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:36 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:05 +0800 Message-Id: <20190228165508.21594-5-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 4/7] Migration/colo.c: Add new COLOExitReason to handle all failover state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen In this patch we add the processing state for COLOExitReason, because we have to identify COLO in the failover processing state or failover error state. In the way, we can handle all the failover state. We have improved the description of the COLOExitReason by the way. Signed-off-by: Zhang Chen --- migration/colo.c | 24 +++++++++++++----------- qapi/migration.json | 15 +++++++++------ 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index 89325952c7..dbe2b88807 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -267,7 +267,11 @@ COLOStatus *qmp_query_colo_status(Error **errp) s->reason = COLO_EXIT_REASON_REQUEST; break; default: - s->reason = COLO_EXIT_REASON_ERROR; + if (migration_in_colo_state()) { + s->reason = COLO_EXIT_REASON_PROCESSING; + } else { + s->reason = COLO_EXIT_REASON_ERROR; + } } return s; @@ -579,16 +583,13 @@ out: * or the user triggered failover. */ switch (failover_get_state()) { - case FAILOVER_STATUS_NONE: - qapi_event_send_colo_exit(COLO_MODE_PRIMARY, - COLO_EXIT_REASON_ERROR); - break; case FAILOVER_STATUS_COMPLETED: qapi_event_send_colo_exit(COLO_MODE_PRIMARY, COLO_EXIT_REASON_REQUEST); break; default: - abort(); + qapi_event_send_colo_exit(COLO_MODE_PRIMARY, + COLO_EXIT_REASON_ERROR); } /* Hope this not to be too long to wait here */ @@ -850,17 +851,18 @@ out: error_report_err(local_err); } + /* + * There are only two reasons we can get here, some error happened + * or the user triggered failover. + */ switch (failover_get_state()) { - case FAILOVER_STATUS_NONE: - qapi_event_send_colo_exit(COLO_MODE_SECONDARY, - COLO_EXIT_REASON_ERROR); - break; case FAILOVER_STATUS_COMPLETED: qapi_event_send_colo_exit(COLO_MODE_SECONDARY, COLO_EXIT_REASON_REQUEST); break; default: - abort(); + qapi_event_send_colo_exit(COLO_MODE_SECONDARY, + COLO_EXIT_REASON_ERROR); } if (fb) { diff --git a/qapi/migration.json b/qapi/migration.json index 7a795ecc16..48e21880a3 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -983,19 +983,22 @@ ## # @COLOExitReason: # -# The reason for a COLO exit +# Describe the reason for COLO exit. # -# @none: no failover has ever happened. This can't occur in the -# COLO_EXIT event, only in the result of query-colo-status. +# @none: failover has never happened. This state does not occurred +# in the COLO_EXIT event, only happened in the result of +# query-colo-status. # -# @request: COLO exit is due to an external request +# @request: COLO exit caused by an external request. # -# @error: COLO exit is due to an internal error +# @error: COLO exit caused by an internal error. +# +# @processing: COLO in failover handling state. # # Since: 3.1 ## { 'enum': 'COLOExitReason', - 'data': [ 'none', 'request', 'error' ] } + 'data': [ 'none', 'request', 'error' , 'processing' ] } ## # @x-colo-lost-heartbeat: From patchwork Thu Feb 28 16:55:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BB8D15AC for ; Thu, 28 Feb 2019 17:00:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7896F2F2C7 for ; Thu, 28 Feb 2019 17:00:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D0972F4C4; Thu, 28 Feb 2019 17:00:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 33F272F2C7 for ; Thu, 28 Feb 2019 17:00:30 +0000 (UTC) Received: from localhost ([127.0.0.1]:43001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP2r-0006ud-KD for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:00:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP1C-0005Nm-K9 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP1B-0007Ky-6a for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:46 -0500 Received: from mga17.intel.com ([192.55.52.151]:63409) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP1A-0007Dq-Px for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431789" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:38 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:06 +0800 Message-Id: <20190228165508.21594-6-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 5/7] qapi/migration.json: Remove a variable that doesn't exist in example X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen Remove the "active" variable in example for query-colo-status. Signed-off-by: Zhang Chen Reviewed-by: Eric Blake Reviewed-by: Eric Blake --- qapi/migration.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qapi/migration.json b/qapi/migration.json index 48e21880a3..f4c1762dfc 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1342,7 +1342,7 @@ # Example: # # -> { "execute": "query-colo-status" } -# <- { "return": { "mode": "primary", "active": true, "reason": "request" } } +# <- { "return": { "mode": "primary", "reason": "request" } } # # Since: 3.1 ## From patchwork Thu Feb 28 16:55:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0626017E9 for ; Thu, 28 Feb 2019 17:00:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E64A12F3E2 for ; Thu, 28 Feb 2019 17:00:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DAEBB2F34C; Thu, 28 Feb 2019 17:00:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2BD92F35A for ; Thu, 28 Feb 2019 17:00:10 +0000 (UTC) Received: from localhost ([127.0.0.1]:42988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP2Y-0006aN-1N for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:00:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP1D-0005OK-9A for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP1B-0007L6-9Q for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:46 -0500 Received: from mga17.intel.com ([192.55.52.151]:63406) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP1A-0007D6-RG for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:45 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431797" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:41 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:07 +0800 Message-Id: <20190228165508.21594-7-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 6/7] Migration/colo.c: Add the necessary checks for colo_do_failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen Signed-off-by: Zhang Chen --- migration/colo.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index dbe2b88807..d1ae2e6d11 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -197,10 +197,16 @@ void colo_do_failover(MigrationState *s) vm_stop_force_state(RUN_STATE_COLO); } - if (get_colo_mode() == COLO_MODE_PRIMARY) { + switch (get_colo_mode()) { + case COLO_MODE_PRIMARY: primary_vm_do_failover(); - } else { + break; + case COLO_MODE_SECONDARY: secondary_vm_do_failover(); + break; + default: + error_report("colo_do_failover failed because the colo mode" + " could not be obtained"); } } From patchwork Thu Feb 28 16:55:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10833509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6F8CD17E9 for ; Thu, 28 Feb 2019 17:09:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 520322F1AA for ; Thu, 28 Feb 2019 17:09:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 502C72F2F1; Thu, 28 Feb 2019 17:09:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=0.1 required=2.0 tests=BAYES_00,FROM_ADDR_WS, FROM_WSP_TRAIL,MAILING_LIST_MULTI autolearn=no version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 03A752F1AA for ; Thu, 28 Feb 2019 17:09:21 +0000 (UTC) Received: from localhost ([127.0.0.1]:43250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzPBQ-0005HJ-7x for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Feb 2019 12:09:20 -0500 Received: from eggs.gnu.org ([209.51.188.92]:57008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzP1W-0005fE-UT for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:59:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzP1M-0007Rz-OC for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:59:02 -0500 Received: from mga17.intel.com ([192.55.52.151]:63424) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzP1D-0007LG-Cs for qemu-devel@nongnu.org; Thu, 28 Feb 2019 11:58:49 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Feb 2019 08:58:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,423,1544515200"; d="scan'208";a="142431800" Received: from unknown (HELO localhost.localdomain) ([10.239.13.19]) by orsmga001.jf.intel.com with ESMTP; 28 Feb 2019 08:58:43 -0800 From: Zhang Chen To: Li Zhijian , Zhang Chen , "Dr. David Alan Gilbert" , Juan Quintela , zhanghailiang , Markus Armbruster , Eric Blake , qemu-dev Date: Fri, 1 Mar 2019 00:55:08 +0800 Message-Id: <20190228165508.21594-8-chen.zhang@intel.com> X-Mailer: git-send-email 2.17.GIT In-Reply-To: <20190228165508.21594-1-chen.zhang@intel.com> References: <20190228165508.21594-1-chen.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.151 Subject: [Qemu-devel] [PATCH V2 7/7] Migration/colo.c: Make user obtain the COLO mode info after failover X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Zhang Chen Add the last_colo_mode to save the status after failover. This patch can solve the issue that user got nothing to call query_colo_status after failover. Signed-off-by: Zhang Chen --- migration/colo.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/migration/colo.c b/migration/colo.c index d1ae2e6d11..6eba8e06f2 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -38,6 +38,9 @@ static bool vmstate_loading; static Notifier packets_compare_notifier; +/* User need to know colo mode after COLO failover */ +static COLOMode last_colo_mode; + #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) bool migration_in_colo_state(void) @@ -197,7 +200,10 @@ void colo_do_failover(MigrationState *s) vm_stop_force_state(RUN_STATE_COLO); } - switch (get_colo_mode()) { + /* Update last_COLO_mode to avoid unexpectedly exit COLO status */ + last_colo_mode = get_colo_mode(); + + switch (last_colo_mode) { case COLO_MODE_PRIMARY: primary_vm_do_failover(); break; @@ -263,7 +269,7 @@ COLOStatus *qmp_query_colo_status(Error **errp) { COLOStatus *s = g_new0(COLOStatus, 1); - s->mode = get_colo_mode(); + s->mode = last_colo_mode; switch (failover_get_state()) { case FAILOVER_STATUS_NONE: @@ -515,6 +521,12 @@ 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) { + error_report("COLO mode must be COLO_MODE_PRIMARY"); + return; + } + failover_init_state(); s->rp_state.from_dst_file = qemu_file_get_return_path(s->to_dst_file); @@ -682,12 +694,18 @@ void *colo_process_incoming_thread(void *opaque) Error *local_err = NULL; int ret; - rcu_register_thread(); - qemu_sem_init(&mis->colo_incoming_sem, 0); - migrate_set_state(&mis->state, MIGRATION_STATUS_ACTIVE, MIGRATION_STATUS_COLO); + last_colo_mode = get_colo_mode(); + if (last_colo_mode != COLO_MODE_SECONDARY) { + error_report("COLO mode must be COLO_MODE_SECONDARY"); + return NULL; + } + + rcu_register_thread(); + qemu_sem_init(&mis->colo_incoming_sem, 0); + failover_init_state(); mis->to_src_file = qemu_file_get_return_path(mis->from_src_file);