From patchwork Mon May 14 03:23:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10396855 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 499E460216 for ; Mon, 14 May 2018 06:51:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3802D28E11 for ; Mon, 14 May 2018 06:51:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2C96828EA0; Mon, 14 May 2018 06:51:43 +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 932F928E11 for ; Mon, 14 May 2018 06:51:42 +0000 (UTC) Received: from localhost ([::1]:44490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI7Kf-0004Vx-Sl for patchwork-qemu-devel@patchwork.kernel.org; Mon, 14 May 2018 02:51:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47370) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fI6fX-0006dK-0R for qemu-devel@nongnu.org; Mon, 14 May 2018 02:09:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fI46d-0000O8-Sk for qemu-devel@nongnu.org; Sun, 13 May 2018 23:25:03 -0400 Received: from mail-pg0-x234.google.com ([2607:f8b0:400e:c05::234]:38339) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fI46d-0000N6-Mq for qemu-devel@nongnu.org; Sun, 13 May 2018 23:24:59 -0400 Received: by mail-pg0-x234.google.com with SMTP id n9-v6so4846470pgq.5 for ; Sun, 13 May 2018 20:24:59 -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=P8+FLOfvMorXstTMNMIRaiUcPBB8BGJsymX5MoajP1I=; b=QbLA5FywbCgWKlVUUr00lR8emGmytcDJaF6OJcQ62riLYZEn0CVPJC5Y1l3BDl9SQs yBe1a8CCN61ej29FK9doekxX5pouz41Km0FU6skTVVZK8PZCd3lXlu1b+OcTc6fOGjyj 1ldO0p9QCltoa/cYAiE2B2OyhpyGAl+dzWjibRLszhpHBI0EaQzTr4R79iV2/ErhfECk Ea0vpvgNprP6x5mMkZtNBtP9cQxHx+LYD9fuFt/2UQHQyNTLZEo8xJ6xD2QD1nXP7rO4 4hSjv5oiab8hVqcWPPqOWSWXjTQ6R+7SFyW8z6A0u3TlrA01LDDaZ4e1QsQA5Juo1f6W EMxw== 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=P8+FLOfvMorXstTMNMIRaiUcPBB8BGJsymX5MoajP1I=; b=YjxruLF8woH5TUzUb+L4RI7wBmOxYhPYQaXWRldAiDF9HjxfyRo8UL/HoryPmRHZgJ 5AkhNVKmkgRBb5XWiYJeakGZZkyvY4YHGhkSnAv6pNWEcpnoLVOnFhAP1xv9TibfoVaY Zu8kAY+zY3C6N52MJT/F4C3N/cl4EtOgl6n/bP5B9WX7EPm/sWuZhygsjWn8UTr2I9OJ Ny6dpinukgV8QHbwtqcYnJtkcPveQpw/rleWDRf6TqaSHiRb22+hHNdQQxzZCkUr5lrJ fwvfrWaNPLSyqVDQizufjkirwQAPGO7r0KrKXFpoHHRNQx0r1j6syeu2KrU4OQmf4ekZ zocw== X-Gm-Message-State: ALKqPwft5m3yZgIvI+bd/4Yial0YUVIZ8NIt+i58xWj2gcgn42uoV+2E 7yPLfAcrRvMnJNoEGT9dRwuTCw== X-Google-Smtp-Source: AB8JxZpsUi/bQIz+eaBsPVm+7fZ4NTuaMbZw65s36sx4NOOyWfG4GUT5d/oFjkEfIXDmx9P/iLLkYA== X-Received: by 2002:a62:1fc8:: with SMTP id l69-v6mr8586787pfj.49.1526268298441; Sun, 13 May 2018 20:24:58 -0700 (PDT) Received: from localhost.localdomain (109.227.199.104.bc.googleusercontent.com. [104.199.227.109]) by smtp.gmail.com with ESMTPSA id p6-v6sm17183532pfg.157.2018.05.13.20.24.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 13 May 2018 20:24:57 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org Date: Mon, 14 May 2018 11:23:41 +0800 Message-Id: <1526268228-27951-11-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1526268228-27951-1-git-send-email-zhangckid@gmail.com> References: <1526268228-27951-1-git-send-email-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::234 Subject: [Qemu-devel] [PATCH V7 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 c083d36..8ca6381 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 f3974c6..55dae48 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -875,6 +875,43 @@ '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: # # Tell qemu that heartbeat is lost, request it to do takeover procedures.