From patchwork Mon Jan 14 07:09:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wayne Xia X-Patchwork-Id: 211716 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 F00F52C0096 for ; Mon, 14 Jan 2013 18:15:05 +1100 (EST) Received: from localhost ([::1]:45313 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TueG8-0005fv-3k for incoming@patchwork.ozlabs.org; Mon, 14 Jan 2013 02:15:04 -0500 Received: from eggs.gnu.org ([208.118.235.92]:35410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TueED-0002jx-Jv for qemu-devel@nongnu.org; Mon, 14 Jan 2013 02:13:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TueDr-0006Ow-LX for qemu-devel@nongnu.org; Mon, 14 Jan 2013 02:13:05 -0500 Received: from e28smtp01.in.ibm.com ([122.248.162.1]:58963) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TueDr-0006OJ-11 for qemu-devel@nongnu.org; Mon, 14 Jan 2013 02:12:43 -0500 Received: from /spool/local by e28smtp01.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Jan 2013 12:41:10 +0530 Received: from d28dlp02.in.ibm.com (9.184.220.127) by e28smtp01.in.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 14 Jan 2013 12:41:09 +0530 Received: from d28relay01.in.ibm.com (d28relay01.in.ibm.com [9.184.220.58]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id F2ABA3940050 for ; Mon, 14 Jan 2013 12:42:39 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay01.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0E7Cbij39125002 for ; Mon, 14 Jan 2013 12:42:37 +0530 Received: from d28av01.in.ibm.com (loopback [127.0.0.1]) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r0E7CcqQ008813 for ; Mon, 14 Jan 2013 07:12:39 GMT Received: from RH63Wenchao (wenchaox.cn.ibm.com [9.115.122.169] (may be forged)) by d28av01.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r0E79tJi028786; Mon, 14 Jan 2013 07:12:36 GMT From: Wenchao Xia To: qemu-devel@nongnu.org Date: Mon, 14 Jan 2013 15:09:47 +0800 Message-Id: <1358147387-8221-12-git-send-email-xiawenc@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1358147387-8221-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1358147387-8221-1-git-send-email-xiawenc@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13011407-4790-0000-0000-00000671248E X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 122.248.162.1 Cc: aliguori@us.ibm.com, phrdina@redhat.com, stefanha@gmail.com, armbru@redhat.com, lcapitulino@redhat.com, pbonzini@redhat.com, Wenchao Xia Subject: [Qemu-devel] [PATCH V3 11/11] hmp: show snapshot on single block device 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 patch use block layer API to qmp snapshot info on a block device, then use the same code dumping vm snapshot info, to print in monitor. Signed-off-by: Wenchao Xia --- Note: This patch need previous hmp extention patch which enable info sub command take qdict * as paramter. --- monitor.c | 6 +++--- savevm.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/monitor.c b/monitor.c index d186532..cba75a2 100644 --- a/monitor.c +++ b/monitor.c @@ -2583,9 +2583,9 @@ static mon_cmd_t info_cmds[] = { }, { .name = "snapshots", - .args_type = "", - .params = "", - .help = "show the currently saved VM snapshots", + .args_type = "device:B?", + .params = "[device]", + .help = "show snapshots of whole vm or a single device", .mhandler.cmd = do_info_snapshots, }, { diff --git a/savevm.c b/savevm.c index cabdcb6..cd474e9 100644 --- a/savevm.c +++ b/savevm.c @@ -2354,9 +2354,50 @@ static void do_info_snapshots_vm(Monitor *mon) return; } +static void do_info_snapshots_blk(Monitor *mon, const char *device) +{ + Error *err = NULL; + SnapshotInfoList *list; + BlockDriverState *bs; + + /* find the target bs */ + bs = bdrv_find(device); + if (!bs) { + monitor_printf(mon, "Device '%s' not found.\n", device); + return ; + } + + if (!bdrv_can_snapshot(bs)) { + monitor_printf(mon, "Device '%s' can't have snapshot.\n", device); + return ; + } + + list = bdrv_query_snapshot_infolist(bs, NULL, NULL, &err); + if (error_is_set(&err)) { + hmp_handle_error(mon, &err); + return; + } + + if (list == NULL) { + monitor_printf(mon, "There is no snapshot available.\n"); + return; + } + + monitor_printf(mon, "Device '%s':\n", device); + monitor_dump_snapshotinfolist(mon, list); + qapi_free_SnapshotInfoList(list); + return; +} + void do_info_snapshots(Monitor *mon, const QDict *qdict) { - do_info_snapshots_vm(mon); + const char *device = qdict_get_try_str(qdict, "device"); + if (!device) { + do_info_snapshots_vm(mon); + } else { + do_info_snapshots_blk(mon, device); + } + return; } void vmstate_register_ram(MemoryRegion *mr, DeviceState *dev)