From: Eric Blake <eblake@redhat.com>
To: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Cc: kwolf@redhat.com, phrdina@redhat.com, stefanha@gmail.com,
qemu-devel@nongnu.org, lcapitulino@redhat.com,
pbonzini@redhat.com, armbru@redhat.com
Subject: Re: [Qemu-devel] [PATCH V2 5/5] block: dump to specified output for bdrv_snapshot_dump() and bdrv_image_info_dump()
Date: Thu, 23 May 2013 09:31:00 -0600 [thread overview]
Message-ID: <519E3634.30107@redhat.com> (raw)
In-Reply-To: <1369298836-17416-6-git-send-email-xiawenc@linux.vnet.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2842 bytes --]
On 05/23/2013 02:47 AM, Wenchao Xia wrote:
> Buffer is not used now so the string would not be truncated any more. They can be used
> by both qemu and qemu-img with correct parameter specified.
>
> Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
> ---
> block/qapi.c | 65 +++++++++++++++++++++++++++-----------------------
> include/block/qapi.h | 5 ++-
> qemu-img.c | 15 +++++++----
> savevm.c | 11 ++++++--
> 4 files changed, 55 insertions(+), 41 deletions(-)
>
> @@ -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_state_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),
...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 = {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 = { .kind = OUTPUT_STREAM, .stream = 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.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 621 bytes --]
next prev parent reply other threads:[~2013-05-23 15:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-23 8:47 [Qemu-devel] [PATCH V2 0/5] qapi and snapshot code clean up in block layer Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 1/5] block: drop bs_snapshots global variable Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 2/5] block: move snapshot code in block.c to block/snapshot.c Wenchao Xia
2013-05-24 11:35 ` Stefan Hajnoczi
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 3/5] block: move qmp and info dump related code to block/qapi.c Wenchao Xia
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 4/5] util: add new function message_printf() Wenchao Xia
2013-05-23 15:05 ` Eric Blake
2013-05-24 1:41 ` Wenchao Xia
2013-05-23 17:14 ` Luiz Capitulino
2013-05-24 11:45 ` Stefan Hajnoczi
2013-05-23 8:47 ` [Qemu-devel] [PATCH V2 5/5] block: dump to specified output for bdrv_snapshot_dump() and bdrv_image_info_dump() Wenchao Xia
2013-05-23 15:31 ` Eric Blake [this message]
2013-05-24 1:48 ` Wenchao Xia
2013-05-24 2:31 ` Wenchao Xia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=519E3634.30107@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=pbonzini@redhat.com \
--cc=phrdina@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.com \
--cc=xiawenc@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).