From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuwOp-0005Mk-SK for qemu-devel@nongnu.org; Mon, 14 Jan 2013 21:37:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuwOo-0004yX-6w for qemu-devel@nongnu.org; Mon, 14 Jan 2013 21:37:15 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:35772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuwOn-0004y7-Jb for qemu-devel@nongnu.org; Mon, 14 Jan 2013 21:37:14 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 15 Jan 2013 08:05:45 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id B383B394004C for ; Tue, 15 Jan 2013 08:07:03 +0530 (IST) Received: from d28av01.in.ibm.com (d28av01.in.ibm.com [9.184.220.63]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r0F2b1Tt20906230 for ; Tue, 15 Jan 2013 08:07:01 +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 r0F2b262006194 for ; Tue, 15 Jan 2013 02:37:02 GMT Message-ID: <50F4C0A6.4070404@linux.vnet.ibm.com> Date: Tue, 15 Jan 2013 10:36:22 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1358147387-8221-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1358147387-8221-12-git-send-email-xiawenc@linux.vnet.ibm.com> <1358162137.22120.4.camel@localhost> In-Reply-To: <1358162137.22120.4.camel@localhost> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH V3 11/11] hmp: show snapshot on single block device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Hrdina Cc: aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, armbru@redhat.com > On Mon, 2013-01-14 at 15:09 +0800, Wenchao Xia wrote: >> 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. > >> 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; >> } >> > > I think that you should move these functions into hmp.c file. This also > applies to previous patch and according to this changes you don't have > to export hmp_handle_error() function which should be used only in hmp.c > > Pavel > It seems there are other "do_info_**" function in other .c files, so I suggest a different serial later which move those functions, if necessary. -- Best Regards Wenchao Xia