From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:35828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnKwA-0001Wu-Ie for qemu-devel@nongnu.org; Mon, 24 Dec 2012 22:12:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TnKw9-00059P-Id for qemu-devel@nongnu.org; Mon, 24 Dec 2012 22:12:14 -0500 Received: from e23smtp05.au.ibm.com ([202.81.31.147]:38306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TnKw8-00059G-Sm for qemu-devel@nongnu.org; Mon, 24 Dec 2012 22:12:13 -0500 Received: from /spool/local by e23smtp05.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 25 Dec 2012 13:09:15 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp02.au.ibm.com (Postfix) with ESMTP id C64D72BB004E for ; Tue, 25 Dec 2012 14:12:04 +1100 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qBP30gmx2556194 for ; Tue, 25 Dec 2012 14:00:44 +1100 Received: from d23av02.au.ibm.com (loopback [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qBP3C2aF027540 for ; Tue, 25 Dec 2012 14:12:02 +1100 Message-ID: <50D91947.5010404@linux.vnet.ibm.com> Date: Tue, 25 Dec 2012 11:11:03 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1355912230-25132-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1355912230-25132-4-git-send-email-xiawenc@linux.vnet.ibm.com> <87mwx733d4.fsf@blackfin.pond.sub.org> In-Reply-To: <87mwx733d4.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 3/3] HMP: show internal snapshots on a single device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com >> >> +static void do_info_snapshots_blk(Monitor *mon, const char *device) >> +{ >> + BlockDriverState *bs; >> + QEMUSnapshotInfo *sn_tab, *sn; >> + int nb_sns, i; >> + char buf[256]; >> + >> + /* 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 ; >> + } > > Rest of the function is is essentially code copied from > do_info_snapshots_vm(). Could it be factored out? > Sure, I forgot that before. I guess a better way is adding a QMP interface first and using common code from it. >> + >> + nb_sns = bdrv_snapshot_list(bs, &sn_tab); >> + if (nb_sns < 0) { >> + monitor_printf(mon, "Device %s bdrv_snapshot_list: error %d\n", >> + device, nb_sns); >> + return; >> + } >> + >> + if (nb_sns == 0) { >> + monitor_printf(mon, "There is no snapshot available.\n"); >> + return; >> + } >> + >> + monitor_printf(mon, "Device %s:\n", device); >> + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL)); >> + for (i = 0; i < nb_sns; i++) { >> + sn = &sn_tab[i]; >> + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), sn)); >> + } >> + g_free(sn_tab); >> + return; >> +} >> + >> +void do_info_snapshots(Monitor *mon, const QDict *qdict) >> +{ >> + /* Todo, there should be a layer rebuild qdict before enter this func. */ > > I'm not sure I get this comment. > > We usually capitalize TODO for easy grepping. > My mistake, this comments should have been removed, it is used before where qdict was not rebuilt as a new one. >> + 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) >> { >> qemu_ram_set_idstr(memory_region_get_ram_addr(mr) & TARGET_PAGE_MASK, > -- Best Regards Wenchao Xia