From patchwork Sat Aug 11 20:59:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10563555 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 B5E3213B4 for ; Sat, 11 Aug 2018 21:08:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 307C82947B for ; Sat, 11 Aug 2018 21:08:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0CCD0294B9; Sat, 11 Aug 2018 21:08:06 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 733222947B for ; Sat, 11 Aug 2018 21:08:05 +0000 (UTC) Received: from localhost ([::1]:33210 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fob7E-00033D-29 for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Aug 2018 17:08:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1foazz-00059S-CX for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1foazw-0001Oz-AR for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:35 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:46821) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1foazw-0001Oh-3t for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:32 -0400 Received: by mail-pg1-x52b.google.com with SMTP id f14-v6so5850536pgv.13 for ; Sat, 11 Aug 2018 14:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RS0WVorMcxBw+4/+ip7fUKa54Kq6NT6yPbDyMpZ4Vz8=; b=oXTwXleIoTXYpcYggsh9tK8YbzLoA/y+SLEd9uYo5BIAXWNfM8WT4FWu4U7BZtvN7r acstqziBxfrErP2xIychrbOmbmvi1OcRZ6os7bSAnk+fRZBvCPdRpSl2P9FMDxL8y4S6 vPUEkjBw5M+T275BzyVMfT6vm61kZyW2V7TKwpUIXeYCZWITBzMBoQj5scPtnUdNRrGP 6B9LeTYMbQC7m8CKTeTmfaORQPETl285rlswrJrOOnv24qJFwzJbbvEMLpBkMW1HlCrr SgSysC1pmthI8mZIzJIOfKCH0SGN3N2KiN+EllJoZvkC0XuBISEr2GX8eaB+Klr3Eq6H U/8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RS0WVorMcxBw+4/+ip7fUKa54Kq6NT6yPbDyMpZ4Vz8=; b=ow/kgkOHgcKcCPIymFk+M+A865hJHQtFSIo1WJKPxKou/qmUOXf9EosUKJOA/Y3BT4 KLjYmUQHuM9Qbf7RaZPzcTEVyOczJjeMgB5QYi4n0rFLTvecLwSymykgNVskcUUXU/4u 92ea2+RnNM8pFpFntePTBFweLYvS01YgBPvE8/0rAtptM4TBqyiK+hDfOc3FOHlkUapx F6ZhxyQHNPGmGUcGTCnVTAuYtUdi3j6vXox0C9v5uAddhAkjonR/q3HUN+kz8/CYm7/A rV3+eSE3+3pSrgD1GEA6c4I/gFkBwsioAT2uK/sH61JsUmx8x37m8MJV5nelXD2M1B01 uHrw== X-Gm-Message-State: AOUpUlFxaqH9FpGQ2/RLYE3k27sT71UuxrGGoTjVP56DtGZaetfEmEdS x16UiZmkO/27Bb0XNENVLfOKXq+E X-Google-Smtp-Source: AA+uWPx1LlIKZMOCLTyO23u5nohDYlUC8Yjc1Fec79/x60svZ6IUcLfYjv6NiW3SSWU7eI6LFjOscA== X-Received: by 2002:a63:d20e:: with SMTP id a14-v6mr11386382pgg.226.1534021230782; Sat, 11 Aug 2018 14:00:30 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id h24-v6sm23502641pfk.113.2018.08.11.14.00.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 14:00:29 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Sun, 12 Aug 2018 04:59:14 +0800 Message-Id: <20180811205924.4113-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180811205924.4113-1-zhangckid@gmail.com> References: <20180811205924.4113-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::52b Subject: [Qemu-devel] [PATCH V11 10/20] qmp event: Add COLO_EXIT event to notify users while exited COLO 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 , zhanghailiang , Li Zhijian , 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: zhanghailiang If some errors happen during VM's COLO FT stage, it's important to notify the users of this event. Together with 'x-colo-lost-heartbeat', Users can intervene in COLO's failover work immediately. If users don't want to get involved in COLO's failover verdict, it is still necessary to notify users that we exited COLO mode. Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian Signed-off-by: Zhang Chen Signed-off-by: Zhang Chen Reviewed-by: Eric Blake Reviewed-by: Markus Armbruster --- migration/colo.c | 31 +++++++++++++++++++++++++++++++ qapi/migration.json | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index c083d3696f..ab484ad754 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -28,6 +28,7 @@ #include "net/colo-compare.h" #include "net/colo.h" #include "block/block.h" +#include "qapi/qapi-events-migration.h" static bool vmstate_loading; static Notifier packets_compare_notifier; @@ -514,6 +515,23 @@ out: qemu_fclose(fb); } + /* + * 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_PRIMARY, + COLO_EXIT_REASON_ERROR, NULL); + break; + case FAILOVER_STATUS_REQUIRE: + qapi_event_send_colo_exit(COLO_MODE_PRIMARY, + COLO_EXIT_REASON_REQUEST, NULL); + break; + default: + abort(); + } + /* Hope this not to be too long to wait here */ qemu_sem_wait(&s->colo_exit_sem); qemu_sem_destroy(&s->colo_exit_sem); @@ -745,6 +763,19 @@ out: error_report_err(local_err); } + switch (failover_get_state()) { + case FAILOVER_STATUS_NONE: + qapi_event_send_colo_exit(COLO_MODE_SECONDARY, + COLO_EXIT_REASON_ERROR, NULL); + break; + case FAILOVER_STATUS_REQUIRE: + qapi_event_send_colo_exit(COLO_MODE_SECONDARY, + COLO_EXIT_REASON_REQUEST, NULL); + break; + default: + abort(); + } + if (fb) { qemu_fclose(fb); } diff --git a/qapi/migration.json b/qapi/migration.json index 186e8a7303..36faea59c1 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -900,6 +900,44 @@ { 'enum': 'FailoverStatus', 'data': [ 'none', 'require', 'active', 'completed', 'relaunch' ] } +## +# @COLO_EXIT: +# +# Emitted when VM finishes COLO mode due to some errors happening or +# at the request of users. +# +# @mode: report COLO mode when COLO exited. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 3.1 +# +# Example: +# +# <- { "timestamp": {"seconds": 2032141960, "microseconds": 417172}, +# "event": "COLO_EXIT", "data": {"mode": "primary", "reason": "request" } } +# +## +{ 'event': 'COLO_EXIT', + 'data': {'mode': 'COLOMode', 'reason': 'COLOExitReason' } } + +## +# @COLOExitReason: +# +# The reason for a 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. +# +# @request: COLO exit is due to an external request +# +# @error: COLO exit is due to an internal error +# +# Since: 3.1 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'none', 'request', 'error' ] } + ## # @x-colo-lost-heartbeat: #