From patchwork Fri Jun 3 07:52:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9152061 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 5BBAB60751 for ; Fri, 3 Jun 2016 08:04:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BA22272AA for ; Fri, 3 Jun 2016 08:04:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40501282E8; Fri, 3 Jun 2016 08:04:01 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 B62C5272AA for ; Fri, 3 Jun 2016 08:04:00 +0000 (UTC) Received: from localhost ([::1]:53079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8k5H-0007JS-SD for patchwork-qemu-devel@patchwork.kernel.org; Fri, 03 Jun 2016 04:03:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jwC-0007cX-Gd for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8jw7-0004zJ-C9 for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:35 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:25564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8jw6-0004yL-0O for qemu-devel@nongnu.org; Fri, 03 Jun 2016 03:54:31 -0400 Received: from 172.24.1.60 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DIE18652; Fri, 03 Jun 2016 15:53:20 +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; Fri, 3 Jun 2016 15:53:09 +0800 From: zhanghailiang To: , , , Date: Fri, 3 Jun 2016 15:52:32 +0800 Message-ID: <1464940366-9880-21-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1464940366-9880-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1464940366-9880-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.0A090202.5751379A.0042, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 47fca77e155aff8cf20f866fefb52d51 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH COLO-Frame v17 20/34] qmp event: Add COLO_EXIT event to notify users while exited from 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: xiecl.fnst@cn.fujitsu.com, lizhijian@cn.fujitsu.com, yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, Markus Armbruster , zhanghailiang , arei.gonglei@huawei.com, stefanha@redhat.com, zhangchen.fnst@cn.fujitsu.com, Michael Roth , hongyang.yang@easystack.cn Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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 Reviewed-by: Eric Blake --- v16: - fix some minor grammars from Eric - Add Reviewed-by tag 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 | 19 +++++++++++++++++++ qapi-schema.json | 14 ++++++++++++++ qapi/event.json | 15 +++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/docs/qmp-events.txt b/docs/qmp-events.txt index fa7574d..77c634e 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 8216c5f..db6534a 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -19,6 +19,7 @@ #include "qemu/error-report.h" #include "qapi/error.h" #include "migration/failover.h" +#include "qapi-event.h" #define COLO_BUFFER_BASE_SIZE (4 * 1024 * 1024) @@ -361,6 +362,17 @@ out: } qemu_fclose(fb); + /* + * There are only two reasons we can go here, some error happened. + * Or the user 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); + } if (s->rp_state.from_dst_file) { qemu_fclose(s->rp_state.from_dst_file); @@ -521,6 +533,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 07d3fcb..9856567 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -831,6 +831,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.7 +## +{ '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 8642052..09542fa 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.7 +## +{ 'event': 'COLO_EXIT', + 'data': {'mode': 'COLOMode', 'reason': 'COLOExitReason' } } + +## # @ACPI_DEVICE_OST # # Emitted when guest executes ACPI _OST method.