qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
@ 2014-09-30  3:02 arei.gonglei
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 1/5] qdev: add description field in " arei.gonglei
                   ` (7 more replies)
  0 siblings, 8 replies; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

This patch series based on qom-next tree:
 https://github.com/afaerber/qemu-cpu/commits/qom-next

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

v4 -> v3:
 1. rebase on qom-next tree (Andreas)
 2. fix memory leak in PATCH 2, move object_property_set_description calling
    in object_property_add_alias() from PATCH 3 to PATCH 2. (Paolo)
 3. drop "?:" in PATCH 2, call g_strdup() directly
 4. rework PATCH 4, change description as optional field,
    drop "?:" conditional express (Eric)
 
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!

 Cc: Paolo Bonzini <pbonzini@redhat.com>
 Cc: Michael S. Tsirkin <mst@redhat.com>
 Cc: Markus Armbruster <armbru@redhat.com>


Gonglei (5):
  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                 |  4 +++-
 qdev-monitor.c                   |  7 ++++++-
 qmp.c                            | 13 ++++++++++---
 qom/object.c                     | 20 ++++++++++++++++++++
 target-ppc/translate_init.c      |  2 +-
 10 files changed, 73 insertions(+), 17 deletions(-)

-- 
2.0.4

^ permalink raw reply	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
@ 2014-09-30  3:02 ` arei.gonglei
  2014-09-30 11:42   ` Michael S. Tsirkin
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct arei.gonglei
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

The descriptions can serve as documentation in the code,
and they can be used to provide better help.

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>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 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(+)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 84caa1d..55b6636 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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,
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 66556d3..a853ac9 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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,
 };
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 178fee2..31acbe6 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -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;
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 65b840d..0312e04 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -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,
 };
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 1/5] qdev: add description field in " arei.gonglei
@ 2014-09-30  3:02 ` arei.gonglei
  2014-09-30 11:48   ` Michael S. Tsirkin
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 3/5] qdev: set the object property's description to the qdev property's arei.gonglei
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

The descriptions can serve as documentation in the code,
and they can be used to provide better help.

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 object property's.

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>
---
 include/qom/object.h | 15 +++++++++++++++
 qom/object.c         | 20 ++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/include/qom/object.h b/include/qom/object.h
index 8a05a81..ddc600d 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -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
diff --git a/qom/object.c b/qom/object.c
index 575291f..a751367 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -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);
 }
 
@@ -1672,10 +1674,28 @@ 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);
 }
 
+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;
+    }
+
+    g_free(op->description);
+    op->description = g_strdup(description);
+}
+
 static void object_instance_init(Object *obj)
 {
     object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PATCH v4 3/5] qdev: set the object property's description to the qdev property's.
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 1/5] qdev: add description field in " arei.gonglei
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct arei.gonglei
@ 2014-09-30  3:02 ` arei.gonglei
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties arei.gonglei
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

