From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:48560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULv4s-0001s8-S9 for qemu-devel@nongnu.org; Sat, 30 Mar 2013 08:40:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULv4r-0000E7-K4 for qemu-devel@nongnu.org; Sat, 30 Mar 2013 08:40:10 -0400 Received: from e28smtp02.in.ibm.com ([122.248.162.2]:40161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULv4q-0000DN-V3 for qemu-devel@nongnu.org; Sat, 30 Mar 2013 08:40:09 -0400 Received: from /spool/local by e28smtp02.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 30 Mar 2013 18:05:28 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp03.in.ibm.com (Postfix) with ESMTP id CECD2125804E for ; Sat, 30 Mar 2013 18:11:11 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r2UCdpMx14024984 for ; Sat, 30 Mar 2013 18:09:51 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r2UCdsUH007469 for ; Sat, 30 Mar 2013 23:39:54 +1100 Message-ID: <5156DCE2.8070604@linux.vnet.ibm.com> Date: Sat, 30 Mar 2013 20:38:58 +0800 From: Wenchao Xia MIME-Version: 1.0 References: <1363961953-13561-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1363961953-13561-13-git-send-email-xiawenc@linux.vnet.ibm.com> <51561E00.9070002@redhat.com> In-Reply-To: <51561E00.9070002@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH V10 12/17] hmp: add function hmp_info_snapshots() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@gmail.com, qemu-devel@nongnu.org, armbru@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com 于 2013-3-30 7:04, Eric Blake 写道: > On 03/22/2013 08:19 AM, Wenchao Xia wrote: >> This function will simply call qmp interface qmp_query_snapshots() >> added in last commit and then dump information in monitor console. >> To get snapshot info, Now qemu and qemu-img both call block layer >> function bdrv_query_snapshot_info_list() in their calling path, and >> then they just translate the qmp object got to strings in stdout or >> monitor console. >> >> Signed-off-by: Wenchao Xia >> --- >> hmp.c | 42 ++++++++++++++++++++++++++++++++++++++++++ >> hmp.h | 1 + >> 2 files changed, 43 insertions(+), 0 deletions(-) >> >> diff --git a/hmp.c b/hmp.c >> index b0a861c..c475d65 100644 >> --- a/hmp.c >> +++ b/hmp.c >> @@ -651,6 +651,48 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict) >> qapi_free_TPMInfoList(info_list); >> } >> >> +/* assume list is valid */ >> +static void monitor_dump_snapshotinfolist(Monitor *mon, SnapshotInfoList *list) >> +{ >> + SnapshotInfoList *elem; >> + char buf[256]; >> + >> + monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL)); > > Are you sure that won't ever be truncated? I'm pretty sure that I could > come up with a scenario where I cause bdrv_snapshot_dump() to want to > output more than 256 bytes of details. > I hope not use dynamic buff for strings, how about check it as following: char buf[254] = 0; monitor_printf(mon, "%s\n", bdrv_snapshot_dump(buf, sizeof(buf), NULL)); if (buf[254]) { monitor_printf(mon, "'string truncated'"); } -- Best Regards Wenchao Xia