* [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm)
@ 2010-07-23 16:47 Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 1/3] QMP: Introduce the documentation for query-available-devices Miguel Di Ciurcio Filho
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-23 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, lcapitulino, Miguel Di Ciurcio Filho, avi
This series introduces the documentation for the query-available-devices command
and the conversion of the monitor command 'info qdm' to QMP.
The documentation and code were based on a patch previously sent to qemu-devel
by Daniel P. Berrange:
http://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00931.html
Changelog from v3
-----------------
- Renamed the command from query-qdm to query-available-devices
- Fixed coding style when declaring the variable 'type'
- Fixed qlist leak in case the device does not have any property
- Split the series from 2 to 3 parts for easier review
Changelog from v2
-----------------
- added IDE and s390-virtio as possible values for "bus"
- specify that the "properties" list is optional, in case the device doesn't
have anything to be setup
- reworded the explanation of "creatable"
- reverted the qdev/qmp split, just use "type" and its json equivalent
representation
- do not list legacy stuff: PROP_TYPE_(VLAN|PTR|UNSPEC)
Changelog from v1
-----------------
- renamed "props" to "properties"
- updated the examples
- reworded the explanations of "name" and "description"
- split "type" into a json-object, adding "qmp" and "qdev"
- list all possible values for "bus"
- list all possible values for "qdev" on "type"
- list all possible values for "qmp" on "type"
Changes from the Daniel's original patch:
- Split the patch in two, taking out the documentation from the code
- Reworded some parts of the documentation and added data types
- Small cleanups and renamed do_info_devices() to do_info_qdm()
- Added do_info_qdm_print() to be used in the monitor
Regards,
Miguel
---
*** BLURB HERE ***
Miguel Di Ciurcio Filho (3):
QMP: Introduce the documentation for query-available-devices
QMP: Introduce query-available-devices
monitor: Convert 'info qdm' to QMP
hw/qdev.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
hw/qdev.h | 3 +-
monitor.c | 11 +++++-
qemu-monitor.hx | 71 +++++++++++++++++++++++++++++++++++
4 files changed, 192 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v4 1/3] QMP: Introduce the documentation for query-available-devices
2010-07-23 16:47 [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Miguel Di Ciurcio Filho
@ 2010-07-23 16:47 ` Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 2/3] QMP: Introduce query-available-devices Miguel Di Ciurcio Filho
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-23 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, lcapitulino, Miguel Di Ciurcio Filho, avi
---
qemu-monitor.hx | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 2af3de6..f6b976a 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -2490,6 +2490,77 @@ STEXI
show device tree
@item info qdm
show qdev device model list
+ETEXI
+SQMP
+query-available-devices
+-----------------------
+
+Describe the capabilities of all devices registered with qdev.
+
+The returned output is a json-array, each element is a json-object describing
+a single device type.
+
+Each json-object contains the following:
+
+- "name": name of the device (json-string)
+- "bus": the name of the bus type for the device (json-string)
+ - Possible values: PCI, SCSI, I2C, ISA, SSI, USB, virtio-serial-bus, System,
+ IDE, s390-virtio
+- "alias": an alias by which the device is also known (json-string, optional)
+- "description": description of the device (json-string, optional)
+- "creatable": whether this device can be created by the user (json-boolean)
+- "properties": a json-array where each item is a json-object that describes a
+ property of the device. If the device has no property to be setup, this item
+ will not be present. Each json-object contains the following:
+ - "name": the name of the property (json-string)
+ - "type": the json type of the property (json-string)
+ - Possible values: integer, string, boolean
+
+Example:
+
+-> { "execute": "query-available-devices" }
+<- {
+ "return": [
+ {
+ "name": "virtio-blk-pci",
+ "creatable": true,
+ "bus": "PCI",
+ "properties": [
+ {
+ "name": "indirect_desc",
+ "type": "boolean"
+ },
+ {
+ "name": "logical_block_size",
+ "type": "integer"
+ },
+ {
+ "name": "opt_io_size",
+ "type": "integer"
+ },
+ {
+ "name": "drive",
+ "type": "string"
+ }
+ ]
+ },
+ {
+ "name": "virtio-balloon-pci",
+ "creatable": true,
+ "bus": "PCI",
+ "properties": [
+ {
+ "name": "indirect_desc",
+ "type": "boolean"
+ }
+ ]
+ },
+ ....
+ ]
+
+EQMP
+
+STEXI
@item info roms
show roms
@end table
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v4 2/3] QMP: Introduce query-available-devices
2010-07-23 16:47 [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 1/3] QMP: Introduce the documentation for query-available-devices Miguel Di Ciurcio Filho
@ 2010-07-23 16:47 ` Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 3/3] monitor: Convert 'info qdm' to QMP Miguel Di Ciurcio Filho
2010-07-23 20:20 ` [Qemu-devel] Re: [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Luiz Capitulino
3 siblings, 0 replies; 5+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-23 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, lcapitulino, Miguel Di Ciurcio Filho, avi
---
hw/qdev.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
hw/qdev.h | 1 +
monitor.c | 8 ++++++
3 files changed, 93 insertions(+), 0 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index e99c73f..14985f5 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -29,6 +29,7 @@
#include "qdev.h"
#include "sysemu.h"
#include "monitor.h"
+#include "qjson.h"
static int qdev_hotplug = 0;
@@ -788,6 +789,89 @@ void do_info_qdm(Monitor *mon)
}
}
+static const char *qdev_property_type_to_string(int type)
+{
+ switch (type) {
+ case PROP_TYPE_UINT8:
+ case PROP_TYPE_UINT16:
+ case PROP_TYPE_UINT32:
+ case PROP_TYPE_INT32:
+ case PROP_TYPE_UINT64:
+ return "integer";
+ case PROP_TYPE_TADDR:
+ case PROP_TYPE_MACADDR:
+ case PROP_TYPE_DRIVE:
+ case PROP_TYPE_CHR:
+ case PROP_TYPE_STRING:
+ case PROP_TYPE_NETDEV:
+ return "string";
+ case PROP_TYPE_BIT:
+ return "boolean";
+ }
+
+ return NULL;
+}
+
+void do_available_devices(Monitor *mon, QObject **ret_data)
+{
+ DeviceInfo *info;
+ QList *devs = qlist_new();
+
+ for (info = device_info_list; info != NULL; info = info->next) {
+ QObject *obj;
+ QDict *dev;
+ QList *props = qlist_new();
+ Property *prop;
+ const char *type;
+
+ for (prop = info->props; prop && prop->name; prop++) {
+ QObject *entry;
+ /*
+ * TODO: skip old and hackish stuff, they will be removed some day.
+ */
+ if (!prop->info->parse || prop->info->type == PROP_TYPE_VLAN
+ || prop->info->type == PROP_TYPE_PTR
+ || prop->info->type == PROP_TYPE_UNSPEC) {
+ continue;
+ }
+
+ type = qdev_property_type_to_string(prop->info->type);
+
+ assert(type != NULL);
+
+ entry = qobject_from_jsonf("{ 'name': %s, 'type': %s }",
+ prop->name, type);
+
+ qlist_append_obj(props, entry);
+ }
+
+ obj = qobject_from_jsonf("{ 'name': %s, 'bus': %s, 'creatable': %i }",
+ info->name,
+ info->bus_info->name,
+ info->no_user ? 0 : 1);
+
+ dev = qobject_to_qdict(obj);
+
+ if (!qlist_empty(props)) {
+ qdict_put(dev, "properties", props);
+ } else {
+ QDECREF(props);
+ }
+
+ if (info->alias) {
+ qdict_put(dev, "alias", qstring_from_str(info->alias));
+ }
+
+ if (info->desc) {
+ qdict_put(dev, "description", qstring_from_str(info->desc));
+ }
+
+ qlist_append(devs, dev);
+ }
+
+ *ret_data = QOBJECT(devs);
+}
+
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data)
{
QemuOpts *opts;
diff --git a/hw/qdev.h b/hw/qdev.h
index 678f8b7..8c6fa06 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -185,6 +185,7 @@ void qbus_free(BusState *bus);
void do_info_qtree(Monitor *mon);
void do_info_qdm(Monitor *mon);
+void do_available_devices(Monitor *mon, QObject **ret_data);
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
diff --git a/monitor.c b/monitor.c
index 45fd482..384d5fc 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2561,6 +2561,14 @@ static const mon_cmd_t info_cmds[] = {
.mhandler.info = do_info_qtree,
},
{
+ .name = "available-devices",
+ .args_type = "",
+ .params = "",
+ .help = "describes the capabilities of all supported devices",
+ .user_print = monitor_user_noop,
+ .mhandler.info_new = do_available_devices,
+ },
+ {
.name = "qdm",
.args_type = "",
.params = "",
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [PATCH v4 3/3] monitor: Convert 'info qdm' to QMP
2010-07-23 16:47 [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 1/3] QMP: Introduce the documentation for query-available-devices Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 2/3] QMP: Introduce query-available-devices Miguel Di Ciurcio Filho
@ 2010-07-23 16:47 ` Miguel Di Ciurcio Filho
2010-07-23 20:20 ` [Qemu-devel] Re: [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Luiz Capitulino
3 siblings, 0 replies; 5+ messages in thread
From: Miguel Di Ciurcio Filho @ 2010-07-23 16:47 UTC (permalink / raw)
To: qemu-devel; +Cc: armbru, lcapitulino, Miguel Di Ciurcio Filho, avi
---
hw/qdev.c | 31 +++++++++++++++++++++++++++----
hw/qdev.h | 2 +-
monitor.c | 3 ++-
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/hw/qdev.c b/hw/qdev.c
index 14985f5..ea9633c 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -780,13 +780,36 @@ void do_info_qtree(Monitor *mon)
qbus_print(mon, main_system_bus, 0);
}
-void do_info_qdm(Monitor *mon)
+static void qdm_list_iter(QObject *obj, void *opaque)
{
- DeviceInfo *info;
- for (info = device_info_list; info != NULL; info = info->next) {
- qdev_print_devinfo(info);
+ Monitor *mon = opaque;
+ QDict *dev = qobject_to_qdict(obj);
+
+ monitor_printf(mon, "name \"%s\", bus %s", qdict_get_str(dev, "name"),
+ qdict_get_str(dev, "bus"));
+
+ if (qdict_haskey(dev, "alias")) {
+ monitor_printf(mon, ", alias \"%s\"", qdict_get_str(dev, "alias"));
}
+
+ if (qdict_haskey(dev, "description")) {
+ monitor_printf(mon, ", desc \"%s\"", qdict_get_str(dev, "description"));
+ }
+
+ if (!qdict_get_bool(dev, "creatable")) {
+ monitor_printf(mon, ", no-user");
+ }
+
+ monitor_printf(mon, "\n");
+}
+
+void do_info_qdm_print(Monitor *mon, const QObject *ret_data)
+{
+ QList *devs;
+
+ devs = qobject_to_qlist(ret_data);
+ qlist_iter(devs, qdm_list_iter, mon);
}
static const char *qdev_property_type_to_string(int type)
diff --git a/hw/qdev.h b/hw/qdev.h
index 8c6fa06..04d8501 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -184,7 +184,7 @@ void qbus_free(BusState *bus);
/*** monitor commands ***/
void do_info_qtree(Monitor *mon);
-void do_info_qdm(Monitor *mon);
+void do_info_qdm_print(Monitor *mon, const QObject *ret_data);
void do_available_devices(Monitor *mon, QObject **ret_data);
int do_device_add(Monitor *mon, const QDict *qdict, QObject **ret_data);
int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
diff --git a/monitor.c b/monitor.c
index 384d5fc..1322416 100644
--- a/monitor.c
+++ b/monitor.c
@@ -2573,7 +2573,8 @@ static const mon_cmd_t info_cmds[] = {
.args_type = "",
.params = "",
.help = "show qdev device model list",
- .mhandler.info = do_info_qdm,
+ .user_print = do_info_qdm_print,
+ .mhandler.info_new = do_available_devices,
},
{
.name = "roms",
--
1.7.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm)
2010-07-23 16:47 [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Miguel Di Ciurcio Filho
` (2 preceding siblings ...)
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 3/3] monitor: Convert 'info qdm' to QMP Miguel Di Ciurcio Filho
@ 2010-07-23 20:20 ` Luiz Capitulino
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Capitulino @ 2010-07-23 20:20 UTC (permalink / raw)
To: Miguel Di Ciurcio Filho; +Cc: avi, qemu-devel, armbru
On Fri, 23 Jul 2010 13:47:37 -0300
Miguel Di Ciurcio Filho <miguel.filho@gmail.com> wrote:
> This series introduces the documentation for the query-available-devices command
> and the conversion of the monitor command 'info qdm' to QMP.
>
> The documentation and code were based on a patch previously sent to qemu-devel
> by Daniel P. Berrange:
>
> http://lists.gnu.org/archive/html/qemu-devel/2010-06/msg00931.html
Looks good to me now, pushed it to the monitor queue.
Only detail is that query-qdm was available and there was some unneeded
blank lines, fixed both.
>
> Changelog from v3
> -----------------
> - Renamed the command from query-qdm to query-available-devices
> - Fixed coding style when declaring the variable 'type'
> - Fixed qlist leak in case the device does not have any property
> - Split the series from 2 to 3 parts for easier review
>
> Changelog from v2
> -----------------
> - added IDE and s390-virtio as possible values for "bus"
> - specify that the "properties" list is optional, in case the device doesn't
> have anything to be setup
> - reworded the explanation of "creatable"
> - reverted the qdev/qmp split, just use "type" and its json equivalent
> representation
> - do not list legacy stuff: PROP_TYPE_(VLAN|PTR|UNSPEC)
>
> Changelog from v1
> -----------------
> - renamed "props" to "properties"
> - updated the examples
> - reworded the explanations of "name" and "description"
> - split "type" into a json-object, adding "qmp" and "qdev"
> - list all possible values for "bus"
> - list all possible values for "qdev" on "type"
> - list all possible values for "qmp" on "type"
>
> Changes from the Daniel's original patch:
> - Split the patch in two, taking out the documentation from the code
> - Reworded some parts of the documentation and added data types
> - Small cleanups and renamed do_info_devices() to do_info_qdm()
> - Added do_info_qdm_print() to be used in the monitor
>
> Regards,
>
> Miguel
>
> ---
>
> *** BLURB HERE ***
>
> Miguel Di Ciurcio Filho (3):
> QMP: Introduce the documentation for query-available-devices
> QMP: Introduce query-available-devices
> monitor: Convert 'info qdm' to QMP
>
> hw/qdev.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> hw/qdev.h | 3 +-
> monitor.c | 11 +++++-
> qemu-monitor.hx | 71 +++++++++++++++++++++++++++++++++++
> 4 files changed, 192 insertions(+), 4 deletions(-)
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-07-23 20:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-23 16:47 [Qemu-devel] [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 1/3] QMP: Introduce the documentation for query-available-devices Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 2/3] QMP: Introduce query-available-devices Miguel Di Ciurcio Filho
2010-07-23 16:47 ` [Qemu-devel] [PATCH v4 3/3] monitor: Convert 'info qdm' to QMP Miguel Di Ciurcio Filho
2010-07-23 20:20 ` [Qemu-devel] Re: [PATCH v4 0/3] QMP: Introduce query-available-devices (was query-qdm) Luiz Capitulino
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.