From nobody Mon Feb 9 13:39:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535950218709309.6465692950742; Sun, 2 Sep 2018 21:50:18 -0700 (PDT) Received: from localhost ([::1]:43405 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwgob-00013j-Gj for importer@patchew.org; Mon, 03 Sep 2018 00:50:17 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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" =20 static bool vmstate_loading; static Notifier packets_compare_notifier; @@ -237,6 +238,26 @@ void qmp_xen_colo_do_checkpoint(Error **errp) #endif } =20 +COLOStatus *qmp_query_colo_status(Error **errp) +{ + COLOStatus *s =3D g_new0(COLOStatus, 1); + + s->mode =3D get_colo_mode(); + + switch (failover_get_state()) { + case FAILOVER_STATUS_NONE: + s->reason =3D COLO_EXIT_REASON_NONE; + break; + case FAILOVER_STATUS_REQUIRE: + s->reason =3D COLO_EXIT_REASON_REQUEST; + break; + default: + s->reason =3D 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' } =20 +## +# @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: # --=20 2.17.GIT