From patchwork Sat Feb 6 09:28:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 8242151 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BCFB6BEEE5 for ; Sat, 6 Feb 2016 09:42:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01BD320212 for ; Sat, 6 Feb 2016 09:42:58 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 1E5E020121 for ; Sat, 6 Feb 2016 09:42:57 +0000 (UTC) Received: from localhost ([::1]:52677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRzOK-0001Yn-Hp for patchwork-qemu-devel@patchwork.kernel.org; Sat, 06 Feb 2016 04:42:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRzBr-0002xj-3w for qemu-devel@nongnu.org; Sat, 06 Feb 2016 04:30:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aRzBp-0001UY-RC for qemu-devel@nongnu.org; Sat, 06 Feb 2016 04:30:03 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:22533) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aRzBp-0001Tr-7r for qemu-devel@nongnu.org; Sat, 06 Feb 2016 04:30:01 -0500 Received: from 172.24.1.49 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.49]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BVU12142; Sat, 06 Feb 2016 17:29:34 +0800 (CST) Received: from localhost (10.177.24.212) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Sat, 6 Feb 2016 17:29:27 +0800 From: zhanghailiang To: Date: Sat, 6 Feb 2016 17:28:33 +0800 Message-ID: <1454750932-7556-22-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1454750932-7556-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1454750932-7556-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.24.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.56B5BCFF.000E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: c09fe7fb0db5ef76d6c5ab1e75dbde67 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: xiecl.fnst@cn.fujitsu.com, lizhijian@cn.fujitsu.com, quintela@redhat.com, armbru@redhat.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, stefanha@redhat.com, amit.shah@redhat.com, zhangchen.fnst@cn.fujitsu.com, Michael Roth , hongyang.yang@easystack.cn Subject: [Qemu-devel] [PATCH COLO-Frame v14 21/40] qmp event: Add COLO_EXIT event to notify users while exited from COLO X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Markus Armbruster Cc: Michael Roth Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian --- v13: - Remove optional 'error' string for this event. (I doubted it was usefull for users, Since users shouldn't interpret it and can't depend on it to decide what happened exaclty. Besides it is really hard to organize.) - Remove unused 'unknown' member for enum COLOExitReason. (Eric's suggestion) - Fix comment for COLO_EXIT v11: - Fix several typos found by Eric --- docs/qmp-events.txt | 16 ++++++++++++++++ migration/colo.c | 20 ++++++++++++++++++++ qapi-schema.json | 14 ++++++++++++++ qapi/event.json | 15 +++++++++++++++ 4 files changed, 65 insertions(+) diff --git a/docs/qmp-events.txt b/docs/qmp-events.txt index 52eb7e2..b6e8937 100644 --- a/docs/qmp-events.txt +++ b/docs/qmp-events.txt @@ -184,6 +184,22 @@ Example: Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR event. +COLO_EXIT +--------- + +Emitted when VM finishes COLO mode due to some errors happening or +at the request of users. + +Data: + + - "mode": COLO mode, primary or secondary side (json-string) + - "reason": the exit reason, internal error or external request. (json-string) + +Example: + +{"timestamp": {"seconds": 2032141960, "microseconds": 417172}, + "event": "COLO_EXIT", "data": {"mode": "primary", "reason": "request" } } + DEVICE_DELETED -------------- diff --git a/migration/colo.c b/migration/colo.c index a65b22b..814480c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -17,6 +17,7 @@ #include "trace.h" #include "qemu/error-report.h" #include "migration/failover.h" +#include "qapi-event.h" /* colo buffer */ #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) @@ -367,6 +368,18 @@ out: if (local_err) { error_report_err(local_err); } + /* + * There are only two reasons we can go here, something error happened, + * Or users triggered failover. + */ + if (!failover_request_is_active()) { + 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); + } + qsb_free(buffer); buffer = NULL; @@ -530,6 +543,13 @@ out: if (local_err) { error_report_err(local_err); } + if (!failover_request_is_active()) { + 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-schema.json b/qapi-schema.json index 73325ed..7fec696 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -776,6 +776,20 @@ 'data': [ 'unknown', 'primary', 'secondary'] } ## +# @COLOExitReason +# +# The reason for a COLO exit +# +# @request: COLO exit is due to an external request +# +# @error: COLO exit is due to an internal error +# +# Since: 2.6 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'request', 'error' ] } + +## # @x-colo-lost-heartbeat # # Tell qemu that heartbeat is lost, request it to do takeover procedures. diff --git a/qapi/event.json b/qapi/event.json index 390fd45..cfcc887 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -268,6 +268,21 @@ 'data': { 'pass': 'int' } } ## +# @COLO_EXIT +# +# Emitted when VM finishes COLO mode due to some errors happening or +# at the request of users. +# +# @mode: which COLO mode the VM was in when it exited. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 2.6 +## +{ 'event': 'COLO_EXIT', + 'data': {'mode': 'COLOMode', 'reason': 'COLOExitReason' } } + +## # @ACPI_DEVICE_OST # # Emitted when guest executes ACPI _OST method.