From patchwork Mon Sep 3 04:38:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10585425 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 19600174C for ; Mon, 3 Sep 2018 04:49:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 071C629529 for ; Mon, 3 Sep 2018 04:49:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFBEE29533; Mon, 3 Sep 2018 04:49:44 +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 96EC629529 for ; Mon, 3 Sep 2018 04:49:44 +0000 (UTC) Received: from localhost ([::1]:43405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgo3-00013j-T8 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 03 Sep 2018 00:49:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56413) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwggL-0000VY-PK for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwggK-0005fH-Ut for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:45 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:34652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwggK-0005eC-7N for qemu-devel@nongnu.org; Mon, 03 Sep 2018 00:41:44 -0400 Received: by mail-pl1-x643.google.com with SMTP id f6-v6so8059994plo.1 for ; Sun, 02 Sep 2018 21:41:43 -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=aZuHHS6luCm6QPodXWJwWtpEq349UrPUbTFjnVdJmp4=; b=R5SLWE1/FE26BoBsQW1WvowpuPEWQsq3j9uN0YhNq/dWdTtXa6nAW9yOesTJrW0B41 ZreBAAwZP4yr9YKBIBSCs1xa3+izxrH0M94+gBoVSlquLVJydzeELgxE3iZZMEzpsq4U 6pWXqIHx9AjlkA+Tn5G51EYj0Miscm/yweqXas/r0wtm7mG2GB2IHgwW/OvGAU8F2tdn lZLejRxFeuHMTG+i/fEV9ASZLxfCdSVl5qFk7CmF/6ZFfaHP8tlErTQoRJl/sPCxLxK7 g+iuvQcKiVuIG5VIbsNrgPCQdMJ/Op/27SUPgY1YeLBgAbfEMG/a8WiqHTu1m7qe5MIS iwLw== 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=aZuHHS6luCm6QPodXWJwWtpEq349UrPUbTFjnVdJmp4=; b=ZNS6GQJnibxLG/BgXVOq8dAtx6ZxihtayVe92lHQSQZg/CceADKVhc6z85y0uzq790 rsjWlfICva3nXv4zg3Dnwk2ESYibrqUO2HMxyhZogeLB52VLVgJ7K7ECCX8r2cMqjVb8 YSDLutSMEek9hfdUIaf9V1et7UheAZaRneNJX5rGc4uOqc80HPIXzEFm6xMDhrncQhai N7zDK6MogVH+LYgCXyhJA3Ve3OfS6ljrG8uZHl632KOAX2o9lpL1kBluENTjiBNAuqJe NBrVayLiuSdowDbqTsbF7r1TmkJ+YSEcKPFbDPVp4gin9ooCKf7tJQsGT5K4NB6dqcyu mFYA== X-Gm-Message-State: APzg51Cx5JPM6T/miIxNrvPUiXNXrthdLhnjAOkPIwrkDzV+oA2nIZ4c FE5leMV7n/tM34jGqVUrjCacvbB8 X-Google-Smtp-Source: ANB0VdZ2mXMws4oKczfF9Mo24E3aw2wxkCQLw9WhqFIu3oE7K7m5E3/XQBwOCJqBKudMaxV1A7bzVg== X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr26600425pll.66.1535949702630; Sun, 02 Sep 2018 21:41:42 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id g6-v6sm32738308pfb.11.2018.09.02.21.41.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Sep 2018 21:41:41 -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: Mon, 3 Sep 2018 12:38:53 +0800 Message-Id: <20180903043900.28592-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180903043900.28592-1-zhangckid@gmail.com> References: <20180903043900.28592-1-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::643 Subject: [Qemu-devel] [PATCH V12 12/19] 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 9107ac124a..8c4ba373aa 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 c0bc77fd8d..840a118d11 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1283,6 +1283,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: #