From patchwork Mon May 14 16:54:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10398931 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A7F56053A for ; Mon, 14 May 2018 16:59:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A7532811E for ; Mon, 14 May 2018 16:59:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F03F2838F; Mon, 14 May 2018 16:59:33 +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 B26E22811E for ; Mon, 14 May 2018 16:59:32 +0000 (UTC) Received: from localhost ([::1]:47280 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGou-0003Ih-0p for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 May 2018 12:59:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33536) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIGl3-0008Bj-4o for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIGky-0005lz-KA for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:33 -0400 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]:39941) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fIGky-0005lJ-Dk for qemu-devel@nongnu.org; Mon, 14 May 2018 12:55:28 -0400 Received: by mail-pf0-x22d.google.com with SMTP id f189-v6so6306562pfa.7 for ; Mon, 14 May 2018 09:55:28 -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=1k4ztbdsYCmsp1MgR4MJL4AoI9gtOnP24l8VMwnkbUw=; b=Ql0bgdWEr84tfIWpOn0lQENrcKtCjwpyaTWlhb7Z5hJlpegDm1LUGda1bNc1PZZvdp Dc+NBi2DScGCEDj2uyUYRg5r3JFKnhDekrWj2qAlyp18eHQ3dJh9mAI11yxI5wVyChsA GWzHuYyhvUsaMw1LrdnmBsr3rnc7zGEUwUY964+hCRvTZ5omdjuqYwAHQY6Dgv9PiPc/ /ShOA4+gbdmnNjXskZXL2efcWzCdX8eAVhKyvdeuPTzbKlG8UvzIoQ/gNiFHMJ0WTDrb 4patKrSfME8iVI9IbzLUfq4R1nHTVMqASlBHUNuIfx6fSt6xpcIGTGA3A9v+gmULIbcm spRg== 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=1k4ztbdsYCmsp1MgR4MJL4AoI9gtOnP24l8VMwnkbUw=; b=BXcto+QIIXPRAIJJn9JpkgK9ymowuc04KbR/Ooh4lbqBbSi+NPuvPjM54m+1RwIwRX Y7YygnEm/naa6Lq8xq+l//F9JJz/Ng1f4Aw833MFfXoaCkZzd7VieCyp7kFmU9QslY1v PvWAZk9kPnw5EZ6b+t6fNzd2BIpgFUbJeaBOJRqe+wYfWlehOJu4PQpnO3VmW/rPqnhT WqKQjiWAY7kVlrUMuW5XBsJx7UMyWGrLXZjao7/3vRVlEa5xuTGksvCu69q3IjG57gbe Un/OzR8k21mxRBC2w6zuFFe4oA/5/okVYkXhb+026K9xW2fcaCzkVojhR6hZxDFIkLxe vZtg== X-Gm-Message-State: ALKqPwc+uP1F0+zPM5N+3Dkf8u0Z/loi5vP/ybO3LQbR+TlaIFq5VGKP 9PvTwd4BS7tVk8jA9Cm2nQEtCQ== X-Google-Smtp-Source: AB8JxZrlLC+84x51R+zu5NyZxe6fVQT1wD/xybb5vHWGC5nhysJW0LlTMVbEnyHTD1fbsxmsRc2TtQ== X-Received: by 2002:a62:883:: with SMTP id 3-v6mr11471404pfi.154.1526316927076; Mon, 14 May 2018 09:55:27 -0700 (PDT) Received: from localhost.localdomain (109.227.199.104.bc.googleusercontent.com. [104.199.227.109]) by smtp.gmail.com with ESMTPSA id u69-v6sm631448pgb.42.2018.05.14.09.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 09:55:25 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 00:54:17 +0800 Message-Id: <20180514165424.12884-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180514165424.12884-1-zhangckid@gmail.com> References: <20180514165424.12884-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22d Subject: [Qemu-devel] [PATCH V7 RESEND 10/17] 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 , Jason Wang , Markus Armbruster , "Dr . David Alan Gilbert" , Zhang Chen , Paolo Bonzini 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 --- migration/colo.c | 20 ++++++++++++++++++++ qapi/migration.json | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index c083d3696f..8ca63813c2 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,18 @@ out: qemu_fclose(fb); } + /* + * There are only two reasons we can go here, some error happened. + * Or the user triggered failover. + */ + if (failover_get_state() == FAILOVER_STATUS_NONE) { + qapi_event_send_colo_exit(COLO_MODE_PRIMARY, + COLO_EXIT_REASON_ERROR, NULL); + } else { + qapi_event_send_colo_exit(COLO_MODE_PRIMARY, + COLO_EXIT_REASON_REQUEST, NULL); + } + /* Hope this not to be too long to wait here */ qemu_sem_wait(&s->colo_exit_sem); qemu_sem_destroy(&s->colo_exit_sem); @@ -744,6 +757,13 @@ out: if (local_err) { error_report_err(local_err); } + if (failover_get_state() == FAILOVER_STATUS_NONE) { + qapi_event_send_colo_exit(COLO_MODE_SECONDARY, + COLO_EXIT_REASON_ERROR, NULL); + } else { + qapi_event_send_colo_exit(COLO_MODE_SECONDARY, + COLO_EXIT_REASON_REQUEST, NULL); + } if (fb) { qemu_fclose(fb); diff --git a/qapi/migration.json b/qapi/migration.json index f3974c6807..55dae48089 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -874,6 +874,43 @@ { '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: 2.13 +# +# 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. +# +# @request: COLO exit is due to an external request +# +# @error: COLO exit is due to an internal error +# +# Since: 2.13 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'none', 'request', 'error' ] } + ## # @x-colo-lost-heartbeat: #