From patchwork Sat Apr 13 08:56:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 236314 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 37CC32C00A2 for ; Sat, 13 Apr 2013 19:04:28 +1000 (EST) Received: from localhost ([::1]:60961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwMy-0005cN-3K for incoming@patchwork.ozlabs.org; Sat, 13 Apr 2013 05:03:36 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwJq-0000Wh-5I for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQwJp-0000o8-3Y for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:22 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:42960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQwJo-0000ns-IH for qemu-devel@nongnu.org; Sat, 13 Apr 2013 05:00:21 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 13 Apr 2013 18:58:06 +1000 Received: from d23dlp02.au.ibm.com (202.81.31.213) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sat, 13 Apr 2013 18:58:03 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id 6E4A62BB0023 for ; Sat, 13 Apr 2013 19:00:14 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3D8khus8913218 for ; Sat, 13 Apr 2013 18:46:43 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3D90DZ2028362 for ; Sat, 13 Apr 2013 19:00:14 +1000 Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.157]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r3D8u24N020091; Sat, 13 Apr 2013 19:00:11 +1000 From: Wenchao Xia To: qemu-devel@nongnu.org Date: Sat, 13 Apr 2013 16:56:39 +0800 Message-Id: <1365843407-16504-11-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1365843407-16504-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13041308-5140-0000-0000-000003065AF3 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 202.81.31.141 Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V12 10/18] 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 --- block/qapi.c | 17 +++++++++++++++ qapi-schema.json | 14 +++++++++++++ qmp-commands.hx | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 0 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index 73c1961..13c7860 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -268,6 +268,23 @@ BlockInfo *bdrv_query_info(BlockDriverState *bs) return info; } +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; +} + BlockInfoList *qmp_query_block(Error **errp) { BlockInfoList *head = NULL, **p_next = &head; diff --git a/qapi-schema.json b/qapi-schema.json index db542f6..16d0b1f 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -841,6 +841,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 1e0e11e..e13c029 100644 --- a/qmp-commands.hx +++ b/qmp-commands.hx @@ -1765,6 +1765,64 @@ EQMP }, SQMP +query-snapshots +--------------- + +Show the internal consistent snapshot information + +Consistent snapshots are snapshots that exist in all writeable block devices. +When 'savevm' takes a snapshot it uses the same ID across all writeable block +devices. If a snapshot ID only exists in one block device then it is not a +consistent one. Each snapshot is represented by a json-object and 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 ----------------