From patchwork Sun Jun 3 05:05:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10445143 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 B02B960234 for ; Sun, 3 Jun 2018 05:20:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0800289A2 for ; Sun, 3 Jun 2018 05:20:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94E10289D6; Sun, 3 Jun 2018 05:20:54 +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 152F7289A2 for ; Sun, 3 Jun 2018 05:20:54 +0000 (UTC) Received: from localhost ([::1]:33703 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPLRl-00024V-C6 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 03 Jun 2018 01:20:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57871) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPLED-0000FK-Dn for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:06:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPLEA-0000rq-6o for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:06:53 -0400 Received: from mail-pl0-x234.google.com ([2607:f8b0:400e:c01::234]:38336) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fPLEA-0000rZ-0n for qemu-devel@nongnu.org; Sun, 03 Jun 2018 01:06:50 -0400 Received: by mail-pl0-x234.google.com with SMTP id b14-v6so511146pls.5 for ; Sat, 02 Jun 2018 22:06:49 -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=blGkwLorxtbaogbHNXwbLYDrkc5No8/I1VNcR1Md91Q=; b=qoSh+nzJTt+2fU0hdkJ0xy2X0UIuLktHkKNNdtri9U28T/vtw/GgNKjvytRJ/aTl1J 2KqGxdAF+PGOd/ZPXFV/dMtGhQAsENhGkvK5V3K4U0x4KKEd2oAkhwOwbeWZnWA/oisd YuFVsN4MUAicZYsaSSevM7y/C5/Hs50F8VI4gxdvrWDuHcnnos7+hRyy2q+FbvcgoAl9 zb0WDQw4HM2cj/8CnBv1oGCVz8p74rizR1VjuvdcM7jPLV3OJbaXIH9d9s8k93I+WFE9 NOsmlXUVZB7S2qasffpH2FNvolIrtCsC8AQr/zHKiwcmW2UcFOwXecYvlAAscTICUK1M KkAQ== 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=blGkwLorxtbaogbHNXwbLYDrkc5No8/I1VNcR1Md91Q=; b=fGSNe41fDQi1FWhgOsySF7OavpsJdBHoWAT0oEm9jU8QG+cPHTDeYWYYG4Tov45wtS SByJuHwhYg8fYlfYuA+S78Ar7WuFCsTuN5PABCjv7o1jESBHR1PXiFN7t0+MULJCHYRS +Te+tX4TbA/Nuh3dGe/IYVdEoGG2wOpUlPyoH7IllvBnnlzEk64ZmyE2Hby5M1yAkeFk 5nQeVakY3LGLhOV8j2CcOhRekYVlB+daVhuhNzb1zRmiah66lmWaEBa9siB7wTB41kiA MhUmU85zHSpqAoTaBX/gFCUny3I9KwP/XeTh6rAlNHMZ1pLmxggQtFzRc7ebdZjfucRE 9WZA== X-Gm-Message-State: ALKqPweSJi56/YmquA4br0wXF9jvM4nbh6yYU3Eu33DMstUEMKLzS1iJ OIEpqT0t/M/Bj+7t7zyAQe3K+Q== X-Google-Smtp-Source: ADUXVKK+WnEVff3R1VLrEBjdM+1zYLoHyyc2a2VsB7EYax7ojhJiV6i4HBEwgsu6ty1+REWIAYIGPg== X-Received: by 2002:a17:902:7248:: with SMTP id c8-v6mr10311128pll.128.1528002408914; Sat, 02 Jun 2018 22:06:48 -0700 (PDT) Received: from localhost.localdomain (197.225.229.35.bc.googleusercontent.com. [35.229.225.197]) by smtp.gmail.com with ESMTPSA id 10-v6sm45841595pgb.40.2018.06.02.22.06.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Jun 2018 22:06:48 -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, 3 Jun 2018 13:05:39 +0800 Message-Id: <20180603050546.6827-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180603050546.6827-1-zhangckid@gmail.com> References: <20180603050546.6827-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::234 Subject: [Qemu-devel] [PATCH V8 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 , 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..bedb677788 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 go 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 dc9cc85545..93136ce5a0 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -880,6 +880,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: 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, 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: 2.13 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'none', 'request', 'error' ] } + ## # @x-colo-lost-heartbeat: #