From patchwork Sun Mar 11 07:45:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10274543 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 CEE1A60211 for ; Sun, 11 Mar 2018 07:53:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C36ED28DD4 for ; Sun, 11 Mar 2018 07:53:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7EE828DDE; Sun, 11 Mar 2018 07:53:19 +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 180C528DD4 for ; Sun, 11 Mar 2018 07:53:18 +0000 (UTC) Received: from localhost ([::1]:53382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euvnC-00047B-1w for patchwork-qemu-devel@patchwork.kernel.org; Sun, 11 Mar 2018 03:53:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euvgN-0006T4-HW for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euvgM-0000qV-JY for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:15 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:41355) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euvgM-0000q1-D2 for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:14 -0400 Received: by mail-pf0-x241.google.com with SMTP id f80so3040525pfa.8 for ; Sat, 10 Mar 2018 23:46:14 -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=CJnOHXk3ttK72RpIEK3drqddQVpgrW+25eEgjDOLf6wXeLAkeq3Q9FjQ1sPLfC3jr6 aB0Tni+y+eXHBGtN5PHAJ/cNErpN1pEMwHoqU2ff/Y4AvlQgo/8+ek24VrVpKjh8HVXC B1s1QLvYt0OGOMVVufE0wIJEQmaq88QNlLfFi80Mdw+XogIDZ7JL5QO4HRlx/zX4gp7X 85bmif/N2l48ackvt1I1oVGZrztWWl3niTiF6k9nDc28A/+RRqd1VC2rUGWsjgEHPm+A uV0r4L5YaSWKkaMMW4zho8+1aJ/E+AiSbtJTYODe1015ByUoiS/sgDRHy63IIXPnRVMp Q+6w== 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=HNVX8QShO9RWYQxC5FHttP9pusnzYJCvUhE3DCsX3PM3eks/fnHdVmY8pvUMc7Sg5s QQGfZKYSur06JvQBuRnlB5o0VzuHriNVWu/xeQZsHHgHwnQ76ostTuNZYsKXG1YisJE4 eyfjz3zVZD+sWP54ACzRRXlSzu3VMOYxZk05RFgrxznCa8c+HWatt6K2XbsautOyTygC DZenUIsFNBnTF+OFgDgyCkGKma+4ycmFABmNE7CBvi4iRH9ecgle54w3x4jzc5APnwLf gltGAPvcfKGeR+dTHokms8o1TjxcZWbmmTM5Uh6kgua8+iAyPfgVbcxjMZ8pZfLDQcQu Bj1g== X-Gm-Message-State: AElRT7F5SiTgLKxrd3v93h9guje5HmI4ebX/0GCV/bxhSs/kHfd7MJSb +tyUDvxY+P+muWj/y/TGvoD8LIVy X-Google-Smtp-Source: AG47ELuaTYRlf5aM8MUpyiWH70jfNOSvdDIhZEZfqZbvomGf9dtEXWFHeX92bzCmk00bsQOPcoTdbA== X-Received: by 10.98.70.89 with SMTP id t86mr4101978pfa.215.1520754373058; Sat, 10 Mar 2018 23:46:13 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id t16sm10917037pfm.69.2018.03.10.23.46.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 23:46:11 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2018 15:45:07 +0800 Message-Id: <1520754314-5969-12-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520754314-5969-1-git-send-email-zhangckid@gmail.com> References: <1520754314-5969-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:c00::241 Subject: [Qemu-devel] [PATCH V6 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.