From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfXUq-00071a-TT for qemu-devel@nongnu.org; Thu, 23 May 2013 11:32:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UfXUk-00033j-S3 for qemu-devel@nongnu.org; Thu, 23 May 2013 11:32:04 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47650) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UfXUk-00033N-K7 for qemu-devel@nongnu.org; Thu, 23 May 2013 11:31:58 -0400 Message-ID: <519E3634.30107@redhat.com> Date: Thu, 23 May 2013 09:31:00 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369298836-17416-1-git-send-email-xiawenc@linux.vnet.ibm.com> <1369298836-17416-6-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1369298836-17416-6-git-send-email-xiawenc@linux.vnet.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2WBOBDODOBHPTQPMTADXU" Subject: Re: [Qemu-devel] [PATCH V2 5/5] block: dump to specified output for bdrv_snapshot_dump() and bdrv_image_info_dump() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wenchao Xia Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, lcapitulino@redhat.com, pbonzini@redhat.com, armbru@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2WBOBDODOBHPTQPMTADXU Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/23/2013 02:47 AM, Wenchao Xia wrote: > Buffer is not used now so the string would not be truncated any more. T= hey can be used > by both qemu and qemu-img with correct parameter specified. >=20 > Signed-off-by: Wenchao Xia > --- > block/qapi.c | 65 +++++++++++++++++++++++++++---------------= -------- > include/block/qapi.h | 5 ++- > qemu-img.c | 15 +++++++---- > savevm.c | 11 ++++++-- > 4 files changed, 55 insertions(+), 41 deletions(-) >=20 > @@ -282,17 +282,17 @@ char *bdrv_snapshot_dump(char *buf, int buf_size,= QEMUSnapshotInfo *sn) > (int)((secs / 60) % 60), > (int)(secs % 60), > (int)((sn->vm_clock_nsec / 1000000) % 1000)); > - snprintf(buf, buf_size, > - "%-10s%-20s%7s%20s%15s", > - sn->id_str, sn->name, > - get_human_readable_size(buf1, sizeof(buf1), sn->vm_st= ate_size), > - date_buf, > - clock_buf); > + message_printf(output, You got rid of ONE buffer... > + "%-10s%-20s%7s%20s%15s", > + sn->id_str, sn->name, > + get_human_readable_size(buf1, sizeof(buf1), =2E..but what is this other buffer still doing? get_human_readable_size needs to be converted to use QemuOutput. > +void bdrv_image_info_dump(const QemuOutput *output, ImageInfo *info) > { > char size_buf[128], dsize_buf[128]; Why do we still need size_buf and dsize_buf? > if (!info->has_actual_size) { > @@ -302,43 +302,47 @@ void bdrv_image_info_dump(ImageInfo *info) > info->actual_size); > } > get_human_readable_size(size_buf, sizeof(size_buf), info->virtual_= size); Again, get_human_readable_size should be converted to use QemuOutput. > +++ b/qemu-img.c > @@ -1554,16 +1554,18 @@ static void dump_snapshots(BlockDriverState *bs= ) > { > QEMUSnapshotInfo *sn_tab, *sn; > int nb_sns, i; > - char buf[256]; > + QemuOutput output =3D {OUTPUT_STREAM, {stdout,} }; This is relying on C99's rule that a union is initialized by its first named member. But I think it might be more readable as: output =3D { .kind =3D OUTPUT_STREAM, .stream =3D stdout }; not to mention that you will HAVE to use a designator to ever initialize the monitor element of the union in any parallel code that favors the monitor. Hmm, does C99 even allow anonymous unions, or is that a gcc extension? Overall, I like the direction this is headed. The conversion looks reasonable, although it didn't quite go far enough for getting rid of buffers. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2WBOBDODOBHPTQPMTADXU Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRnjY0AAoJEKeha0olJ0Nq2t4H/3ACEJfDnQoQXvdDPR4x0A8N xHPOjiCJ6709Y6ZFp551CFUsacZYKFSHx0PCEmSsaYE13Z+PNOyTH9AOPbOQyn7n fHDtcrD9OzecunkZoVh4mNryu3vvNqUEWHzwoWwprUpThgrJev+fwabrpVx2+Zvc rqTQl12dXp50lMhMHv1X0NVBlOecVQyqC55rD8P6S2igyHM7ETATFoOnWzlnAI7s evu5Ko2++QvfeiyMjLabNaSOi1jtFllNw3272FErmZG8OwcTd1b6yVoTB4XpunMz nfxTjpp0/YOihmEg3ixgm8Sw5jqzmreMz8WdyHv8I4zdMe7ZQM+MvrwImIp044s= =kRDy -----END PGP SIGNATURE----- ------enig2WBOBDODOBHPTQPMTADXU--