From patchwork Thu Jun 18 08:58:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhanghailiang X-Patchwork-Id: 486225 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1879F1400A0 for ; Thu, 18 Jun 2015 19:16:05 +1000 (AEST) Received: from localhost ([::1]:51238 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VvW-0002z9-Up for incoming@patchwork.ozlabs.org; Thu, 18 Jun 2015 05:16:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VgP-0001SA-KQ for qemu-devel@nongnu.org; Thu, 18 Jun 2015 05:00:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z5VgM-0002iN-AU for qemu-devel@nongnu.org; Thu, 18 Jun 2015 05:00:25 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:34206) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z5VgL-0002h3-9X for qemu-devel@nongnu.org; Thu, 18 Jun 2015 05:00:22 -0400 Received: from 172.24.2.119 (EHLO szxeml433-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CPR21786; Thu, 18 Jun 2015 17:00:04 +0800 (CST) Received: from localhost (10.177.22.69) by szxeml433-hub.china.huawei.com (10.82.67.210) with Microsoft SMTP Server id 14.3.158.1; Thu, 18 Jun 2015 16:59:51 +0800 From: zhanghailiang To: Date: Thu, 18 Jun 2015 16:58:40 +0800 Message-ID: <1434617935-6924-17-git-send-email-zhang.zhanghailiang@huawei.com> X-Mailer: git-send-email 1.9.2.msysgit.0 In-Reply-To: <1434617935-6924-1-git-send-email-zhang.zhanghailiang@huawei.com> References: <1434617935-6924-1-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.22.69] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: lizhijian@cn.fujitsu.com, quintela@redhat.com, Markus Armbruster , yunhong.jiang@intel.com, eddie.dong@intel.com, peter.huangpeng@huawei.com, dgilbert@redhat.com, zhanghailiang , arei.gonglei@huawei.com, amit.shah@redhat.com, Michael Roth , laijs@cn.fujitsu.com Subject: [Qemu-devel] [PATCH COLO-Frame v6 16/31] qmp event: Add event notification for COLO error 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org If some errors happen during VM's COLO FT stage, it's import to notify the users this event, Togehter with '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 exit COLO mode. Cc: Markus Armbruster Cc: Michael Roth Signed-off-by: zhanghailiang Signed-off-by: Li Zhijian --- docs/qmp/qmp-events.txt | 16 ++++++++++++++++ migration/colo.c | 12 ++++++++++-- qapi/event.json | 15 +++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 4c13d48..7b6df2e 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -473,6 +473,22 @@ Example: { "timestamp": {"seconds": 1290688046, "microseconds": 417172}, "event": "SPICE_MIGRATE_COMPLETED" } +COLO_EXIT +--------- + +Emitted when VM finish COLO mode due to some errors happening or +the request of users. + +Data: None. + + - "mode": COLO mode, 'primary' or 'secondary' + - "error": Error message (json-string, optional) + +Example: + +{"timestamp": {"seconds": 2032141960, "microseconds": 417172}, + "event": "COLO_EXIT", "data": {"mode": "primary"}} + STOP ---- diff --git a/migration/colo.c b/migration/colo.c index 3ecaec8..a65f9ea 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -15,6 +15,7 @@ #include "trace.h" #include "qemu/error-report.h" #include "migration/migration-failover.h" +#include "qapi-event.h" enum { COLO_CHECPOINT_READY = 0x46, @@ -325,13 +326,14 @@ static void *colo_thread(void *opaque) out: error_report("colo: some error happens in colo_thread"); + qapi_event_send_colo_exit("primary", true, "unknown", NULL);; /* Give users time (2s) to get involved in this verdict */ for (i = 0; i < 10; i++) { if (failover_request_is_set()) { error_report("Primary VM will take over work"); break; } - usleep(200*1000); + usleep(200 * 1000); } qemu_mutex_lock_iothread(); if (!failover_request_is_set()) { @@ -533,13 +535,19 @@ void *colo_process_incoming_checkpoints(void *opaque) out: error_report("Detect some error or get a failover request"); + /* + * Here, we raise a qmp event to the user, + * It can help user to know what happens, and help deciding whether to + * do failover. + */ + qapi_event_send_colo_exit("secondary", true, "unknown", NULL);; /* Give users time (2s) to get involved in this verdict */ for (i = 0; i < 10; i++) { if (failover_request_is_set()) { error_report("Secondary VM will take over work"); break; } - usleep(200*1000); + usleep(200 * 1000); } /* check flag again*/ if (!failover_request_is_set()) { diff --git a/qapi/event.json b/qapi/event.json index 378dda5..e269765 100644 --- a/qapi/event.json +++ b/qapi/event.json @@ -243,6 +243,21 @@ { 'event': 'SPICE_MIGRATE_COMPLETED' } ## +# @COLO_EXIT +# +# Emitted when VM finish COLO mode due to some errors happening or +# the request of users. +# +# @mode: 'primary' or 'secondeary'. +# +# @error: #optional, error message. Only present on error happening. +# +# Since: 2.4 +## +{ 'event': 'COLO_EXIT', + 'data': {'mode': 'str', '*error':'str'}} + +## # @ACPI_DEVICE_OST # # Emitted when guest executes ACPI _OST method.