Set all static qdev properties' descriptions to object property's
description.

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>
---
 hw/core/qdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 2b42d5b..e11510c 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -789,6 +789,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;
     }
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
                   ` (2 preceding siblings ...)
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 3/5] qdev: set the object property's description to the qdev property's arei.gonglei
@ 2014-09-30  3:02 ` arei.gonglei
  2014-09-30 15:38   ` Eric Blake
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties arei.gonglei
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

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

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>
---
 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;
         }
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
                   ` (3 preceding siblings ...)
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties arei.gonglei
@ 2014-09-30  3:02 ` arei.gonglei
  2014-09-30 11:43   ` Michael S. Tsirkin
  2014-09-30  8:54 ` [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct Paolo Bonzini
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 28+ messages in thread
From: arei.gonglei @ 2014-09-30  3:02 UTC (permalink / raw)
  To: qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, Gonglei, stefanha, pbonzini, afaerber

From: Gonglei <arei.gonglei@huawei.com>

The legacy_name is useless now, the better help
information provied by description field of property.

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>
---
 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(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 55b6636..f2bd954 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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,
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a853ac9..5c85db1 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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,
diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 31acbe6..7fcd415 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -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);
diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
index 0312e04..33fb4cc 100644
--- a/target-ppc/translate_init.c
+++ b/target-ppc/translate_init.c
@@ -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,
-- 
2.0.4

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
                   ` (4 preceding siblings ...)
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties arei.gonglei
@ 2014-09-30  8:54 ` Paolo Bonzini
  2014-09-30 11:35 ` Michael S. Tsirkin
  2014-09-30 13:32 ` Michael S. Tsirkin
  7 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2014-09-30  8:54 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, stefanha, afaerber

Il 30/09/2014 05:02, arei.gonglei@huawei.com ha scritto:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> This patch series based on qom-next tree:
>  https://github.com/afaerber/qemu-cpu/commits/qom-next
> 
> 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
> 
> v4 -> v3:
>  1. rebase on qom-next tree (Andreas)
>  2. fix memory leak in PATCH 2, move object_property_set_description calling
>     in object_property_add_alias() from PATCH 3 to PATCH 2. (Paolo)
>  3. drop "?:" in PATCH 2, call g_strdup() directly
>  4. rework PATCH 4, change description as optional field,
>     drop "?:" conditional express (Eric)
>  
> 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!
> 
>  Cc: Paolo Bonzini <pbonzini@redhat.com>
>  Cc: Michael S. Tsirkin <mst@redhat.com>
>  Cc: Markus Armbruster <armbru@redhat.com>
> 
> 
> Gonglei (5):
>   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                 |  4 +++-
>  qdev-monitor.c                   |  7 ++++++-
>  qmp.c                            | 13 ++++++++++---
>  qom/object.c                     | 20 ++++++++++++++++++++
>  target-ppc/translate_init.c      |  2 +-
>  10 files changed, 73 insertions(+), 17 deletions(-)
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks Andreas for handling this.

Paolo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
                   ` (5 preceding siblings ...)
  2014-09-30  8:54 ` [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct Paolo Bonzini
@ 2014-09-30 11:35 ` Michael S. Tsirkin
  2014-09-30 11:53   ` Paolo Bonzini
                     ` (2 more replies)
  2014-09-30 13:32 ` Michael S. Tsirkin
  7 siblings, 3 replies; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 11:35 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, stefanha, pbonzini, lcapitulino, afaerber

On Tue, Sep 30, 2014 at 11:02:34AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> This patch series based on qom-next tree:
>  https://github.com/afaerber/qemu-cpu/commits/qom-next
> 
> 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)

Weird. 06.0 is clearly not an int, is it?

> 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

BTW, any way we can find out and report default values
as well? E.g.
virtio-blk-pci.indirect_desc=bool (on/off) default:on

This idea should not block this patch of course.

> v4 -> v3:
>  1. rebase on qom-next tree (Andreas)
>  2. fix memory leak in PATCH 2, move object_property_set_description calling
>     in object_property_add_alias() from PATCH 3 to PATCH 2. (Paolo)
>  3. drop "?:" in PATCH 2, call g_strdup() directly
>  4. rework PATCH 4, change description as optional field,
>     drop "?:" conditional express (Eric)
>  
> 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!
> 
>  Cc: Paolo Bonzini <pbonzini@redhat.com>
>  Cc: Michael S. Tsirkin <mst@redhat.com>
>  Cc: Markus Armbruster <armbru@redhat.com>
> 
> 
> Gonglei (5):
>   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                 |  4 +++-
>  qdev-monitor.c                   |  7 ++++++-
>  qmp.c                            | 13 ++++++++++---
>  qom/object.c                     | 20 ++++++++++++++++++++
>  target-ppc/translate_init.c      |  2 +-
>  10 files changed, 73 insertions(+), 17 deletions(-)
> 
> -- 
> 2.0.4
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 1/5] qdev: add description field in " arei.gonglei
@ 2014-09-30 11:42   ` Michael S. Tsirkin
  2014-09-30 13:14     ` Gonglei
  0 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 11:42 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, stefanha, pbonzini, lcapitulino, afaerber

On Tue, Sep 30, 2014 at 11:02:35AM +0800, arei.gonglei@huawei.com wrote:
> @@ -552,6 +556,7 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest,
>  PropertyInfo qdev_prop_pci_devfn = {
>      .name  = "int32",

Is this name used anywhere? It seems wrong ...

>      .legacy_name  = "pci-devfn",
> +    .description = "Slot and function number, example: 06.0",

In fact, .0 can be omitted. So please make this:
Slot and optional function number, examples: 06.0 or 06.

>      .print = print_pci_devfn,
>      .get   = get_int32,
>      .set   = set_pci_devfn,

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties arei.gonglei
@ 2014-09-30 11:43   ` Michael S. Tsirkin
  2014-09-30 13:15     ` Gonglei
  0 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 11:43 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, stefanha, pbonzini, lcapitulino, afaerber

On Tue, Sep 30, 2014 at 11:02:39AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> The legacy_name is useless now, the better help
> information provied by description field of property.

provided.

Pls run ispell on comments.

> 
> 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>
> ---
>  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(-)
> 
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index 55b6636..f2bd954 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -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,
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index a853ac9..5c85db1 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -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,
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 31acbe6..7fcd415 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -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);
> diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c
> index 0312e04..33fb4cc 100644
> --- a/target-ppc/translate_init.c
> +++ b/target-ppc/translate_init.c
> @@ -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,
> -- 
> 2.0.4
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct arei.gonglei
@ 2014-09-30 11:48   ` Michael S. Tsirkin
  2014-09-30 13:18     ` Gonglei
  0 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 11:48 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, stefanha, pbonzini, lcapitulino, afaerber

On Tue, Sep 30, 2014 at 11:02:36AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> The descriptions can serve as documentation in the code,
> and they can be used to provide better help.
> 
> 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 object property's.


I think by the above you mean "Copy property descriptions when copying alias
properties"?

> 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>
> ---
>  include/qom/object.h | 15 +++++++++++++++
>  qom/object.c         | 20 ++++++++++++++++++++
>  2 files changed, 35 insertions(+)
> 
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 8a05a81..ddc600d 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -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);
>  
> +

Avoid duplicate empty lines please.

> +/**
> + * object_property_set_description:
> + * @obj: the object to set a property's description to

do you mean "the object owning the property"?

> + * @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
> diff --git a/qom/object.c b/qom/object.c
> index 575291f..a751367 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -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);
>  }
>  
> @@ -1672,10 +1674,28 @@ 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);
>  }
>  
> +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;
> +    }
> +
> +    g_free(op->description);
> +    op->description = g_strdup(description);
> +}
> +
>  static void object_instance_init(Object *obj)
>  {
>      object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
> -- 
> 2.0.4
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30 11:35 ` Michael S. Tsirkin
@ 2014-09-30 11:53   ` Paolo Bonzini
  2014-09-30 12:09   ` Markus Armbruster
  2014-09-30 13:05   ` Gonglei
  2 siblings, 0 replies; 28+ messages in thread
From: Paolo Bonzini @ 2014-09-30 11:53 UTC (permalink / raw)
  To: Michael S. Tsirkin, arei.gonglei
  Cc: weidong.huang, aliguori, qemu-devel, armbru, luonengjun,
	peter.huangpeng, lcapitulino, stefanha, afaerber

Il 30/09/2014 13:35, Michael S. Tsirkin ha scritto:
>> > virtio-blk-pci.addr=int32 (Slot and function number, example: 06.0)
> Weird. 06.0 is clearly not an int, is it?

The QOM property accepts both int32 and str, but always returns an int32
when read.

For now we can leave out patch 5 while this is sorted out.

Paolo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30 11:35 ` Michael S. Tsirkin
  2014-09-30 11:53   ` Paolo Bonzini
@ 2014-09-30 12:09   ` Markus Armbruster
  2014-09-30 13:05   ` Gonglei
  2 siblings, 0 replies; 28+ messages in thread
From: Markus Armbruster @ 2014-09-30 12:09 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: weidong.huang, stefanha, luonengjun, peter.huangpeng, qemu-devel,
	arei.gonglei, aliguori, pbonzini, lcapitulino, afaerber

"Michael S. Tsirkin" <mst@redhat.com> writes:

> On Tue, Sep 30, 2014 at 11:02:34AM +0800, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>> 
>> This patch series based on qom-next tree:
>>  https://github.com/afaerber/qemu-cpu/commits/qom-next
>> 
>> 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)
>
> Weird. 06.0 is clearly not an int, is it?

Yes, it is.  48 in fact ;-P

Back to serious.  This is a clear improvement over
"virtio-blk-pci.addr=pci-devfn".  Let's get it in.  We can always
improve further on top.

[...]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30 11:35 ` Michael S. Tsirkin
  2014-09-30 11:53   ` Paolo Bonzini
  2014-09-30 12:09   ` Markus Armbruster
