From patchwork Fri Jan 19 13:44:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10175353 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 7ECFF60386 for ; Fri, 19 Jan 2018 13:58:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FF3C285EA for ; Fri, 19 Jan 2018 13:58:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6410E2869F; Fri, 19 Jan 2018 13:58:20 +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 DBE42285EA for ; Fri, 19 Jan 2018 13:58:19 +0000 (UTC) Received: from localhost ([::1]:50655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecXBS-0005Iu-Pg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 19 Jan 2018 08:58:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecX0J-0003xh-Dc for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecX0F-0003La-2E for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:47 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:42798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecX0E-0003LK-TC for qemu-devel@nongnu.org; Fri, 19 Jan 2018 08:46:42 -0500 Received: by mail-pg0-x244.google.com with SMTP id q67so1458676pga.9 for ; Fri, 19 Jan 2018 05:46:42 -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=lSCwC99Noxssn3VatGN4GXPj6exgWJyE0rMb01p67aE=; b=jb8CaERNgxFtnfrPW+1ZjBlPqYZU0A6BLljhkmfYDq8+D99FP6UYyZMqmonZ9QTtpO OgQZuNoGStZVjX0WGobM/eWxkYkx4Hnmy6As2qUMfjFVDPdBMMgqQPwXDOvkUgW2+xIm DnnT4tqE3H5Kg5100pAxnZH0Eq0liZlN526kRMHGd2jLhfYU9UEMEvRGF+kci6vJqGc3 jeSttunL0TzHfqp4Eg15HZSbBYP3RATZWhdXjh52le6phBcT8Nf67JKYzHL7pbVzlztb S2HRzyvzK+YDmQTswTJ8cdDOaPekGOezRlenTBx6xon2MGKIY8b2XapiQTZobZ6EtLfv FGbA== 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=lSCwC99Noxssn3VatGN4GXPj6exgWJyE0rMb01p67aE=; b=XGluJ1C6748a+AEcj4l0Llf50pTH7yNVkQ2iN5s45w6WJUTjKkfwcw6Ng41pwOOpyj AOo+asOHGN/KMDCbPyKAVZbdH65Q6YcZ9N16tr8mWlxssr8ocz5kIc2pHx/pjau2vyGm +Vn38bzQ7Y8R5XIAHnj7X/XiWX7dFrR4hqIQlRCGu+jAKO8trsWRx3bDNXwm6cswVw/3 zppu4tnIVMsKi8tfvNkhGZWfO9mfaveDhmdiDhFOdRhbPIlIKr8prrcItBoyLymeiheG p9jTO0VzrBRGQ2px/ZF+u9oZd++sB3VlJPv+E08N+EYmQWsWmFnyykyuZi7a/9WceILh BySA== X-Gm-Message-State: AKGB3mKfb9NTdR5N81BzF8PdVlk6qttQSe9ahGei5784N9bbE2xmh2i1 GL0rxJr9oDX6YkimNrBRAp9/q/Gb X-Google-Smtp-Source: ACJfBouuoYEzw7z+yGFvu2mwTzTAIdb6IYCD136WvJaAuMwuqdtjotKcvHh9YQKl85XByAowJSIfQg== X-Received: by 10.99.126.86 with SMTP id o22mr37188684pgn.364.1516369601661; Fri, 19 Jan 2018 05:46:41 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id r88sm14251865pfb.17.2018.01.19.05.46.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jan 2018 05:46:40 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Fri, 19 Jan 2018 21:44:39 +0800 Message-Id: <1516369485-5374-11-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516369485-5374-1-git-send-email-zhangckid@gmail.com> References: <1516369485-5374-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::244 Subject: [Qemu-devel] [PATCH V4 10/16] 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 | 19 +++++++++++++++++++ qapi/migration.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 8d2e3f8..790b122 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -516,6 +516,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); @@ -746,6 +758,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 70e7b67..6fc95b7 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -869,6 +869,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.