From patchwork Thu Mar 7 06:07:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 225747 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 461862C035E for ; Thu, 7 Mar 2013 17:43:09 +1100 (EST) Received: from localhost ([::1]:55656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU6z-0008Iz-6q for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2013 01:15:29 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51145) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU1t-0007ey-8z for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDU1r-0004Zq-MG for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:13 -0500 Received: from e28smtp09.in.ibm.com ([122.248.162.9]:33041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU1q-0004Z4-VC for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:11 -0500 Received: from /spool/local by e28smtp09.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Mar 2013 11:37:57 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp09.in.ibm.com (192.168.1.139) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 7 Mar 2013 11:37:55 +0530 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 189C3E0053 for ; Thu, 7 Mar 2013 11:41:20 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r276A1iK34996422 for ; Thu, 7 Mar 2013 11:40:01 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r276A3OT030747 for ; Thu, 7 Mar 2013 17:10:04 +1100 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.208]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r2767TJp021188; Thu, 7 Mar 2013 17:09:52 +1100 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2013 14:07:15 +0800 Message-Id: <1362636445-7188-11-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13030706-2674-0000-0000-000008150F37 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.9 Cc: kwolf@redhat.com, aliguori@us.ibm.com, capitulino@redhat.com, stefanha@gmail.com, armbru@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V8 10/20] 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 now return valid internal snapshots for whole vm. Signed-off-by: Wenchao Xia --- block/qapi.c | 22 +++++++++++++++++++++ qapi-schema.json | 14 +++++++++++++ qmp-commands.hx | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 0 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 0c3055f..b903dd8 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. @@ -180,3 +181,24 @@ int bdrv_query_image_info(BlockDriverState *bs, *p_info = info; return 0; } + +SnapshotInfoList *qmp_query_snapshots(Error **errp) +{ + BlockDriverState *bs; + SnapshotInfoList *list = NULL; + int ret; + + /* internal snapshot for whole vm */ + bs = bdrv_snapshots(); + if (!bs) { + error_setg(errp, "No available block device supports snapshots\n"); + return NULL; + } + + ret = bdrv_query_snapshot_info_list(bs, &list, true, errp); + if (ret < 0) { + qapi_free_SnapshotInfoList(list); + list = NULL; + } + return list; +} diff --git a/qapi-schema.json b/qapi-schema.json index 28b070f..3710495 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 whole virtual machine, only valid +# internal snapshot 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..d505209 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 nano seconds 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 nano seconds 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 ----------------