add description field in ObjectProperty and PropertyInfo struct
v3 cover add description field in ObjectProperty and PropertyInfo struct
From: Gonglei <[email protected]>
ATCH 1 and PATCH 2 are bugfixes. PATCH 3~7 add a description field in both ObjectProperty and PropertyInfo struct. The descriptions can serve as documentation in the code, and they can be used to provide better help. For example:
Before this patch series:
$./qemu-system-x86_64 -device virtio-blk-pci,?
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:
$./qemu-system-x86_64 -device virtio-blk-pci,?
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
v3 -> v2:
1. add a new "description" field to DevicePropertyInfo, and format it in qdev_device_help() in PATCH 6 (Paolo)
v2 -> v1:
1. rename "fail" label to "out" in PATCH 1 (Andreas)
2. improve descriptions in PATCH 3 (Paolo, adding Signed-off-by Paolo in this patch)
3. rework PATCH 5, set description at qdev_property_add_static(),
then copy the description of target_obj.property. (Paolo)
4. free description filed of ObjectProperty avoid memory leak in PATCH 4.
Thanks for review!
Gonglei (7):
qom: add error handler for object_property_print()
qom: add error handler for object alias property
qdev: add description field in PropertyInfo struct
qom: add description field in ObjectProperty struct
qdev: set the object property's description to the qdev property's.
qmp: print descriptions of object properties
qdev: drop legacy_name from qdev properties
hw/core/qdev-properties-system.c | 8 ++++---- hw/core/qdev-properties.c | 14 ++++++++------ hw/core/qdev.c | 5 +++++ include/hw/qdev-core.h | 2 +- include/qom/object.h | 15 +++++++++++++++ qapi-schema.json | 3 ++- qdev-monitor.c | 7 ++++++- qmp.c | 12 +++++++++--- qom/object.c | 39 ++++++++++++++++++++++++++++++++++++--- target-ppc/translate_init.c | 2 +- 10 files changed, 87 insertions(+), 20 deletions(-)
Signature · 1 line
1.7.12.4
PATCH v3 1/7 qom: add error handler for object_property_print()
From: Gonglei <[email protected]>
Avoid the caller of object_property_print() leaking string argument's memory, such as qdev_print_props() when encounter errors.
--- qom/object.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
qom/object.c +10 -2
@@ -1010,11 +1010,19 @@ char *object_property_print(Object *obj, const char *name, bool human, Error **errp) {StringOutputVisitor *mo; -char *string; +char *string =NULL ; +Error *local_err =NULL ; mo =string_output_visitor_new (human); -object_property_get (obj,string_output_get_visitor (mo), name, errp); +object_property_get (obj,string_output_get_visitor (mo), name, &local_err); +if (local_err) { +error_propagate (errp, local_err); + goto out; + } + string =string_output_get_string (mo); + +out:string_output_visitor_cleanup (mo);return string; }
Signature · 1 line
1.7.12.4
PATCH v3 2/7 qom: add error handler for object alias property
In reply to [email protected]From: Gonglei <[email protected]>
object_property_add_alias() is called at some
places at present. And its parameter errp may not NULL,
such as
object_property_add_alias(obj, "iothread", OBJECT(&dev->vdev),"iothread",
&error_abort);
This patch add error handler for security.
--- qom/object.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
qom/object.c +8 -1
@@ -1642,6 +1642,7 @@ void object_property_add_alias(Object *obj, const char *name,ObjectProperty *op;ObjectProperty *target_prop;gchar *prop_type; +Error *local_err =NULL ; target_prop =object_property_find (target_obj, target_name, errp);if (!target_prop) {
@@ -1663,9 +1664,15 @@ void object_property_add_alias(Object *obj, const char *name, property_get_alias, property_set_alias, property_release_alias, - prop, errp); + prop, &local_err); +if (local_err) { +error_propagate (errp, local_err); +g_free (prop); + goto out; + } op->resolve = property_resolve_alias; +out:g_free (prop_type); }
Signature · 1 line
1.7.12.4
PATCH v3 3/7 qdev: add description field in PropertyInfo struct
In reply to [email protected]From: Gonglei <[email protected]>
The descriptions can serve as documentation in the code, and they can be used to provide better help.
--- hw/core/qdev-properties-system.c | 4 ++++ hw/core/qdev-properties.c | 8 ++++++++ include/hw/qdev-core.h | 1 + target-ppc/translate_init.c | 1 + 4 files changed, 14 insertions(+)
hw/core/qdev-properties-system.c +4 -0
@@ -113,6 +113,7 @@ static void set_drive(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_drive = { .name ="str" , .legacy_name ="drive" , + .description ="ID of a drive to use as a backend" , .get = get_drive, .set = set_drive, .release = release_drive,
@@ -170,6 +171,7 @@ static void set_chr(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_chr = { .name ="str" , .legacy_name ="chr" , + .description ="ID of a chardev to use as a backend" , .get = get_chr, .set = set_chr, .release = release_chr,
@@ -249,6 +251,7 @@ static void set_netdev(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_netdev = { .name ="str" , .legacy_name ="netdev" , + .description ="ID of a netdev to use as a backend" , .get = get_netdev, .set = set_netdev, };
@@ -329,6 +332,7 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_vlan = { .name ="int32" , .legacy_name ="vlan" , + .description ="Integer VLAN id to connect to" , .print = print_vlan, .get = get_vlan, .set = set_vlan,
hw/core/qdev-properties.c +8 -0
@@ -121,6 +121,7 @@ static void prop_set_bit(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_bit = { .name ="bool" , .legacy_name ="on/off" , + .description ="on/off" , .get = prop_get_bit, .set = prop_set_bit, };
@@ -456,6 +457,7 @@ inval:PropertyInfo qdev_prop_macaddr = { .name ="str" , .legacy_name ="macaddr" , + .description ="Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56" , .get = get_mac, .set = set_mac, };
@@ -478,6 +480,8 @@ QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));PropertyInfo qdev_prop_bios_chs_trans = { .name ="BiosAtaTranslation" , .legacy_name ="bios-chs-trans" , + .description ="Logical CHS translation algorithm, " +"auto/none/lba/large/rechs" , .enum_table = BiosAtaTranslation_lookup, .get = get_enum, .set = set_enum,
@@ -552,6 +556,7 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,PropertyInfo qdev_prop_pci_devfn = { .name ="int32" , .legacy_name ="pci-devfn" , + .description ="Slot and function number, example: 06.0" , .print = print_pci_devfn, .get = get_int32, .set = set_pci_devfn,
@@ -599,6 +604,7 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_blocksize = { .name ="uint16" , .legacy_name ="blocksize" , + .description ="A power of two between 512 and 32768" , .get = get_uint16, .set = set_blocksize, };
@@ -707,6 +713,8 @@ inval:PropertyInfo qdev_prop_pci_host_devaddr = { .name ="str" , .legacy_name ="pci-host-devaddr" , + .description ="Address (bus/device/function) of " +"the host device, example: 04:10.0" , .get = get_pci_host_devaddr, .set = set_pci_host_devaddr, };
include/hw/qdev-core.h +1 -0
@@ -233,6 +233,7 @@ struct Property {struct PropertyInfo {const char *name;const char *legacy_name; +const char *description;const char **enum_table;int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len);ObjectPropertyAccessor *get;
target-ppc/translate_init.c +1 -0
@@ -8045,6 +8045,7 @@ static void powerpc_set_compat(Object *obj, Visitor *v,static PropertyInfo powerpc_compat_propinfo = { .name ="str" , .legacy_name ="powerpc-server-compat" , + .description ="compatibility mode, power6/power7/power8" , .get = powerpc_get_compat, .set = powerpc_set_compat, };
Signature · 1 line
1.7.12.4
PATCH v3 4/7 qom: add description field in ObjectProperty struct
In reply to [email protected]From: Gonglei <[email protected]>
The descriptions can serve as documentation in the code, and they can be used to provide better help.
--- include/qom/object.h | 15 +++++++++++++++ qom/object.c | 14 ++++++++++++++ 2 files changed, 29 insertions(+)
include/qom/object.h +15 -0
@@ -338,6 +338,7 @@ typedef struct ObjectProperty {gchar *name;gchar *type; +gchar *description;ObjectPropertyAccessor *get;ObjectPropertyAccessor *set;ObjectPropertyResolve *resolve;
@@ -1274,6 +1275,20 @@ void object_property_add_alias(Object *obj, const char *name, Object *target_obj, const char *target_name, Error **errp); + +/** +* object_property_set_description: +* @obj: the object to set a property's description to +* @name: the name of the property +* @description: the description of the property on the object +* @errp: if an error occurs, a pointer to an area to store the error +* +* Set an object property's description. +* +*/ +void object_property_set_description (Object *obj,const char *name, +const char *description,Error **errp); +/** * object_child_foreach: * @obj: the object whose children will be navigated
qom/object.c +14 -0
@@ -369,6 +369,7 @@ static void object_property_del_all(Object *obj)g_free (prop->name);g_free (prop->type); +g_free (prop->description);g_free (prop); } }
@@ -803,6 +804,7 @@ void object_property_del(Object *obj, const char *name, Error **errp)g_free (prop->name);g_free (prop->type); +g_free (prop->description);g_free (prop); }
@@ -1676,6 +1678,18 @@ out:g_free (prop_type); } +void object_property_set_description (Object *obj,const char *name, +const char *description,Error **errp) +{ +ObjectProperty *op; + + op =object_property_find (obj, name, errp); +if (!op) { +return ; + } + op->description = description ?g_strdup (description) :NULL ; +} +static void object_instance_init (Object *obj) {object_property_add_str (obj,"type" , qdev_get_type,NULL ,NULL );
Signature · 1 line
1.7.12.4
Re: [Qemu-devel] [PATCH v3 4/7] qom: add description field in ObjectProperty struct
Il 27/09/2014 07:13, [email protected] ha scritto:
qom/object.c out: · line 1689
Quoted 9 lines
qom/object.c +9
-0+void object_property_set_description (Object *obj,const char *name, +const char *description,Error **errp) +{ +ObjectProperty *op; + + op =object_property_find (obj, name, errp); +if (!op) { +return ; + }
The old description is leaked here if it is not NULL.
Since you are doing v4, please move the object_property_add_alias change here, too.
Paolo
Quoted 3 lines
qom/object.c +3
-0+ op->description = description ?g_strdup (description) :NULL ; +} +
Re: [Qemu-devel] [PATCH v3 4/7] qom: add description field in ObjectProperty struct
Hi,
Quoted 6 lines
Subject: Re: [PATCH v3 4/7] qom: add description field in ObjectProperty struct
Il 27/09/2014 07:13, [email protected] ha scritto:
Review
Quoted 2 lines
(quoted diff) +2
-0+void object_property_set_description(Object *obj, const char *name, + const char *description, Error**errp)
Quoted 10 lines
qom/object.c out: · line 1689
Quoted 7 lines
qom/object.c +7
-0+{ +ObjectProperty *op; + + op =object_property_find (obj, name, errp); +if (!op) { +return ; + }The old description is leaked here if it is not NULL.
Good catch.
Quoted 3 lines
Since you are doing v4, please move the
object_property_add_aliaschange here, too.
OK. Thanks !
Best regards,
-Gonglei
Quoted 5 lines
Paolo
Quoted 3 lines
qom/object.c +3
-0+ op->description = description ?g_strdup (description) :NULL ; +} +
PATCH v3 5/7 qdev: set the object property's description to the qdev property's.
In reply to [email protected]From: Gonglei <[email protected]>
Set all static qdev properties' descriptions to object property's description.
When we call object_property_add_alias() adding alias properties to the source object on the target Object, set the object property's description to the source qdev property's.
--- hw/core/qdev.c | 5 +++++ qom/object.c | 4 ++++ 2 files changed, 9 insertions(+)
hw/core/qdev.c +5 -0
@@ -766,6 +766,11 @@ void qdev_property_add_static(DeviceState *dev, Property *prop,error_propagate (errp, local_err);return ; } + +object_property_set_description (obj, prop->name, + prop->info->description, + &error_abort); +if (prop->qtype ==QTYPE_NONE ) {return ; }
qom/object.c +4 -0
@@ -1674,6 +1674,10 @@ void object_property_add_alias(Object *obj, const char *name, } op->resolve = property_resolve_alias; +object_property_set_description (obj, name, + target_prop->description, + &error_abort); + out:g_free (prop_type); }
Signature · 1 line
1.7.12.4
PATCH v3 6/7 qmp: print descriptions of object properties
In reply to [email protected]From: Gonglei <[email protected]>
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 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
--- qapi-schema.json | 3 ++- qdev-monitor.c | 7 ++++++- qmp.c | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-)
qapi-schema.json +2 -1
@@ -1615,11 +1615,12 @@ # # @name: the name of the property # @type: the typename of the property +# @description: the description of the property # # Since: 1.2 ## { 'type': 'DevicePropertyInfo', - 'data': { 'name': 'str', 'type': 'str' } } + 'data': { 'name': 'str', 'type': 'str', 'description': 'str' } } ## # @device-list-properties:
qdev-monitor.c +6 -1
@@ -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->description) { +error_printf (" (%s)\n" , prop->value->description); + }else { +error_printf ("\n" ); + } }qapi_free_DevicePropertyInfoList (prop_list);
qmp.c +9 -3
@@ -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->description = prop->info->description ? +g_strdup (prop->info->description) :NULL ;return info; } klass =object_class_get_parent (klass);
@@ -475,6 +478,8 @@ 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->description = description ?g_strdup (description) :NULL ; +return info; }
@@ -521,7 +526,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 ; }
Signature · 1 line
1.7.12.4
Re: [Qemu-devel] [PATCH v3 6/7] qmp: print descriptions of object properties
Quoted 11 lines · On 09/26/2014 11:14 PM, [email protected] wrote:
From: Gonglei <[email protected]>
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,?
+++
b/qapi-schema.json
qapi-schema.json line 1618
Quoted 4 lines
qapi-schema.json +1
-0@@ -1615,11 +1615,12 @@ # # @name: the name of the property # @type: the typename of the property +# @description: the description of the property
Please add a '(since 2.2)' designation. Will 'description' always be present (that is, do ALL properties have a description), or is it optional and only provided when a non-NULL description is available?
[/me reads rest of patch]
Yes, given your code, it looks like you meant for it to be optional.
qapi-schema.json line 1623
Quoted 6 lines
qapi-schema.json +1
-1# # Since: 1.2 ## { 'type': 'DevicePropertyInfo', - 'data': { 'name': 'str', 'type': 'str' } } + 'data': { 'name': 'str', 'type': 'str', 'description': 'str' } }
Therefore, this needs to be '*description'...
Quoted 8 lines
qapi-schema.json +0
-0## # @device-list-properties:qdev-monitor.c +0
-0
qdev-monitor.c int qdev_device_help(QemuOpts *opts) · line 219
Quoted 8 lines
qdev-monitor.c +2
-1@@ -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->description) {
...and this needs to be 'prop->value->has_description'. We don't support NULL values of non-optional strings in QMP yet.
qdev-monitor.c static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, · line 471
Quoted 8 lines
qdev-monitor.c +3
-1@@ -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->description = prop->info->description ? +g_strdup (prop->info->description) :NULL ;
This needs to be:
info->has_description = !!prop->info->description; info->description = g_strdup(prop->info->description);
(it's safe to call g_strdup(NULL), avoiding the need for ?: in the assignment).
qdev-monitor.c static DevicePropertyInfo *make_device_property_info(ObjectClass *klass, · line 481
Quoted 8 lines
qdev-monitor.c +1
-0return info; } klass =object_class_get_parent (klass);@@ -475,6 +478,8 @@ 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->description = description ?g_strdup (description) :NULL ;
Another place that should avoid the ?:, and set has_description.
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH v3 6/7] qmp: print descriptions of object properties
Quoted 11 lines · On 09/26/2014 11:14 PM, [email protected] wrote:
Quoted 8 lines
From: Gonglei <[email protected]>
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,?
Quoted 8 lines
qapi-schema.json line 1618
Quoted 6 lines
+++
b/qapi-schema.jsonqapi-schema.json +1
-0@@ -1615,11 +1615,12 @@ # # @name: the name of the property # @type: the typename of the property +# @description: the description of the propertyPlease add a '(since 2.2)' designation.
OK.
Quoted 8 lines
Will 'description' always be
present (that is, do ALL properties have a description), or is it optional and only provided when a non-NULL description is available?[/me reads rest of patch]
Yes, given your code, it looks like you meant for it to be optional.
Yes.
Quoted 9 lines
qapi-schema.json line 1623
Quoted 6 lines
qapi-schema.json +1
-1# # Since: 1.2 ## { 'type': 'DevicePropertyInfo', - 'data': { 'name': 'str', 'type': 'str' } } + 'data': { 'name': 'str', 'type': 'str', 'description': 'str' } }Therefore, this needs to be '*description'...
OK.
Quoted 10 lines
Quoted 10 lines
qapi-schema.json +0
-0## # @device-list-properties:qdev-monitor.c +0
-0@@ -213,9 +213,14 @@ int qdev_device_help(QemuOpts *opts) }
Quoted 10 lines
qdev-monitor.c int qdev_device_help(QemuOpts *opts) · line 219
Quoted 6 lines
qdev-monitor.c +2
-1for (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->description) {...and this needs to be '
prop->value->has_description'. We don't support NULL values of non-optional strings in QMP yet.
OK.
Quoted 12 lines
qdev-monitor.c static DevicePropertyInfo
Quoted 1 line
qdev-monitor.c +0
-0@@ -465,7 +466,9 @@ static DevicePropertyInfo*make_device_property_info(ObjectClass *klass,
qdev-monitor.c static DevicePropertyInfo · line 467
Quoted 4 lines
qdev-monitor.c +0
-1info =g_malloc0 (sizeof (*info)); info->name =g_strdup (prop->name); - info->type = g_strdup(prop->info->legacy_name ?:
prop->info->name);qdev-monitor.c static DevicePropertyInfo · line 470
Quoted 3 lines
qdev-monitor.c +3
-0+ info->type =g_strdup (prop->info->name); + info->description = prop->info->description ? + g_strdup(prop->info->description) :NULL;
Quoted 8 lines
This needs to be:
info->has_description= !!prop->info->description;info->description=g_strdup(prop->info->description);(it's safe to call
g_strdup(NULL), avoiding the need for ?: in the assignment).
OK.
Quoted 5 lines
qdev-monitor.c static DevicePropertyInfo
Quoted 4 lines
qdev-monitor.c +0
-0return info; } klass =object_class_get_parent (klass);@@ -475,6 +478,8 @@ static DevicePropertyInfo*make_device_property_info(ObjectClass *klass,
Quoted 7 lines
qdev-monitor.c static DevicePropertyInfo · line 481
Quoted 4 lines
qdev-monitor.c +1
-0info =g_malloc0 (sizeof (*info)); info->name =g_strdup (name); info->type =g_strdup (default_type); + info->description = description ?g_strdup (description) :NULL ;Another place that should avoid the ?:, and set
has_description.
OK. Thanks a lot, Eric!
Will fix them in v4.
Best regards,
-Gonglei
Quoted 3 lines
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
PATCH v3 7/7 qdev: drop legacy_name from qdev properties
In reply to [email protected]From: Gonglei <[email protected]>
The legacy_name is useless now, the better help information provied by description field of property.
--- hw/core/qdev-properties-system.c | 4 ---- hw/core/qdev-properties.c | 6 ------ include/hw/qdev-core.h | 1 - target-ppc/translate_init.c | 1 - 4 files changed, 12 deletions(-)
hw/core/qdev-properties-system.c +0 -4
@@ -112,7 +112,6 @@ static void set_drive(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_drive = { .name ="str" , - .legacy_name ="drive" , .description ="ID of a drive to use as a backend" , .get = get_drive, .set = set_drive,
@@ -170,7 +169,6 @@ static void set_chr(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_chr = { .name ="str" , - .legacy_name ="chr" , .description ="ID of a chardev to use as a backend" , .get = get_chr, .set = set_chr,
@@ -250,7 +248,6 @@ static void set_netdev(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_netdev = { .name ="str" , - .legacy_name ="netdev" , .description ="ID of a netdev to use as a backend" , .get = get_netdev, .set = set_netdev,
@@ -331,7 +328,6 @@ static void set_vlan(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_vlan = { .name ="int32" , - .legacy_name ="vlan" , .description ="Integer VLAN id to connect to" , .print = print_vlan, .get = get_vlan,
hw/core/qdev-properties.c +0 -6
@@ -120,7 +120,6 @@ static void prop_set_bit(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_bit = { .name ="bool" , - .legacy_name ="on/off" , .description ="on/off" , .get = prop_get_bit, .set = prop_set_bit,
@@ -456,7 +455,6 @@ inval:PropertyInfo qdev_prop_macaddr = { .name ="str" , - .legacy_name ="macaddr" , .description ="Ethernet 6-byte MAC Address, example: 52:54:00:12:34:56" , .get = get_mac, .set = set_mac,
@@ -479,7 +477,6 @@ QEMU_BUILD_BUG_ON(sizeof(BiosAtaTranslation) != sizeof(int));PropertyInfo qdev_prop_bios_chs_trans = { .name ="BiosAtaTranslation" , - .legacy_name ="bios-chs-trans" , .description ="Logical CHS translation algorithm, " "auto/none/lba/large/rechs" , .enum_table = BiosAtaTranslation_lookup,
@@ -555,7 +552,6 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,PropertyInfo qdev_prop_pci_devfn = { .name ="int32" , - .legacy_name ="pci-devfn" , .description ="Slot and function number, example: 06.0" , .print = print_pci_devfn, .get = get_int32,
@@ -603,7 +599,6 @@ static void set_blocksize(Object *obj, Visitor *v, void *opaque,PropertyInfo qdev_prop_blocksize = { .name ="uint16" , - .legacy_name ="blocksize" , .description ="A power of two between 512 and 32768" , .get = get_uint16, .set = set_blocksize,
@@ -712,7 +707,6 @@ inval:PropertyInfo qdev_prop_pci_host_devaddr = { .name ="str" , - .legacy_name ="pci-host-devaddr" , .description ="Address (bus/device/function) of " "the host device, example: 04:10.0" , .get = get_pci_host_devaddr,
include/hw/qdev-core.h +0 -1
@@ -232,7 +232,6 @@ struct Property {struct PropertyInfo {const char *name; -const char *legacy_name;const char *description;const char **enum_table;int (*print)(DeviceState *dev,Property *prop,char *dest,size_t len);
target-ppc/translate_init.c +0 -1
@@ -8044,7 +8044,6 @@ static void powerpc_set_compat(Object *obj, Visitor *v,static PropertyInfo powerpc_compat_propinfo = { .name ="str" , - .legacy_name ="powerpc-server-compat" , .description ="compatibility mode, power6/power7/power8" , .get = powerpc_get_compat, .set = powerpc_set_compat,
Signature · 1 line
1.7.12.4
Andreas Färber
AppliedHi,
Am 27.09.2014 um 07:13 schrieb [email protected]:
Quoted 3 lines
Gonglei (7):
qom: add error handler forobject_property_print()
qom: add error handler for object alias property
I've applied these two to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-next
As I understand there will be a v4, feel free to rebase on it.
Regards,
Andreas
Quoted 5 lines
qdev: add description field in PropertyInfo struct
qom: add description field in ObjectProperty struct
qdev: set the object property's description to the qdev property's.
qmp: print descriptions of object properties
qdev: droplegacy_namefrom qdev properties
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 6 lines
Subject: Re: [Qemu-devel] [PATCH v3 0/7] add description field in ObjectProperty and PropertyInfo struct
Hi,
Am 27.09.2014 um 07:13 schrieb [email protected]:
Quoted 9 lines
Quoted 3 lines
Gonglei (7):
qom: add error handler forobject_property_print()
qom: add error handler for object alias propertyI've applied these two to qom-next:
https://github.com/afaerber/qemu-cpu/commits/qom-nextAs I understand there will be a v4, feel free to rebase on it.
OK, thanks!
Best regards,
-Gonglei
Quoted 12 lines
Regards,
AndreasQuoted 5 lines
qdev: add description field in PropertyInfo struct
qom: add description field in ObjectProperty struct
qdev: set the object property's description to the qdev property's.
qmp: print descriptions of object properties
qdev: droplegacy_namefrom qdev properties--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg