[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 4/5] qmp: print descriptions of object properties
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v5 4/5] qmp: print descriptions of object properties |
Date: |
Tue, 7 Oct 2014 14:33:23 +0800 |
From: Gonglei <address@hidden>
Add a new "description" field to DevicePropertyInfo.
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 optional function number, example: 06.0 or
06)
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 <address@hidden>
Cc: Michael S. Tsirkin <address@hidden>
Cc: Markus Armbruster <address@hidden>
Signed-off-by: Gonglei <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
qapi-schema.json | 4 +++-
qdev-monitor.c | 7 ++++++-
qmp.c | 13 ++++++++++---
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 4bfaf20..d95a820 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1615,11 +1615,13 @@
#
# @name: the name of the property
# @type: the typename of the property
+# @description: #optional if specified, the description of the property.
+# (since 2.2)
#
# Since: 1.2
##
{ 'type': 'DevicePropertyInfo',
- 'data': { 'name': 'str', 'type': 'str' } }
+ 'data': { 'name': 'str', 'type': 'str', '*description': 'str' } }
##
# @device-list-properties:
diff --git a/qdev-monitor.c b/qdev-monitor.c
index 5ec6606..6a0c7c8 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -213,9 +213,14 @@ int qdev_device_help(QemuOpts *opts)
}
for (prop = prop_list; prop; prop = prop->next) {
- error_printf("%s.%s=%s\n", driver,
+ error_printf("%s.%s=%s", driver,
prop->value->name,
prop->value->type);
+ if (prop->value->has_description) {
+ error_printf(" (%s)\n", prop->value->description);
+ } else {
+ error_printf("\n");
+ }
}
qapi_free_DevicePropertyInfoList(prop_list);
diff --git a/qmp.c b/qmp.c
index c6767c4..0b4f131 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,9 @@ 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);
+ info->type = g_strdup(prop->info->name);
+ info->has_description = !!prop->info->description;
+ info->description = g_strdup(prop->info->description);
return info;
}
klass = object_class_get_parent(klass);
@@ -475,6 +478,9 @@ static DevicePropertyInfo
*make_device_property_info(ObjectClass *klass,
info = g_malloc0(sizeof(*info));
info->name = g_strdup(name);
info->type = g_strdup(default_type);
+ info->has_description = !!description;
+ info->description = g_strdup(description);
+
return info;
}
@@ -521,7 +527,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;
}
--
1.7.12.4
- [Qemu-devel] [PATCH v5 0/5] add description field in ObjectProperty and PropertyInfo struct, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v5 3/5] qdev: set the object property's description to the qdev property's., arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v5 4/5] qmp: print descriptions of object properties,
arei.gonglei <=
- [Qemu-devel] [PATCH v5 5/5] qdev: drop legacy_name from qdev properties, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v5 2/5] qom: add description field in ObjectProperty struct, arei.gonglei, 2014/10/07
- [Qemu-devel] [PATCH v5 1/5] qdev: add description field in PropertyInfo struct, arei.gonglei, 2014/10/07
- Re: [Qemu-devel] [PATCH v5 0/5] add description field in ObjectProperty and PropertyInfo struct, Paolo Bonzini, 2014/10/07