From patchwork Sat Aug 11 20:59:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10563573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 096B11510 for ; Sat, 11 Aug 2018 21:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F20A32990B for ; Sat, 11 Aug 2018 21:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3EF029946; Sat, 11 Aug 2018 21:13:56 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,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 881312990B for ; Sat, 11 Aug 2018 21:13:56 +0000 (UTC) Received: from localhost ([::1]:33242 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fobCt-0000Ce-Lc for patchwork-qemu-devel@patchwork.kernel.org; Sat, 11 Aug 2018 17:13:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fob0A-0005Hp-8G for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fob07-0001So-2W for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:46 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:42183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fob06-0001SP-TJ for qemu-devel@nongnu.org; Sat, 11 Aug 2018 17:00:43 -0400 Received: by mail-pl0-x241.google.com with SMTP id g6-v6so5380157plq.9 for ; Sat, 11 Aug 2018 14:00:42 -0700 (PDT) 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=PWweyNM/R6oxWdlr2CZr7URUz0go+xHI7GiQr8rdHHk=; b=sGGBweLNF0faVRJPjaRo4eISW6TIyMAYsv5TINLABJG6QdlrJITGifxoDK6AwfVnC9 ysN0XqohTTGJcvzz2H59kZ1cGf+7+1784dyPMafk1T+BcSahi4ebxLNulWAufb+2QjEs X/kfWWvoFaAuXIrd6fynZH8sEtmuNRsYINR7wRvoivWnqrrd7cprXjj5lbbob7VCPHDQ 3JdGbhJ2pMzCTkg6onaGmJS8YmT+LySlkXyBf0zXRz/RcLbjkzODnlP3XYeGos7E/wlZ UHyvmYLJPPRHwi7EpiipgnPjUzpUZR0+I9v6dDcuK+GBndpGrZ/5/iEaKZa2cd0Ompus 96jw== 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=PWweyNM/R6oxWdlr2CZr7URUz0go+xHI7GiQr8rdHHk=; b=Mib0GX6epC4koSjiUhX9g+jp0KypQA1mwraEcFYwRMBqx3/QhZGcUXbWqG0Jwx/Leu 4n/NvSf8RRz+vu+wl0ZngslmgetWhdo1J0P4Zfg1fmgovJYyPhpoWahxvm1GhfT0VoLn s1PsFSnm6ALvOfsBYUr4HHkxXeewiarKXRnlVA1OXMRYWKlFqGmAv6cDHNLRPsIbFYDH XROn/7GKkHh6EzILCXJurWMUy0fP2sdRGD9Vwj/hIP6z2GEJJ63B00VcE5M+nQKOcjGs wy0A9HFcAfnW+hsu4nqoL1Fno62ZYfcuhmO6NvRMociR1LxnADsirD7UlVReFru1JcgN 5ncg== X-Gm-Message-State: AOUpUlE0rvIRVutuCn31MuRgAYWQNACXmZNyzA48pXUbBketRTCxLQqK fcwNAnj0+tLazrjMYCBTHe3KN3Uj X-Google-Smtp-Source: AA+uWPxwtpMgucgh9CnXAIw/RDPBvAm82WXyWMX+aHJ+z++XtNQ09updsz98pKi+NDKccSO1XkHL1w== X-Received: by 2002:a17:902:4381:: with SMTP id j1-v6mr11098234pld.104.1534021241675; Sat, 11 Aug 2018 14:00:41 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id h24-v6sm23502641pfk.113.2018.08.11.14.00.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Aug 2018 14:00:40 -0700 (PDT) From: Zhang Chen To: qemu-devel@nongnu.org, Paolo Bonzini , Juan Quintela , "Dr . David Alan Gilbert" , Jason Wang , Eric Blake , Markus Armbruster Date: Sun, 12 Aug 2018 04:59:16 +0800 Message-Id: <20180811205924.4113-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180811205924.4113-1-zhangckid@gmail.com> References: <20180811205924.4113-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH V11 12/20] qapi: Add new command to query colo status 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: Zhang Chen , zhanghailiang , Li Zhijian , Zhang Chen Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Libvirt or other high level software can use this command query colo status. You can test this command like that: {'execute':'query-colo-status'} Signed-off-by: Zhang Chen Signed-off-by: Zhang Chen --- migration/colo.c | 21 +++++++++++++++++++++ qapi/migration.json | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 8fdb79ac73..b355de3f01 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -29,6 +29,7 @@ #include "net/colo.h" #include "block/block.h" #include "qapi/qapi-events-migration.h" +#include "qapi/qmp/qerror.h" static bool vmstate_loading; static Notifier packets_compare_notifier; @@ -237,6 +238,26 @@ void qmp_xen_colo_do_checkpoint(Error **errp) #endif } +COLOStatus *qmp_query_colo_status(Error **errp) +{ + COLOStatus *s = g_new0(COLOStatus, 1); + + s->mode = get_colo_mode(); + + switch (failover_get_state()) { + case FAILOVER_STATUS_NONE: + s->reason = COLO_EXIT_REASON_NONE; + break; + case FAILOVER_STATUS_REQUIRE: + s->reason = COLO_EXIT_REASON_REQUEST; + break; + default: + s->reason = COLO_EXIT_REASON_ERROR; + } + + return s; +} + static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) { diff --git a/qapi/migration.json b/qapi/migration.json index 78932206dd..87312dd093 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1251,6 +1251,38 @@ ## { 'command': 'xen-colo-do-checkpoint' } +## +# @COLOStatus: +# +# The result format for 'query-colo-status'. +# +# @mode: COLO running mode. If COLO is running, this field will return +# 'primary' or 'secondary'. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 3.0 +## +{ 'struct': 'COLOStatus', + 'data': { 'mode': 'COLOMode', 'reason': 'COLOExitReason' } } + +## +# @query-colo-status: +# +# Query COLO status while the vm is running. +# +# Returns: A @COLOStatus object showing the status. +# +# Example: +# +# -> { "execute": "query-colo-status" } +# <- { "return": { "mode": "primary", "active": true, "reason": "request" } } +# +# Since: 3.0 +## +{ 'command': 'query-colo-status', + 'returns': 'COLOStatus' } + ## # @migrate-recover: #