From patchwork Sat Mar 10 21:22:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10274383 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B41D60390 for ; Sat, 10 Mar 2018 21:36:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396DB28E19 for ; Sat, 10 Mar 2018 21:36:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AAE328E20; Sat, 10 Mar 2018 21:36:58 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 B868D28E08 for ; Sat, 10 Mar 2018 21:36:57 +0000 (UTC) Received: from localhost ([::1]:52043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eumAi-00065O-SF for patchwork-qemu-devel@patchwork.kernel.org; Sat, 10 Mar 2018 16:36:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eulxQ-0002jj-2z for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eulxP-0003Ps-6V for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:12 -0500 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:33275) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eulxP-0003Pn-0b for qemu-devel@nongnu.org; Sat, 10 Mar 2018 16:23:11 -0500 Received: by mail-pg0-x244.google.com with SMTP id g12so4943331pgs.0 for ; Sat, 10 Mar 2018 13:23:10 -0800 (PST) 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=BV0Tmm+QGqTZSP4DC7KUbEzKRI1xCr0G5gQI0kcvnZM=; b=Vs0mlOXCMinWwfSwzI5cQ+wt8O7v82HtWlL0FR39hmSDK6lDJ2b3om0flNPXKzu9zi I6VuCSOPqe3wJICccnM2RzWjB5JSk7sQqlnmcH4BhE4qnxwf4xzFURi5gG9zN7JRtFE6 ISnqyaG7jP/0XBxCeJU2B6FpqmMHBDyHefncekLdkQ2NzrauzMCuXqVifu/NqtP5l+eA iXh/m08mQL9WQso4esOtORY3Sy5NlVVB4ocv1m9npnRwOOsbwhCL3TWI+Vy/aa0FK81s Z9rXtO4iZUtn1bm0mvbM/k0BOotzLLg9at6bnhrQgM4d8uKtt0vcP86nSMab+J04xcb4 ncjw== 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=BV0Tmm+QGqTZSP4DC7KUbEzKRI1xCr0G5gQI0kcvnZM=; b=bPall9NnVLMHwAZM+N7Yc2hdXmvGSuxqPuxLbCnBFjD4BQtGMdHyDJ4tLE+ZuaupJ7 gJ3hRVka4X0dOCqTGUEMOpQlD1VZsWiMmjWaguWa6UwXS/gW0XHhRkGEO42hLi/Q8YUf Ep+hQeA2K3XEk5bff5WcWs23Jc5gkbQ/dIpyWZkNHfwTBdHTOLlwHegfc+e+7R5CHufO +FvJ24adoDMoGKOMZfgi70GlozwrRvr4NyBHYxBe+2C2IuzHCS0cGe60NUNSYXKExULd aTYMKAOAnBqbNGLQXf9bwHCW/qM5fCc5ilnX1MbFrn7uGL6sSfCFM/JQOvMFBF6D7rb9 jPsg== X-Gm-Message-State: AElRT7HCRb18h0QesVcXiaqqxg3NgZpx4ulpy4a383aCgHAFxzPqlzWe 1HS9REcSVMEGYOXEH9op7gZ+kA4R X-Google-Smtp-Source: AG47ELvAFgEja2nJ+r4EsSJ9v1Xd7rAg2rT8tV0NbBTKz0mdDdd5ru3PI3RnoN/SvLliv6mS3cFMUA== X-Received: by 10.99.95.135 with SMTP id t129mr2627pgb.268.1520716989869; Sat, 10 Mar 2018 13:23:09 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id q65sm10532191pfd.140.2018.03.10.13.23.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 13:23:09 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2018 05:22:01 +0800 Message-Id: <1520716927-17068-12-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520716927-17068-1-git-send-email-zhangckid@gmail.com> References: <1520716927-17068-1-git-send-email-zhangckid@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH V5 11/17] 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 , Juan Quintela , Jason Wang , "Dr . David Alan Gilbert" , Markus Armbruster , Zhang Chen , Paolo Bonzini 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 sofware 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 | 35 +++++++++++++++++++++++++++++++++++ qapi/migration.json | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 8ca6381..b4243ab 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -237,6 +237,41 @@ void qmp_xen_colo_do_checkpoint(Error **errp) #endif } +COLOStatus *qmp_query_colo_status(Error **errp) +{ + MigrationState *m; + MigrationIncomingState *mis; + COLOStatus *s = g_new0(COLOStatus, 1); + + if (get_colo_mode() == COLO_MODE_PRIMARY) { + m = migrate_get_current(); + + if (m->state == MIGRATION_STATUS_COLO) { + s->colo_running = true; + } else { + s->colo_running = false; + } + s->mode = true; + } else { + mis = migration_incoming_get_current(); + + if (mis->state == MIGRATION_STATUS_COLO) { + s->colo_running = true; + } else { + s->colo_running = false; + } + s->mode = false; + } + + if (failover_get_state() == FAILOVER_STATUS_NONE) { + s->reason = true; + } else { + s->reason = false; + } + + return s; +} + static void colo_send_message(QEMUFile *f, COLOMessage msg, Error **errp) { diff --git a/qapi/migration.json b/qapi/migration.json index 6c6c50e..8f81f36 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1201,3 +1201,38 @@ # Since: 2.9 ## { 'command': 'xen-colo-do-checkpoint' } + +## +# @COLOStatus: +# +# The result format for 'query-colo-status'. +# +# @mode: which COLO mode the VM was in when it exited. +# true is primary mode, false is secondary mode. +# +# @colo_running: if true means COLO running well, otherwise COLO have done. +# +# @reason: describes the reason for the COLO exit. +# true is error, false is user request. +# +# Since: 2.12 +## +{ 'struct': 'COLOStatus', + 'data': { 'mode': 'bool', 'colo_running': 'bool', 'reason': 'bool' } } + +## +# @query-colo-status: +# +# Query COLO status while the vm is running. +# +# Returns: A @COLOStatus object showing the status. +# +# Example: +# +# -> { "execute": "query-colo-status" } +# <- { "return": { "colo_running": "true", "mode": "true", "reason": "true" } } +# +# Since: 2.12 +## +{ 'command': 'query-colo-status', + 'returns': 'COLOStatus' }