From patchwork Sat Mar 10 21:22:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10274373 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 9227160594 for ; Sat, 10 Mar 2018 21:33:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 823F628DF6 for ; Sat, 10 Mar 2018 21:33:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76D0928E20; Sat, 10 Mar 2018 21:33:36 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 C876928DF6 for ; Sat, 10 Mar 2018 21:33:35 +0000 (UTC) Received: from localhost ([::1]:52021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eum7S-000218-Uc for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Mar 2018 16:33:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eulxN-0002hZ-RT for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eulxK-0003PN-NV for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:09 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:40253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eulxK-0003PC-Go for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:06 -0500 Received: by mail-pg0-x243.google.com with SMTP id g8so4931473pgv.7 for ; Sat, 10 Mar 2018 13:23:06 -0800 (PST) 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=GD6x7tdnuKsONz6vJ1sF07NbBOLox/mgTLZpcyl+d1w=; b=hkj29JxvoUlTqwhK4d1Ikn2g/ToA09/rCUziL3SJmJDMlrqTvizX7R+6oqMslk6hJb It9wWbJe5ch8zCP+1DBBDc0r6byv2FSog8iiH8OmIBwhHSlcRzxcWSB2EsgUD2mozDBR jjpJwKDygzXcE/1mkuFVdIedx1k02deHFeJoWAi5KHGdlMGuHyFr6FF/vgnR8mJxPT6I hN13lQY8Mf220gxK94wvR9LOX7zLqqawreOLk5nHcqqpmn0DbTdnLH/i0lttrmhbBg/l pbZaPFNf9B6sfcoZdZ+a0u55qxmX0e/wU9bFu4z2ua5HPCeGgAZih0Ba6v3gYf5diYzD Mtcw== 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=GD6x7tdnuKsONz6vJ1sF07NbBOLox/mgTLZpcyl+d1w=; b=muYTAr+IGpneTNVTtoq4gnX+9wbGDiLvXDJjmovh1sdPFlVHucezLZbNrEZMHPj3ZX 8JO1GOvAwtg9oPA5r04hQHVjEWSC8aqxVeSE74caEXS77F30Q49DWw91jbtPGLMdhiOy t/Mzvqat3ScENjEh2oGeFN2cLRtcOe65+uaSC/DyUi5XQwcSu4EsPXwZetmGWjlRhLKb D4k+DgJBz5Yf2sk+5zHXec/TQzkrC+vwEKFTqtSi0ewsaxv/seW5xS2dwZLWtRjHBViW IJmJTyaSbsrooRnXiV0RPlbY7RHEwCatojTuyiX3mRJKGgmg0cj1h3koTbSNaD9thWin cwIQ== X-Gm-Message-State: AElRT7Ec7jXqdBtSzKRI38peN+kpC0mW7Sxrebiwcpd/U/vDigv8x17I dJcHx59KeeKLAyegf842ujfEA2Vs X-Google-Smtp-Source: AG47ELua7NSrTl9VWvEIQeWnpx2SOnqaS8cDRyoRic1lmwDYczVSb4RuE/Nke48/XSvZXEvByBRTRQ== X-Received: by 10.98.1.88 with SMTP id 85mr3005429pfb.226.1520716985287; Sat, 10 Mar 2018 13:23:05 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id q65sm10532191pfd.140.2018.03.10.13.23.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 13:23:04 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2018 05:22:00 +0800 Message-Id: <1520716927-17068-11-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520716927-17068-1-git-send-email-zhangckid@gmail.com> References: <1520716927-17068-1-git-send-email-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH V5 10/17] 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 , Juan Quintela , Jason Wang , "Dr . David Alan Gilbert" , Markus Armbruster , Zhang Chen , Paolo Bonzini 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 --- migration/colo.c | 20 ++++++++++++++++++++ qapi/migration.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index c083d36..8ca6381 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,18 @@ out: qemu_fclose(fb); } + /* + * There are only two reasons we can go here, some error happened. + * Or the user triggered failover. + */ + if (failover_get_state() == FAILOVER_STATUS_NONE) { + 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); + } + /* Hope this not to be too long to wait here */ qemu_sem_wait(&s->colo_exit_sem); qemu_sem_destroy(&s->colo_exit_sem); @@ -744,6 +757,13 @@ out: if (local_err) { error_report_err(local_err); } + if (failover_get_state() == FAILOVER_STATUS_NONE) { + 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/migration.json b/qapi/migration.json index 7f465a1..6c6c50e 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -858,6 +858,41 @@ '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: which COLO mode the VM was in when it exited. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 2.12 +# +# 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 +# +# @request: COLO exit is due to an external request +# +# @error: COLO exit is due to an internal error +# +# Since: 2.12 +## +{ 'enum': 'COLOExitReason', + 'data': [ 'request', 'error' ] } + +## # @x-colo-lost-heartbeat: # # Tell qemu that heartbeat is lost, request it to do takeover procedures.