From patchwork Wed Aug 3 12:25:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 9261175 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 D2E4860754 for ; Wed, 3 Aug 2016 12:44:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA6CF284B4 for ; Wed, 3 Aug 2016 12:44:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB13A28518; Wed, 3 Aug 2016 12:44:38 +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 324E728580 for ; Wed, 3 Aug 2016 12:44:36 +0000 (UTC) Received: from localhost ([::1]:34260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvXH-0003Ct-MS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Aug 2016 08:44:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvGM-0000hk-I4 for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUvGI-0006bO-W9 for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:05 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:30662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUvGI-0006ZM-4x for qemu-devel@nongnu.org; Wed, 03 Aug 2016 08:27:02 -0400 Received: from 172.24.1.137 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.137]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DOT30317; Wed, 03 Aug 2016 20:26:46 +0800 (CST) Received: from localhost (10.177.24.212) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Wed, 3 Aug 2016 20:26:38 +0800 From: zhanghailiang To: Date: Wed, 3 Aug 2016 20:25:58 +0800 Message-ID: <1470227172-13704-21-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 2.7.2.windows.1 In-Reply-To: <1470227172-13704-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1470227172-13704-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.0A020203.57A1E308.0154, 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: d2e180de17e97bdb17095aa269905237 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Subject: [Qemu-devel] [PATCH COLO-Frame v18 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, quintela@redhat.com, Markus Armbruster , eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, amit.shah@redhat.com, zhangchen.fnst@cn.fujitsu.com, Michael Roth , zhanghailiang 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 7967ec4..02dd521 100644 --- a/docs/qmp-events.txt +++ b/docs/qmp-events.txt @@ -188,6 +188,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 eeef775..f8fce0d 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); @@ -520,6 +532,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 ee7131d..d729b61 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -835,6 +835,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.8 +## +{ '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..88d10e7 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.8 +## +{ 'event': 'COLO_EXIT', + 'data': {'mode': 'COLOMode', 'reason': 'COLOExitReason' } } + +## # @ACPI_DEVICE_OST # # Emitted when guest executes ACPI _OST method.