[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 3/6] block/qapi: Human-readable ImageInfoSpec
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v5 3/6] block/qapi: Human-readable ImageInfoSpecific dump |
Date: |
Mon, 30 Sep 2013 10:18:23 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9 |
On 09/23/2013 06:09 AM, Max Reitz wrote:
> Add a function for generically dumping the ImageInfoSpecific information
> in a human-readable format to block/qapi.c.
>
> Use this function in bdrv_image_info_dump and qemu-io-cmds.c:info_f to
> allow qemu-img info resp. qemu-io -c info to print that format specific
> information.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> block/qapi.c | 121
> +++++++++++++++++++++++++++++++++++++++++++++++++++
> include/block/qapi.h | 2 +
> qemu-io-cmds.c | 9 ++++
> 3 files changed, 132 insertions(+)
>
> +
> +static void dump_qdict(fprintf_function func_fprintf, void *f, int
> indentation,
> + QDict *dict)
> +{
> + const QDictEntry *entry;
> +
> + for (entry = qdict_first(dict); entry; entry = qdict_next(dict, entry)) {
> + qtype_code type = qobject_type(entry->value);
> + bool composite = (type == QTYPE_QDICT || type == QTYPE_QLIST);
> + const char *format = composite ? "%*s%s:\n" : "%*s%s: ";
> + char key[strlen(entry->key) + 1];
> + int i;
> +
> + /* replace dashes with spaces in key (variable) names */
> + for (i = 0; entry->key[i]; i++) {
> + key[i] = entry->key[i] == '-' ? ' ' : entry->key[i];
I wonder if this should replace underscores, too. For now, this
function is only being used on types that happen to use - in key names,
but it seems generic enough that we may want to use it on older types
that followed older conventions. But I won't force a respin for just
that (if someone DOES reuse this function in the future, they can tweak
underscores at that time, if you don't do it now).
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v5 0/6] Provide additional info through qemu-img info, Max Reitz, 2013/09/23
- [Qemu-devel] [PATCH v5 2/6] block: Add bdrv_get_specific_info, Max Reitz, 2013/09/23
- [Qemu-devel] [PATCH v5 4/6] qcow2: Add support for ImageInfoSpecific, Max Reitz, 2013/09/23
- [Qemu-devel] [PATCH v5 3/6] block/qapi: Human-readable ImageInfoSpecific dump, Max Reitz, 2013/09/23
- Re: [Qemu-devel] [PATCH v5 3/6] block/qapi: Human-readable ImageInfoSpecific dump,
Eric Blake <=
- [Qemu-devel] [PATCH v5 5/6] qemu-iotests: Discard specific info in _img_info, Max Reitz, 2013/09/23
- [Qemu-devel] [PATCH v5 6/6] qemu-iotests: Additional info from qemu-img info, Max Reitz, 2013/09/23
- [Qemu-devel] [PATCH v5 1/6] qapi: Add ImageInfoSpecific type, Max Reitz, 2013/09/23