From: Paolo Bonzini <pbonzini@redhat.com>
To: arei.gonglei@huawei.com, qemu-devel@nongnu.org
Cc: weidong.huang@huawei.com, stefanha@redhat.com, mst@redhat.com,
luonengjun@huawei.com, peter.huangpeng@huawei.com,
armbru@redhat.com, aliguori@amazon.com, lcapitulino@redhat.com,
afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v2 6/7] qmp: print descriptions of object properties
Date: Fri, 26 Sep 2014 13:38:48 +0200 [thread overview]
Message-ID: <54255048.3030804@redhat.com> (raw)
In-Reply-To: <1411610662-9720-7-git-send-email-arei.gonglei@huawei.com>
Il 25/09/2014 04:04, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
>
> The descriptions can serve as documentation in the code,
> and they can be used to provide better help. For example:
>
> $./qemu-system-x86_64 -device virtio-blk-pci,?
>
> Before this patch:
>
> virtio-blk-pci.iothread=link<iothread>
> virtio-blk-pci.x-data-plane=bool
> virtio-blk-pci.scsi=bool
> virtio-blk-pci.config-wce=bool
> virtio-blk-pci.serial=str
> virtio-blk-pci.secs=uint32
> virtio-blk-pci.heads=uint32
> virtio-blk-pci.cyls=uint32
> virtio-blk-pci.discard_granularity=uint32
> virtio-blk-pci.bootindex=int32
> virtio-blk-pci.opt_io_size=uint32
> virtio-blk-pci.min_io_size=uint16
> virtio-blk-pci.physical_block_size=uint16
> virtio-blk-pci.logical_block_size=uint16
> virtio-blk-pci.drive=str
> virtio-blk-pci.virtio-backend=child<virtio-blk-device>
> virtio-blk-pci.command_serr_enable=on/off
> virtio-blk-pci.multifunction=on/off
> virtio-blk-pci.rombar=uint32
> virtio-blk-pci.romfile=str
> virtio-blk-pci.addr=pci-devfn
> virtio-blk-pci.event_idx=on/off
> virtio-blk-pci.indirect_desc=on/off
> virtio-blk-pci.vectors=uint32
> virtio-blk-pci.ioeventfd=on/off
> virtio-blk-pci.class=uint32
>
> After:
>
> virtio-blk-pci.iothread=link<iothread>
> virtio-blk-pci.x-data-plane=bool (on/off)
> virtio-blk-pci.scsi=bool (on/off)
> virtio-blk-pci.config-wce=bool (on/off)
> virtio-blk-pci.serial=str
> virtio-blk-pci.secs=uint32
> virtio-blk-pci.heads=uint32
> virtio-blk-pci.cyls=uint32
> virtio-blk-pci.discard_granularity=uint32
> virtio-blk-pci.bootindex=int32
> virtio-blk-pci.opt_io_size=uint32
> virtio-blk-pci.min_io_size=uint16
> virtio-blk-pci.physical_block_size=uint16 (A power of two between 512 and 32768)
> virtio-blk-pci.logical_block_size=uint16 (A power of two between 512 and 32768)
> virtio-blk-pci.drive=str (ID of a drive to use as a backend)
> virtio-blk-pci.virtio-backend=child<virtio-blk-device>
> virtio-blk-pci.command_serr_enable=bool (on/off)
> virtio-blk-pci.multifunction=bool (on/off)
> virtio-blk-pci.rombar=uint32
> virtio-blk-pci.romfile=str
> virtio-blk-pci.addr=int32 (Slot and function number, example: 06.0)
> virtio-blk-pci.event_idx=bool (on/off)
> virtio-blk-pci.indirect_desc=bool (on/off)
> virtio-blk-pci.vectors=uint32
> virtio-blk-pci.ioeventfd=bool (on/off)
> virtio-blk-pci.class=uint32
>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Michael S. Tsirkin <mst@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
> qmp.c | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/qmp.c b/qmp.c
> index c6767c4..20f501b 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -442,7 +442,8 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
> */
> static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
> const char *name,
> - const char *default_type)
> + const char *default_type,
> + const char *description)
> {
> DevicePropertyInfo *info;
> Property *prop;
> @@ -465,7 +466,12 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
>
> info = g_malloc0(sizeof(*info));
> info->name = g_strdup(prop->name);
> - info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> + if (prop->info->description) {
> + info->type = g_strdup_printf("%s (%s)", prop->info->name,
> + prop->info->description);
> + } else {
> + info->type = g_strdup(prop->info->name);
> + }
> return info;
> }
> klass = object_class_get_parent(klass);
> @@ -474,7 +480,11 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
> /* Not a qdev property, use the default type */
> info = g_malloc0(sizeof(*info));
> info->name = g_strdup(name);
> - info->type = g_strdup(default_type);
> + if (description) {
> + info->type = g_strdup_printf("%s (%s)", default_type, description);
Please add a new "description" field to DevicePropertyInfo, and format
it in qdev_device_help.
You can send v3 of just this patch.
Thanks,
Paolo
> + } else {
> + info->type = g_strdup(default_type);
> + }
> return info;
> }
>
> @@ -521,7 +531,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
> continue;
> }
>
> - info = make_device_property_info(klass, prop->name, prop->type);
> + info = make_device_property_info(klass, prop->name, prop->type,
> + prop->description);
> if (!info) {
> continue;
> }
>
next prev parent reply other threads:[~2014-09-26 11:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 2:04 [Qemu-devel] [PATCH v2 0/7] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 1/7] qom: add error handler for object_property_print() arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 2/7] qom: add error handler for object alias property arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 3/7] qdev: add description field in PropertyInfo struct arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 4/7] qom: add description field in ObjectProperty struct arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 5/7] qdev: set the object property's description to the qdev property's arei.gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 6/7] qmp: print descriptions of object properties arei.gonglei
2014-09-26 11:38 ` Paolo Bonzini [this message]
2014-09-26 12:11 ` Gonglei
2014-09-25 2:04 ` [Qemu-devel] [PATCH v2 7/7] qdev: drop legacy_name from qdev properties arei.gonglei
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=54255048.3030804@redhat.com \
--to=pbonzini@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=luonengjun@huawei.com \
--cc=mst@redhat.com \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=weidong.huang@huawei.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.