From patchwork Mon Sep 3 04:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10585421 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 154F413AC for ; Mon, 3 Sep 2018 04:49:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02DB429529 for ; Mon, 3 Sep 2018 04:49:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E9E4B29533; Mon, 3 Sep 2018 04:49: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 6368329529 for ; Mon, 3 Sep 2018 04:49:06 +0000 (UTC) Received: from localhost ([::1]:43403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgnR-0000Nv-Dq for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Sep 2018 00:49:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgfr-0008U2-Ps for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwgfo-00052z-HA for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:15 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]:46050) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwgfo-00051k-Ay for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:12 -0400 Received: by mail-pl1-x62a.google.com with SMTP id j8-v6so8022790pll.12 for ; Sun, 02 Sep 2018 21:41:12 -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=7lzId/i/kSCDSFoSw243CnN2MYB6TqXdPDlb86gKDB8=; b=UO7wwPiaaeIloJ5RHLQzqdQ5GLTvNZ6hTf/eUI1POCUYLPSqUEehH29ypzc3PnNGgF AIVFKdG29Lnq4dXwkhZCy3QBwQkM+3feIg/yC+TEO45glEKuNv9uVr3FrOJW5pM/AjL8 QDVW8hcfa0GizsM84NBd0rVQ/2/rEUPbecQg5Gu/OlU9oek+qnJyKzCT8lZCZfh5Glde Bwq9TAPO1QRvyCi+W7yMbUQZoP9i/658bj5tKvpUUnpMa1KJyJ/ng7Ou2A1+g0P+XoYK fhU6ZtzFI+rPAiNJAy50RElabsNYeq4hJD12W2WKS3BX+TxcNLKTm3xaB0rUxPB7D+bt swhg== 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=7lzId/i/kSCDSFoSw243CnN2MYB6TqXdPDlb86gKDB8=; b=MgyVrmgYzaiSt3BxrawGPEvxsv57NAnCqS7ExJKive7kWwNAH7PZUKkZRLwSniiwvY NqwXZX0/9+5TN8aGGnK1A3Wr2Xsyrl4ASykOD07YiKGSJ7bofqqBuM553xX5XzGq4xKu 6VXdybHhNJomopOdUpgQYHayevzIJjjB6SHgD28TrUzWCAM41q6iqEVSHE1NNd/EIwNZ 664rQn6pmcmt6jK8SRcd564vFUS3ddHkoCFCBHWaT7WKvxkKYr2n5d6My+TZ10YITjCi s1XCa9UWukZNLgLaaX2sJfmG72YCJFI0SXWp3HFJDz76t9jWzrSgajpdvgWjCvhWGD5U Tpxg== X-Gm-Message-State: APzg51BhwKx/jICQ68PoaUc7/FLMBfXtX65MZvmJKVitW6dV7A6xT0JS ZNrpgDhzrUo5WwVp1vV9Ee+UtxXe X-Google-Smtp-Source: ANB0VdYpa3/9c2HQfNSW9gmyz+i2GpuboTvXJkb8I2DLbjxeNz3xiOyJ+sFiPREXcm1oQFMNWovu9Q== X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr26599087pll.66.1535949671220; Sun, 02 Sep 2018 21:41:11 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id g6-v6sm32738308pfb.11.2018.09.02.21.41.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Sep 2018 21:41:10 -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, 3 Sep 2018 12:38:51 +0800 Message-Id: <20180903043900.28592-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903043900.28592-1-zhangckid@gmail.com> References: <20180903043900.28592-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::62a Subject: [Qemu-devel] [PATCH V12 10/19] 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 d3163b51c8..761fbb9f78 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); @@ -746,6 +764,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 f62d3f9a4b..9b3b1c0c4e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -932,6 +932,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: #