@ 2014-09-30 13:05   ` Gonglei
  2 siblings, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-09-30 13:05 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', arei.gonglei
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru, aliguori,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 0/5] add description field in
> ObjectProperty and PropertyInfo struct
> 
> On Tue, Sep 30, 2014 at 11:02:34AM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > This patch series based on qom-next tree:
> >  https://github.com/afaerber/qemu-cpu/commits/qom-next
> >
> > 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)
> 
> Weird. 06.0 is clearly not an int, is it?
> 
> > 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
> 
> BTW, any way we can find out and report default values
> as well? E.g.
> virtio-blk-pci.indirect_desc=bool (on/off) default:on
> 
I think qom-get is the only way at present. :)

> This idea should not block this patch of course.
> 

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 11:42   ` Michael S. Tsirkin
@ 2014-09-30 13:14     ` Gonglei
  2014-09-30 13:33       ` Michael S. Tsirkin
  0 siblings, 1 reply; 28+ messages in thread
From: Gonglei @ 2014-09-30 13:14 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', arei.gonglei
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru, aliguori,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in
> PropertyInfo struct
> 
> On Tue, Sep 30, 2014 at 11:02:35AM +0800, arei.gonglei@huawei.com wrote:
> > @@ -552,6 +556,7 @@ static int print_pci_devfn(DeviceState *dev, Property
> *prop, char *dest,
> >  PropertyInfo qdev_prop_pci_devfn = {
> >      .name  = "int32",
> 
> Is this name used anywhere? It seems wrong ...
> 
The Propertyinfo.name is used to the qdev property's type, please see PATCH 4:

-            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
+            info->type = g_strdup(prop->info->name);

> >      .legacy_name  = "pci-devfn",
> > +    .description = "Slot and function number, example: 06.0",
> 
> In fact, .0 can be omitted. So please make this:
> Slot and optional function number, examples: 06.0 or 06.
> 
OK. Thanks.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties
  2014-09-30 11:43   ` Michael S. Tsirkin
@ 2014-09-30 13:15     ` Gonglei
  0 siblings, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-09-30 13:15 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', arei.gonglei
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru, aliguori,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev
> properties
> 
> On Tue, Sep 30, 2014 at 11:02:39AM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > The legacy_name is useless now, the better help
> > information provied by description field of property.
> 
> provided.
> 
> Pls run ispell on comments.
> 
OK. Thanks for your ponit.

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct
  2014-09-30 11:48   ` Michael S. Tsirkin
@ 2014-09-30 13:18     ` Gonglei
  0 siblings, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-09-30 13:18 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', arei.gonglei
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru, aliguori,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 2/5] qom: add description field in
> ObjectProperty struct
> 
> On Tue, Sep 30, 2014 at 11:02:36AM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > The descriptions can serve as documentation in the code,
> > and they can be used to provide better help.
> >
> > 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 object property's.
> 
> 
> I think by the above you mean "Copy property descriptions when copying alias
> properties"?
> 
Yes.

> > 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>
> > ---
> >  include/qom/object.h | 15 +++++++++++++++
> >  qom/object.c         | 20 ++++++++++++++++++++
> >  2 files changed, 35 insertions(+)
> >
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index 8a05a81..ddc600d 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -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);
> >
> > +
> 
> Avoid duplicate empty lines please.
> 
OK. Thanks.

