From patchwork Sun Mar 11 07:45:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Chen X-Patchwork-Id: 10274547 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 723A360211 for ; Sun, 11 Mar 2018 07:55:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 650A528DE5 for ; Sun, 11 Mar 2018 07:55:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54A6C28DEE; Sun, 11 Mar 2018 07:55:28 +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 EC2FF28DE5 for ; Sun, 11 Mar 2018 07:55:27 +0000 (UTC) Received: from localhost ([::1]:53395 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euvpH-0005uB-8b for patchwork-qemu-devel@patchwork.kernel.org; Sun, 11 Mar 2018 03:55:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59309) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1euvgT-0006YW-TU for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1euvgQ-0000tF-Ra for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:21 -0400 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]:37267) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1euvgQ-0000so-LT for qemu-devel@nongnu.org; Sun, 11 Mar 2018 03:46:18 -0400 Received: by mail-pf0-x242.google.com with SMTP id h11so3039964pfn.4 for ; Sat, 10 Mar 2018 23:46:18 -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=acZC30ja156O5Gnyj/WgqIdYeX5z3oaQRSH1m++FKfA=; b=FV630v78OPlCWZc2C8XxtKW6I0gmujscwftiU3X8F3WFJCf8OWQ0u3jXYIOvjRJma7 VWp0MHU7Ek/8O/a8Yd7pYX9JQyslA29xVP65LY4z+THa/rwuJ8UVda471hXkX3wwHPFY cadMqMj1JaR3Yf03rDWqzoxTXIhHIECG8YYVfQxsxRQMfumi5bom+qoNslnp0lIB/5cy QyH8jM9w1BmGi3EYjvCAEg7MkZRUIT89kXDVsOJtemRWLLnZnA7ynETc6DVUqJJfgW58 Tw0lj5oCeIdMv34odSQnAqrgew0RqDZiPf60TRNOsvk3bZl7UrZ04HBpYzaJzt+R4WaD PqeQ== 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=acZC30ja156O5Gnyj/WgqIdYeX5z3oaQRSH1m++FKfA=; b=BJ8zh5gl8zFkFGHzpMPperkndCC8hsZCg7TSMUl75gKjPoJ8IAsDawM7seglEvmRyQ gbQF1DlnLZL2jZjLtzj2AeK8fpf7BHo47NnKsMn1Q+b0cN6+ECumVfsuTJBNYxRAsVoT cJRs7eGsgfcF2AKm8uG3k9wUPksEZ1KzaQ2z+8IEwNIGOLXJIRt5OLRUe72JKtaflgov kI4JT/0YSwBpi8fBW6zei0+0TV7H+RfUpOnykV4rhqr7NfDT/21ms9EwTWU7K+1s7LFK D71cyvy2gj719va1vJy6x9QkLIoT7GFIke/mP0c2keDwHbH6qdwGx+jR71LQMk9+8yKm antg== X-Gm-Message-State: AElRT7EGlt8j00oycBFQ2Nemz7dw0mK+fwoqHpqWZRA4mUjqdmudkl0H K2Cbuz8L8bCv0ncVaGncdvpH1+gK X-Google-Smtp-Source: AG47ELvOIsZVeXENnpsN/cC1w8s3SMhIcBFEBdUDtwnnmVKQ3S3kz+UwIeSDOL8ASIM6qIF1Ey34yg== X-Received: by 10.98.65.198 with SMTP id g67mr4113548pfd.127.1520754377343; Sat, 10 Mar 2018 23:46:17 -0800 (PST) Received: from localhost.localdomain (120.236.201.35.bc.googleusercontent.com. [35.201.236.120]) by smtp.gmail.com with ESMTPSA id t16sm10917037pfm.69.2018.03.10.23.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 10 Mar 2018 23:46:16 -0800 (PST) From: Zhang Chen To: qemu-devel@nongnu.org Date: Sun, 11 Mar 2018 15:45:08 +0800 Message-Id: <1520754314-5969-13-git-send-email-zhangckid@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520754314-5969-1-git-send-email-zhangckid@gmail.com> References: <1520754314-5969-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:c00::242 Subject: [Qemu-devel] [PATCH V6 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 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 | 31 +++++++++++++++++++++++++++++++ qapi/migration.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index 8ca6381..127db3c 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -237,6 +237,37 @@ 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 = COLO_MODE_PRIMARY; + } else { + mis = migration_incoming_get_current(); + + if (mis->state == MIGRATION_STATUS_COLO) { + s->colo_running = true; + } else { + s->colo_running = false; + } + s->mode = COLO_MODE_SECONDARY; + } + + s->reason = failover_get_state(); + + 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..8ccdd21 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -1201,3 +1201,36 @@ # 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. +# +# @colo-running: if true means COLO running well, otherwise COLO have done. +# +# @reason: describes the reason for the COLO exit. +# +# Since: 2.12 +## +{ 'struct': 'COLOStatus', + 'data': { 'mode': 'COLOMode', 'colo-running': 'bool', '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", "colo-running": true, "reason": "request" } } +# +# Since: 2.12 +## +{ 'command': 'query-colo-status', + 'returns': 'COLOStatus' }