From: Paolo Bonzini <pbonzini@redhat.com>
To: Or Goshen <oberonc@gmail.com>, Luiz Capitulino <lcapitulino@redhat.com>
Cc: qemu-devel@nongnu.org, Or Goshen <or@heartbeat.com>
Subject: Re: [Qemu-devel] [PATCH] Add a command to QMP to list the supported devices
Date: Mon, 24 Feb 2014 10:31:11 +0100 [thread overview]
Message-ID: <530B115F.7080407@redhat.com> (raw)
In-Reply-To: <1393233796-1328-1-git-send-email-orx.goshen@intel.com>
Il 24/02/2014 10:23, Or Goshen ha scritto:
> From: Or Goshen <or@heartbeat.com>
>
> Was done on behalf of Intel Corp.
Hi Or,
you can use qom-list-types for this purpose.
Paolo
> ---
> qapi-schema.json | 26 ++++++++++++++++++++++++++
> qdev-monitor.c | 28 ++++++++++++++++++++++++++++
> qmp-commands.hx | 40 ++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 94 insertions(+), 0 deletions(-)
>
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 05ced9d..cae1200 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -526,6 +526,32 @@
> { 'command': 'query-commands', 'returns': ['CommandInfo'] }
>
> ##
> +# @DeviceInfo:
> +#
> +# Information about a device
> +#
> +# @name: The command name
> +# @bus: The bus it is connected to
> +# @alias: Device alias
> +# @desc: Description of the device
> +#
> +# Since: 1.6.0
> +##
> +{ 'type': 'DeviceInfo', 'data': {'name': 'str', 'bus': 'str', 'alias': 'str', 'desc': 'str'} }
> +
> +##
> +# @query-devices:
> +#
> +# Return a list of supported devices
> +#
> +# Returns: A list of @DeviceInfo for all supported devices
> +#
> +# Since: 1.6.0
> +##
> +{ 'command': 'query-devices', 'returns': ['DeviceInfo'] }
> +
> +
> +##
> # @EventInfo:
> #
> # Information about a QMP event
> diff --git a/qdev-monitor.c b/qdev-monitor.c
> index 1d3b68d..0a59fd9 100644
> --- a/qdev-monitor.c
> +++ b/qdev-monitor.c
> @@ -644,6 +644,34 @@ void do_info_qtree(Monitor *mon, const QDict *qdict)
> qbus_print(mon, sysbus_get_default(), 0);
> }
>
> +static void qdev_list_devinfo(ObjectClass *klass, void *data)
> +{
> + DeviceInfoList *e, **pret = data;
> + DeviceInfo *info;
> + DeviceClass *dc = (DeviceClass *)object_class_dynamic_cast(klass, TYPE_DEVICE);
> + if (!dc) return;
> +
> + info = g_malloc0(sizeof(*info));
> + info->name = g_strdup(object_class_get_name(klass));
> + info->bus = g_strdup(dc->bus_type ? dc->bus_type : "");
> + info->alias = g_strdup(qdev_class_has_alias(dc) ? qdev_class_get_alias(dc) : "");
> + info->desc = g_strdup(dc->desc ? dc->desc : "");
> +
> + e = g_malloc0(sizeof(*e));
> + e->value = info;
> + e->next = *pret;
> + *pret = e;
> +}
> +
> +DeviceInfoList * qmp_query_devices(Error **errp)
> +{
> + DeviceInfoList *list = NULL;
> +
> + object_class_foreach(qdev_list_devinfo, TYPE_DEVICE, false, &list);
> +
> + return list;
> +}
> +
> void do_info_qdm(Monitor *mon, const QDict *qdict)
> {
> qdev_print_devinfos(true);
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index cce6b81..be4451d 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -1851,6 +1851,46 @@ EQMP
> },
>
> SQMP
> +query-devices
> +--------------
> +
> +List supported devices
> +
> +Each device is represented by a json-object, the returned value is a json-array
> +of all devices.
> +
> +Each json-object contain:
> +
> +- "name": device's name (json-string)
> +- "bus": bus the device connects to (json-string)
> +- "alias": device's alias (json-string)
> +- "desc": device's description (json-string)
> +
> +Example:
> +
> +-> { "execute": "query-devices" }
> +<- {
> + "return":[
> + {
> + "name":"pci-bridge",
> + "bus":"PCI",
> + "alias":"",
> + "desc":"Standard PCI Bridge"
> + }
> + ]
> + }
> +
> +Note: This example has been shortened as the real response is too long.
> +
> +EQMP
> +
> + {
> + .name = "query-devices",
> + .args_type = "",
> + .mhandler.cmd_new = qmp_marshal_input_query_devices,
> + },
> +
> +SQMP
> query-events
> --------------
>
>
next prev parent reply other threads:[~2014-02-24 9:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-24 9:23 [Qemu-devel] [PATCH] Add a command to QMP to list the supported devices Or Goshen
2014-02-24 9:31 ` Paolo Bonzini [this message]
2014-02-24 13:40 ` Andreas Färber
2014-02-24 13:44 ` Paolo Bonzini
2014-02-24 13:49 ` Or Goshen
2014-02-24 18:05 ` Paolo Bonzini
2014-02-24 15:40 ` Eric Blake
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=530B115F.7080407@redhat.com \
--to=pbonzini@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=oberonc@gmail.com \
--cc=or@heartbeat.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 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.