qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Luiz Capitulino" <lcapitulino@redhat.com>,
	Gonglei <arei.gonglei@huawei.com>,
	"Markus Armbruster" <armbru@redhat.com>,
	"Andreas Färber" <afaerber@suse.de>
Subject: [Qemu-devel] [PULL 46/47] qmp: Print descriptions of object properties
Date: Wed, 15 Oct 2014 05:09:20 +0200	[thread overview]
Message-ID: <1413342561-4754-47-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1413342561-4754-1-git-send-email-afaerber@suse.de>

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 optional function number, example: 06.0 or 06)
virtio-blk-pci.event_idx=bool (on/off)
virtio-blk-pci.indirect_desc=bool (on/off)
virtio-blk-pci.vectors=uint32
virtio-blk-pci.ioeventfd=bool (on/off)
virtio-blk-pci.class=uint32

Cc: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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 4f0d7e3..24379ab 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 754437b..fac7d17 100644
--- a/qdev-monitor.c
+++ b/qdev-monitor.c
@@ -213,9 +213,14 @@ int qdev_device_help(QemuOpts *opts)
     }
 
     for (prop = prop_list; prop; prop = prop->next) {
-        error_printf("%s.%s=%s\n", driver,
+        error_printf("%s.%s=%s", driver,
                      prop->value->name,
                      prop->value->type);
+        if (prop->value->has_description) {
+            error_printf(" (%s)\n", prop->value->description);
+        } else {
+            error_printf("\n");
+        }
     }
 
     qapi_free_DevicePropertyInfoList(prop_list);
diff --git a/qmp.c b/qmp.c
index c6767c4..0b4f131 100644
--- a/qmp.c
+++ b/qmp.c
@@ -442,7 +442,8 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
  */
 static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
                                                      const char *name,
-                                                     const char *default_type)
+                                                     const char *default_type,
+                                                     const char *description)
 {
     DevicePropertyInfo *info;
     Property *prop;
@@ -465,7 +466,9 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
 
             info = g_malloc0(sizeof(*info));
             info->name = g_strdup(prop->name);
-            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
+            info->type = g_strdup(prop->info->name);
+            info->has_description = !!prop->info->description;
+            info->description = g_strdup(prop->info->description);
             return info;
         }
         klass = object_class_get_parent(klass);
@@ -475,6 +478,9 @@ static DevicePropertyInfo *make_device_property_info(ObjectClass *klass,
     info = g_malloc0(sizeof(*info));
     info->name = g_strdup(name);
     info->type = g_strdup(default_type);
+    info->has_description = !!description;
+    info->description = g_strdup(description);
+
     return info;
 }
 
@@ -521,7 +527,8 @@ DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
             continue;
         }
 
-        info = make_device_property_info(klass, prop->name, prop->type);
+        info = make_device_property_info(klass, prop->name, prop->type,
+                                         prop->description);
         if (!info) {
             continue;
         }
-- 
1.8.4.5

  parent reply	other threads:[~2014-10-15  3:10 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15  3:08 [Qemu-devel] [PULL 00/47] QOM devices patch queue 2014-10-15 Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 01/47] qdev: gpio: Don't allow name share between I and O Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 02/47] qdev: gpio: Register GPIO inputs as child objects Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 03/47] qdev: gpio: Register GPIO outputs as QOM links Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 04/47] qom: Add error handler for object_property_print() Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 05/47] qom: Add error handler for object alias property Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 06/47] tests: virtio-scsi: Check if hot-plug/unplug works Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 07/47] tests: virtio-serial: " Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 08/47] libqos: Add qpci_plug_device_test() and qpci_unplug_acpi_device_test() Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 09/47] tests: virtio-rng: Check if hot-plug/unplug works Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 10/47] tests: virtio-net: " Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 11/47] tests: virtio-blk: " Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 12/47] tests: usb: Move uhci port test code to libqos/usb.c Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 13/47] tests: usb: add port test to uhci unit test Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 14/47] tests: usb: Generic usb device hotplug Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 15/47] tests: usb: usb-storage hotplug test Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 16/47] tests: usb: usb-uas " Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 17/47] Access BusState::allow_hotplug using wraper qbus_is_hotpluggable() Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 18/47] qdev: do not allow to instantiate non hotpluggable device with device_add Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 19/47] qdev: HotplugHandler: Rename unplug callback to unplug_request Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 20/47] qdev: HotplugHandler: Provide unplug callback Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 21/47] qdev: Add simple/generic unplug callback for HotplugHandler Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 22/47] qdev: Add wrapper to set BUS as HotplugHandler Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 23/47] qdev: Drop hotplug check from bus_add_child() Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 24/47] target-i386: ICC bus: Drop BusState::allow_hotplug Andreas Färber
2014-10-15  3:08 ` [Qemu-devel] [PULL 25/47] virtio-pci: " Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 26/47] virtio-serial: Convert to hotplug-handler API Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 27/47] virtio-mmio: Drop useless bus->allow_hotplug = 0 Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 28/47] s390x: Drop not used allow_hotplug in event-facility Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 29/47] s390x: Convert s390-virtio to hotplug handler API Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 30/47] s390x: Convert virtio-ccw " Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 31/47] scsi: Set SCSI BUS itself as default HotplugHandler Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 32/47] scsi: Convert pvscsi HBA to hotplug handler API Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 33/47] scsi: Convert virtio-scsi " Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 34/47] scsi: Cleanup not used anymore SCSIBusInfo{hotplug, hot_unplug} fields Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 35/47] usb-bot: Mark device as non hotpluggable Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 36/47] usb-bot: Drop not needed "allow_hotplug = 0" Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 37/47] usb-storage: " Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 38/47] usb: Convert usb-ccid to hotplug handler API Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 39/47] usb: Convert usb devices " Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 40/47] qdev: Drop legacy hotplug fields/methods Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 41/47] qdev: HotplugHandler: Add support for unplugging BUS-less devices Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 42/47] qdev: device_del: Search for to be unplugged device in 'peripheral' container Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 43/47] qdev: Add description field in PropertyInfo struct Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 44/47] qom: Add description field in ObjectProperty struct Andreas Färber
2014-10-15  3:09 ` [Qemu-devel] [PULL 45/47] qdev: Set the object property's description to the qdev property's Andreas Färber
2014-10-15  3:09 ` Andreas Färber [this message]
2014-10-15  3:09 ` [Qemu-devel] [PULL 47/47] qdev: Drop legacy_name from qdev properties Andreas Färber
2014-10-15 10:27 ` [Qemu-devel] [PULL 00/47] QOM devices patch queue 2014-10-15 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413342561-4754-47-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=arei.gonglei@huawei.com \
    --cc=armbru@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is 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).