From patchwork Sun Jul 22 19:33:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10539375 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 4A075174A for ; Sun, 22 Jul 2018 19:39:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3A1C62842E for ; Sun, 22 Jul 2018 19:39:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E7FF28434; Sun, 22 Jul 2018 19:39:00 +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 7AE582842E for ; Sun, 22 Jul 2018 19:38:59 +0000 (UTC) Received: from localhost ([::1]:57226 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKC2-0005vB-NT for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Jul 2018 15:38:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhK8L-0002pn-VI for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhK8I-0000k3-Pb for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:09 -0400 Received: from mail-pl0-x242.google.com ([2607:f8b0:400e:c01::242]:44775) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhK8I-0000jr-Iw for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:06 -0400 Received: by mail-pl0-x242.google.com with SMTP id m16-v6so7296054pls.11 for ; Sun, 22 Jul 2018 12:35:06 -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=c1iNzgfPXEp/nvSlMaf31b6bPiaJ6p6YLDqzlK2hcxM=; b=BLYlD5uufO31YiHc2cMqermQj2hLvEbthajHYCCNtP0KppFGH9jP8r7M4o8tAlFWTI 4xqMQCKDliyZfZnIx6/Ef02ei1retWBYX4VvHdeI8EI2pAL/HuIKu81i3vHlx+JiNMta XSHtv4qFNJ2INxUHqa9j8m5L+ppBC3XtMw54n8IqZWev4t/bWCqoknuBaT6m+EeCnG/5 ysuqn9S6xTFeMa6Sxsh4qaFzwiCVqLIb5HcS5wIt0sS2gTJexqk8G5klOvZp5GftpjSo Saxrk1hYZ/KC6qzgQeVwPo885PlwdPHbBpyBn9WDHLtqRW1S2a4A1Sogv4630of1jViW lswQ== 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=c1iNzgfPXEp/nvSlMaf31b6bPiaJ6p6YLDqzlK2hcxM=; b=B0fVe4Et5namBDr0zJzM5EXOOF/INmxa7Xv0qUyeKhnoCnwL8caG7Ji26ZsIVzP2TP K+Fbfv9eLGr2njK9wV8XohiMKTcLJQQzSnqBVO20uOCnzajjRFEinLq5t2VbEvXvDA40 AW6nqEeTmpffUwDiWCIdHU5DswFcvY3dOWClXFkLhyyixl2mrM8D/W9TCG0ZKmAyQIVl vq9/k/QTCqFGDkLRCLuUqYM5Lr+QaybZWZ2BMzf3lO10aI+nDw/YrOTHFxB9a7iEoK4m 4nzI68nm3C5le5q/ssBGZyOfliDdbJp7zY0nqu1vxhOSMCDmnXLHQnzuid7ODCYSidxC TrmQ== X-Gm-Message-State: AOUpUlG67QgQo7xu7CIePoJzO9jlDT63VQQJqm0RbjCEei27Ahr8pGDp uUpqDvsHQwc9SBLJYj2ER0WqzO3E X-Google-Smtp-Source: AAOMgpcjiwWONpnUCBU149JenKb6U0gcNLKNP8jC//kn6hSI/jeHcVxhqzTDKorzYaPzpXbSdiBW5g== X-Received: by 2002:a17:902:bb8d:: with SMTP id m13-v6mr9987583pls.46.1532288105363; Sun, 22 Jul 2018 12:35:05 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id 87-v6sm14215353pfn.103.2018.07.22.12.35.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 12:35:04 -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: Mon, 23 Jul 2018 03:33:40 +0800 Message-Id: <20180722193350.6028-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722193350.6028-1-zhangckid@gmail.com> References: <20180722193350.6028-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::242 Subject: [Qemu-devel] [PATCH V10 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: 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 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..05f65680e1 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.0 +# +# 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.0 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'none', 'request', 'error' ] } + ## # @x-colo-lost-heartbeat: #