From patchwork Mon Mar 11 11:23:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 226539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id E33642C008E for ; Mon, 11 Mar 2013 22:49:35 +1100 (EST) Received: from localhost ([::1]:44149 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF0wU-0006AH-Nx for incoming@patchwork.ozlabs.org; Mon, 11 Mar 2013 07:30:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF0rS-0006tx-Vz for qemu-devel@nongnu.org; Mon, 11 Mar 2013 07:25:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UF0rQ-0001ZN-A4 for qemu-devel@nongnu.org; Mon, 11 Mar 2013 07:25:46 -0400 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:35410) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UF0rP-0001Yq-ET for qemu-devel@nongnu.org; Mon, 11 Mar 2013 07:25:43 -0400 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 11 Mar 2013 16:51:29 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp08.in.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 11 Mar 2013 16:51:27 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id DA7EF3940053 for ; Mon, 11 Mar 2013 16:55:38 +0530 (IST) Received: from d28av02.in.ibm.com (d28av02.in.ibm.com [9.184.220.64]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2BBPZYd27066536 for ; Mon, 11 Mar 2013 16:55:35 +0530 Received: from d28av02.in.ibm.com (loopback [127.0.0.1]) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2BBPaAi025789 for ; Mon, 11 Mar 2013 22:25:38 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.175] (may be forged)) by d28av02.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r2BBNRVC015564; Mon, 11 Mar 2013 22:25:30 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Mon, 11 Mar 2013 19:23:10 +0800 Message-Id: <1363000996-13221-9-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1363000996-13221-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1363000996-13221-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13031111-2000-0000-0000-00000B42BDD1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.8 Cc: kwolf@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V9 08/14] qmp: add interface query-snapshots X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This interface returns info of valid internal snapshots for whole vm. Signed-off-by: Wenchao Xia Reviewed-by: Eric Blake --- block/qapi.c | 18 +++++++++++++++++ qapi-schema.json | 14 +++++++++++++ qmp-commands.hx | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+), 0 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index b78ea5c..7bf2581 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -14,6 +14,7 @@ #include "block/qapi.h" #include "block/snapshot.h" #include "block/block_int.h" +#include "qmp-commands.h" /* * check whether the snapshot is valid for whole vm. @@ -183,3 +184,20 @@ int bdrv_query_image_info(BlockDriverState *bs, *p_info = info; return 0; } + +SnapshotInfoList *qmp_query_snapshots(Error **errp) +{ + BlockDriverState *bs; + SnapshotInfoList *list = NULL; + + /* internal snapshot for whole vm */ + bs = bdrv_snapshots(); + if (!bs) { + error_setg(errp, "No available block device supports snapshots\n"); + return NULL; + } + + bdrv_query_snapshot_info_list(bs, &list, true, errp); + + return list; +} diff --git a/qapi-schema.json b/qapi-schema.json index 28b070f..014365b 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -839,6 +839,20 @@ { 'command': 'query-block', 'returns': ['BlockInfo'] } ## +# @query-snapshots: +# +# Get a list of internal snapshots for the whole virtual machine. Only valid +# internal snapshots will be returned, inconsistent ones will be ignored +# +# Returns: a list of @SnapshotInfo describing all consistent virtual machine +# snapshots +# +# Since: 1.5 +## +{ 'command': 'query-snapshots', + 'returns': ['SnapshotInfo'] } + +## # @BlockDeviceStats: # # Statistics of a virtual block device or a block backing device. diff --git a/qmp-commands.hx b/qmp-commands.hx index 95022e2..bd9e127 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1743,6 +1743,61 @@ EQMP }, SQMP +query-snapshots +--------------- + +Show the internal consistent snapshot information + +Each snapshot is represented by a json-object. The returned value +is a json-array of all snapshots + +Each json-object contain the following: + +- "id": unique snapshot id (json-string) +- "name": internal snapshot name (json-string) +- "vm-state-size": size of the VM state in bytes (json-int) +- "date-sec": UTC date of the snapshot in seconds (json-int) +- "date-nsec": fractional part in nanoseconds to be used with + date-sec(json-int) +- "vm-clock-sec": VM clock relative to boot in seconds (json-int) +- "vm-clock-nsec": fractional part in nanoseconds to be used with + vm-clock-sec (json-int) + +Example: + +-> { "execute": "query-snapshots" } +<- { + "return":[ + { + "id": "1", + "name": "snapshot1", + "vm-state-size": 0, + "date-sec": 10000200, + "date-nsec": 12, + "vm-clock-sec": 206, + "vm-clock-nsec": 30 + }, + { + "id": "2", + "name": "snapshot2", + "vm-state-size": 34000000, + "date-sec": 13000200, + "date-nsec": 32, + "vm-clock-sec": 406, + "vm-clock-nsec": 31 + } + ] + } + +EQMP + + { + .name = "query-snapshots", + .args_type = "", + .mhandler.cmd_new = qmp_marshal_input_query_snapshots, + }, + +SQMP query-blockstats ----------------