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: 947549 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Xl1igTB9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41YZv81m2Rz9s3Z for ; Mon, 23 Jul 2018 05:49:08 +1000 (AEST) Received: from localhost ([::1]:57281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhKLp-0005Sp-Sm for incoming@patchwork.ozlabs.org; Sun, 22 Jul 2018 15:49:05 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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: #