From patchwork Sun Jul 22 19:33:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10539401 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 01EBB112B for ; Sun, 22 Jul 2018 19:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E24F12842E for ; Sun, 22 Jul 2018 19:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D53C228434; Sun, 22 Jul 2018 19:49:31 +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 7B24B2842E for ; Sun, 22 Jul 2018 19:49:31 +0000 (UTC) Received: from localhost ([::1]:57283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKME-0005nb-QD for patchwork-qemu-devel@patchwork.kernel.org; Sun, 22 Jul 2018 15:49:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37817) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhK8W-0002wQ-Ov for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhK8T-0000o5-L8 for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:20 -0400 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]:44098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhK8T-0000np-Ed for qemu-devel@nongnu.org; Sun, 22 Jul 2018 15:35:17 -0400 Received: by mail-pg1-x541.google.com with SMTP id r1-v6so10655761pgp.11 for ; Sun, 22 Jul 2018 12:35:17 -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=Zfh8Y4pwvfjhTw2l8csOLfzbGD+HGghoH1qZptJUvF8=; b=Xl1igTB9mFWKyZyOuKoL/6HajLCcAXDj94NA4DAtlOEGGhf+tkADn8X6t9Ow8ACLCT ExXIxoXq1f4asDJrPz11RInAw1Utrtlx9Af3bZfnMkyybfiQWiWhpo41qLtoyjpKHR2d qRK0gH/JKVTIehnYMnNZRGpv2V/sH9eDzGhCKLhshG3n9HvEFNmrsL+ReggWmh1Wz4Df T+wra0Cso01WjNWxfZXXdBPJrgm7OcFB74gRR9oITtHZs8ZrU0wh4Yu8tULbZ0q5a+G5 fodZxbqhL9foJLn2ioCgkYdULlNAORYioaf1NNU0GlcSA70NHJYM252ldI/8DW/ewl1K 8KLg== 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=Zfh8Y4pwvfjhTw2l8csOLfzbGD+HGghoH1qZptJUvF8=; b=ZvBQ4J4UGogqucRwz92elA7hdO+hndeKJcApzYvBJRC1TWqzvwHMwC+OPgb78jlwx7 xtLRZnAEUTVw2nFEF6/SM5PVkgMBQ5ce8VgP5hGd62TJHwTlAfzcFFwcVx7aMdRcqTzq zw6syuiekK0lFHDaU0Pj/1I025HniVwxCePkoaxhqvq8NftJuxV2JKSzJA6NvOKSySIy 5mJCL4t6X9uqcOQZQFscm07jBJKPyvEK4hDu8o5mwTHnqS2GdvzDCc/x3ivG6/HgH/zv WcCmx4oaT0VoU8SmrJU0JX456CIj4NZ9XsCFcMIYhJ6zooavfXlN80o5MuDTJ7YqoKHe XG3w== X-Gm-Message-State: AOUpUlHaV5l7AVP9UEUPkIN1YhsEfINI6Irg1y5vDxhGTwldxR7sxcYA VL2wx/oZ8IKsRJW1q6SwcogtLljU X-Google-Smtp-Source: AAOMgpcJ5xcvwswKE+kmtO4ATtvw68q/53xkmKR9HVL8GatiZglc9fepnD2xKbSZyy7awZUm5s1QyQ== X-Received: by 2002:a62:1016:: with SMTP id y22-v6mr10402357pfi.109.1532288116288; Sun, 22 Jul 2018 12:35:16 -0700 (PDT) Received: from localhost.localdomain (155.150.229.35.bc.googleusercontent.com. [35.229.150.155]) by smtp.gmail.com with ESMTPSA id 87-v6sm14215353pfn.103.2018.07.22.12.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jul 2018 12:35:15 -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, 23 Jul 2018 03:33:42 +0800 Message-Id: <20180722193350.6028-13-zhangckid@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180722193350.6028-1-zhangckid@gmail.com> References: <20180722193350.6028-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::541 Subject: [Qemu-devel] [PATCH V10 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: 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 --- 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 cdae7ddccb..21b9946595 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: #