From patchwork Wed Jun 27 20:41:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10492641 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 0B23660375 for ; Wed, 27 Jun 2018 20:50:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C9C92A095 for ; Wed, 27 Jun 2018 20:50:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A24F2A0B2; Wed, 27 Jun 2018 20:50:27 +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 59CE62A095 for ; Wed, 27 Jun 2018 20:50:26 +0000 (UTC) Received: from localhost ([::1]:33140 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHOT-0001jC-Gp for patchwork-qemu-devel@patchwork.kernel.org; Wed, 27 Jun 2018 16:50:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYHH0-00044z-1V for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYHGy-0006No-Tj for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:42 -0400 Received: from mail-pl0-x22d.google.com ([2607:f8b0:400e:c01::22d]:39687) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fYHGy-0006NC-O0 for qemu-devel@nongnu.org; Wed, 27 Jun 2018 16:42:40 -0400 Received: by mail-pl0-x22d.google.com with SMTP id s24-v6so1590249plq.6 for ; Wed, 27 Jun 2018 13:42:40 -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=RdboUqsFCsnS69Tet/dfnkPc7+x0C1nplx9y+BKOcOs=; b=IbXkErN6CeFb41ekzCW0uFqOhGF+DOiT5aEe0ksqKh2RwxdnEn9f5CcArP7arDbZZw Tvtzm4scqDYzy6tZsW6FAwi9CytZPaMW8IPxulKT8uEU6k6H/LulNDz2ZAUKSitqFq9r VNEjhtzNZNcX+EbDxg9IrWZN8YsxWQD6wtXMuzmrQPAcXtFvvt0RFome46ZVBFrkP7dj 0TrSgWgom9EBNIQQ5R4Z04axF/xAlqRVo2aRsu7ZH77VUIa9LvWOBMcyMeEq4NHJKqi/ d8wkbJ9CMphdflZT1ufil5brIMCkxmaG4fS4oX/X1yurnqBs5Gu/iGHyUoAXk4NfJSAW GKkA== 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=RdboUqsFCsnS69Tet/dfnkPc7+x0C1nplx9y+BKOcOs=; b=AT5OS8HNZa7W3f5dYLAeIHsustq7vpazO7K3JiTg5C0YKZkDC6i3RxjN5/v9/4uraY CXnDrGEJmOxUXzX2ZwbnKNys9YLu7hHmI2a6PY+layJxnKQFV6rplmkOjADRq96JpJO5 0cszpLF/oLvBG0XiQprOxsflBcp+ySQa+c36Zv4aKmVdmOmBYlUCW6vrz8QnSOall5jX vmqs/oJkCuaJ4su5wzHWkpD2tkcU4P76mGSDwGP2WeG+jaoGvJLv93t0bi1t5htjRH9E hOhYpEPDVV/3eyN01CxF+jXavrAIkivnLYw7jR1S76JkzrzGrCZjfvb68D93Ki/yrwgT MEyw== X-Gm-Message-State: APt69E1N2Ay1UzJguYokFdSmjGfa0HYDCFjjtWbbcG/rpJ3DBbbWiYec tFL+CG7g8eiHj99V9g3vv0TWrg== X-Google-Smtp-Source: ADUXVKLmlV7R0AId9ZdWClSVkrw3omvWisUDOFvSFS3uii5TOnmvTj8FTyJYZWWp69+a7DbLSvGSoQ== X-Received: by 2002:a17:902:e187:: with SMTP id cd7-v6mr7703301plb.166.1530132159457; Wed, 27 Jun 2018 13:42:39 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id c67-v6sm9690428pfj.173.2018.06.27.13.42.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 13:42:38 -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: Thu, 28 Jun 2018 04:41:26 +0800 Message-Id: <20180627204136.4177-11-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180627204136.4177-1-zhangckid@gmail.com> References: <20180627204136.4177-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::22d Subject: [Qemu-devel] [PATCH V9 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 1b4c1db670..d8c3b2e443 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -897,6 +897,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: #