Best regards,
-Gonglei

> > +/**
> > + * object_property_set_description:
> > + * @obj: the object to set a property's description to
> 
> do you mean "the object owning the property"?
> 
> > + * @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
> > diff --git a/qom/object.c b/qom/object.c
> > index 575291f..a751367 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -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);
> >  }
> >
> > @@ -1672,10 +1674,28 @@ 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);
> >  }
> >
> > +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;
> > +    }
> > +
> > +    g_free(op->description);
> > +    op->description = g_strdup(description);
> > +}
> > +
> >  static void object_instance_init(Object *obj)
> >  {
> >      object_property_add_str(obj, "type", qdev_get_type, NULL, NULL);
> > --
> > 2.0.4
> >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
                   ` (6 preceding siblings ...)
  2014-09-30 11:35 ` Michael S. Tsirkin
@ 2014-09-30 13:32 ` Michael S. Tsirkin
  2014-09-30 14:05   ` Gonglei
  7 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 13:32 UTC (permalink / raw)
  To: arei.gonglei
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, stefanha, pbonzini, lcapitulino, afaerber

On Tue, Sep 30, 2014 at 11:02:34AM +0800, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> This patch series based on qom-next tree:
>  https://github.com/afaerber/qemu-cpu/commits/qom-next
> 
> 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.

I'm fine with merging this as is, and adding improvements
on top.

Reviewed-by: Michael S. Tsirkin <mst@redhat.com>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:14     ` Gonglei
@ 2014-09-30 13:33       ` Michael S. Tsirkin
  2014-09-30 13:36         ` Paolo Bonzini
  0 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 13:33 UTC (permalink / raw)
  To: Gonglei
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, pbonzini, lcapitulino,
	afaerber

On Tue, Sep 30, 2014 at 09:14:50PM +0800, Gonglei wrote:
> > Subject: Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in
> > PropertyInfo struct
> > 
> > On Tue, Sep 30, 2014 at 11:02:35AM +0800, arei.gonglei@huawei.com wrote:
> > > @@ -552,6 +556,7 @@ static int print_pci_devfn(DeviceState *dev, Property
> > *prop, char *dest,
> > >  PropertyInfo qdev_prop_pci_devfn = {
> > >      .name  = "int32",
> > 
> > Is this name used anywhere? It seems wrong ...
> > 
> The Propertyinfo.name is used to the qdev property's type, please see PATCH 4:
> 
> -            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> +            info->type = g_strdup(prop->info->name);

I would say this one is more a string than an int.

> > >      .legacy_name  = "pci-devfn",
> > > +    .description = "Slot and function number, example: 06.0",
> > 
> > In fact, .0 can be omitted. So please make this:
> > Slot and optional function number, examples: 06.0 or 06.
> > 
> OK. Thanks.
> 
> Best regards,
> -Gonglei
> 

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:33       ` Michael S. Tsirkin
@ 2014-09-30 13:36         ` Paolo Bonzini
  2014-09-30 13:55           ` Michael S. Tsirkin
  0 siblings, 1 reply; 28+ messages in thread
From: Paolo Bonzini @ 2014-09-30 13:36 UTC (permalink / raw)
  To: Michael S. Tsirkin, Gonglei
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, lcapitulino, afaerber

Il 30/09/2014 15:33, Michael S. Tsirkin ha scritto:
> > > 
> > The Propertyinfo.name is used to the qdev property's type, please see PATCH 4:
> > 
> > -            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> > +            info->type = g_strdup(prop->info->name);
> 
> I would say this one is more a string than an int.

At the QOM level it is an int, even though it secondarily accepts a
string in "DD.F" format.

Paolo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:55           ` Michael S. Tsirkin
@ 2014-09-30 13:53             ` Paolo Bonzini
  2014-09-30 14:01               ` Michael S. Tsirkin
  2014-09-30 14:01             ` Gonglei
  1 sibling, 1 reply; 28+ messages in thread
From: Paolo Bonzini @ 2014-09-30 13:53 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, lcapitulino, afaerber,
	Gonglei

Il 30/09/2014 15:55, Michael S. Tsirkin ha scritto:
> > At the QOM level it is an int, even though it secondarily accepts a
> > string in "DD.F" format.
> 
> That's the only way to specify a function, isn't it?

No, as Markus said "06.0" is 48, "06.1" is 49, etc.

Paolo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:36         ` Paolo Bonzini
@ 2014-09-30 13:55           ` Michael S. Tsirkin
  2014-09-30 13:53             ` Paolo Bonzini
  2014-09-30 14:01             ` Gonglei
  0 siblings, 2 replies; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 13:55 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, lcapitulino, afaerber,
	Gonglei

On Tue, Sep 30, 2014 at 03:36:22PM +0200, Paolo Bonzini wrote:
> Il 30/09/2014 15:33, Michael S. Tsirkin ha scritto:
> > > > 
> > > The Propertyinfo.name is used to the qdev property's type, please see PATCH 4:
> > > 
> > > -            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
> > > +            info->type = g_strdup(prop->info->name);
> > 
> > I would say this one is more a string than an int.
> 
> At the QOM level it is an int, even though it secondarily accepts a
> string in "DD.F" format.
> 
> Paolo

That's the only way to specify a function, isn't it?
Maybe it's not a good idea to expose the QOM type in this case.

-- 
MST

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:53             ` Paolo Bonzini
@ 2014-09-30 14:01               ` Michael S. Tsirkin
  2014-09-30 14:02                 ` Paolo Bonzini
  0 siblings, 1 reply; 28+ messages in thread
From: Michael S. Tsirkin @ 2014-09-30 14:01 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, lcapitulino, afaerber,
	Gonglei

On Tue, Sep 30, 2014 at 03:53:53PM +0200, Paolo Bonzini wrote:
> Il 30/09/2014 15:55, Michael S. Tsirkin ha scritto:
> > > At the QOM level it is an int, even though it secondarily accepts a
> > > string in "DD.F" format.
> > 
> > That's the only way to specify a function, isn't it?
> 
> No, as Markus said "06.0" is 48, "06.1" is 49, etc.
> 
> Paolo

I see. So in fact the help text I suggested is wrong.
At least for HMP I would say slot.function is the
primary format.
Let's just make it a string, it's a superset of
an integer isn't it?

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 13:55           ` Michael S. Tsirkin
  2014-09-30 13:53             ` Paolo Bonzini
@ 2014-09-30 14:01             ` Gonglei
  1 sibling, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-09-30 14:01 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', 'Paolo Bonzini'
  Cc: weidong.huang, stefanha, qemu-devel, luonengjun, armbru,
	peter.huangpeng, arei.gonglei, aliguori, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in
> PropertyInfo struct
> 
> On Tue, Sep 30, 2014 at 03:36:22PM +0200, Paolo Bonzini wrote:
> > Il 30/09/2014 15:33, Michael S. Tsirkin ha scritto:
> > > > >
> > > > The Propertyinfo.name is used to the qdev property's type, please see
> PATCH 4:
> > > >
> > > > -            info->type = g_strdup(prop->info->legacy_name ?:
> prop->info->name);
> > > > +            info->type = g_strdup(prop->info->name);
> > >
> > > I would say this one is more a string than an int.
> >
> > At the QOM level it is an int, even though it secondarily accepts a
> > string in "DD.F" format.
> >
> > Paolo
> 
> That's the only way to specify a function, isn't it?

As far as I can tell, yes.

Best regards,
-Gonglei

> Maybe it's not a good idea to expose the QOM type in this case.
> 
> --
> MST

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 14:01               ` Michael S. Tsirkin
@ 2014-09-30 14:02                 ` Paolo Bonzini
  2014-10-01  4:05                   ` Gonglei
  0 siblings, 1 reply; 28+ messages in thread
From: Paolo Bonzini @ 2014-09-30 14:02 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: weidong.huang, aliguori, armbru, luonengjun, peter.huangpeng,
	qemu-devel, arei.gonglei, stefanha, lcapitulino, afaerber,
	Gonglei

Il 30/09/2014 16:01, Michael S. Tsirkin ha scritto:
> > No, as Markus said "06.0" is 48, "06.1" is 49, etc.
> 
> I see. So in fact the help text I suggested is wrong.
> At least for HMP I would say slot.function is the
> primary format.
> Let's just make it a string, it's a superset of
> an integer isn't it?

Okay, will work on a patch.

Paolo

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct
  2014-09-30 13:32 ` Michael S. Tsirkin
@ 2014-09-30 14:05   ` Gonglei
  0 siblings, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-09-30 14:05 UTC (permalink / raw)
  To: 'Michael S. Tsirkin', arei.gonglei
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru, aliguori,
	pbonzini, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 0/5] add description field in
> ObjectProperty and PropertyInfo struct
> 
> On Tue, Sep 30, 2014 at 11:02:34AM +0800, arei.gonglei@huawei.com wrote:
> > From: Gonglei <arei.gonglei@huawei.com>
> >
> > This patch series based on qom-next tree:
> >  https://github.com/afaerber/qemu-cpu/commits/qom-next
> >
> > 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.
> 
> I'm fine with merging this as is, and adding improvements
> on top.
> 
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> 
Thanks!

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties
  2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties arei.gonglei
@ 2014-09-30 15:38   ` Eric Blake
  0 siblings, 0 replies; 28+ messages in thread
From: Eric Blake @ 2014-09-30 15:38 UTC (permalink / raw)
  To: arei.gonglei, qemu-devel
  Cc: weidong.huang, aliguori, mst, armbru, luonengjun, peter.huangpeng,
	lcapitulino, stefanha, pbonzini, afaerber

[-- Attachment #1: Type: text/plain, Size: 729 bytes --]

On 09/29/2014 09:02 PM, arei.gonglei@huawei.com wrote:
> From: Gonglei <arei.gonglei@huawei.com>
> 
> 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:
> 

> ---
>  qapi-schema.json |  4 +++-
>  qdev-monitor.c   |  7 ++++++-
>  qmp.c            | 13 ++++++++++---
>  3 files changed, 19 insertions(+), 5 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

(would be nice if qmp-commands.hx had an example for
device-list-properties, but that can be a separate patch)

-- 
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: 539 bytes --]

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in PropertyInfo struct
  2014-09-30 14:02                 ` Paolo Bonzini
@ 2014-10-01  4:05                   ` Gonglei
  0 siblings, 0 replies; 28+ messages in thread
From: Gonglei @ 2014-10-01  4:05 UTC (permalink / raw)
  To: 'Paolo Bonzini', 'Michael S. Tsirkin'
  Cc: weidong.huang, stefanha, luonengjun, qemu-devel, armbru,
	arei.gonglei, aliguori, peter.huangpeng, lcapitulino, afaerber

> Subject: Re: [Qemu-devel] [PATCH v4 1/5] qdev: add description field in
> PropertyInfo struct
> 
> Il 30/09/2014 16:01, Michael S. Tsirkin ha scritto:
> > > No, as Markus said "06.0" is 48, "06.1" is 49, etc.
> >
> > I see. So in fact the help text I suggested is wrong.
> > At least for HMP I would say slot.function is the
> > primary format.
> > Let's just make it a string, it's a superset of
> > an integer isn't it?
> 
> Okay, will work on a patch.
> 
> Paolo

Good. Thanks !

Today I have a 7-day National Day holiday. :)
See you next week!

Best regards,
-Gonglei

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2014-10-01  4:06 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-30  3:02 [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct arei.gonglei
2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 1/5] qdev: add description field in " arei.gonglei
2014-09-30 11:42   ` Michael S. Tsirkin
2014-09-30 13:14     ` Gonglei
2014-09-30 13:33       ` Michael S. Tsirkin
2014-09-30 13:36         ` Paolo Bonzini
2014-09-30 13:55           ` Michael S. Tsirkin
2014-09-30 13:53             ` Paolo Bonzini
2014-09-30 14:01               ` Michael S. Tsirkin
2014-09-30 14:02                 ` Paolo Bonzini
2014-10-01  4:05                   ` Gonglei
2014-09-30 14:01             ` Gonglei
2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 2/5] qom: add description field in ObjectProperty struct arei.gonglei
2014-09-30 11:48   ` Michael S. Tsirkin
2014-09-30 13:18     ` Gonglei
2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 3/5] qdev: set the object property's description to the qdev property's arei.gonglei
2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 4/5] qmp: print descriptions of object properties arei.gonglei
2014-09-30 15:38   ` Eric Blake
2014-09-30  3:02 ` [Qemu-devel] [PATCH v4 5/5] qdev: drop legacy_name from qdev properties arei.gonglei
2014-09-30 11:43   ` Michael S. Tsirkin
2014-09-30 13:15     ` Gonglei
2014-09-30  8:54 ` [Qemu-devel] [PATCH v4 0/5] add description field in ObjectProperty and PropertyInfo struct Paolo Bonzini
2014-09-30 11:35 ` Michael S. Tsirkin
2014-09-30 11:53   ` Paolo Bonzini
2014-09-30 12:09   ` Markus Armbruster
2014-09-30 13:05   ` Gonglei
2014-09-30 13:32 ` Michael S. Tsirkin
2014-09-30 14:05   ` Gonglei

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).