All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Luiz Capitulino <lcapitulino@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	libvir-list@redhat.com, qemu-devel@nongnu.org,
	Markus Armbruster <armbru@redhat.com>,
	Alexander Graf <agraf@suse.de>, Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/7] qmp: introduce device-list-properties command
Date: Fri, 10 Aug 2012 09:40:06 -0500	[thread overview]
Message-ID: <87obmi6cah.fsf@codemonkey.ws> (raw)
In-Reply-To: <20120727130525.004c8a7e@doriath.home>

Luiz Capitulino <lcapitulino@redhat.com> writes:

> On Fri, 27 Jul 2012 08:37:13 -0500
> Anthony Liguori <aliguori@us.ibm.com> wrote:
>
>> This can be used in conjunction with qom-list-types to determine the supported
>> set of devices and their parameters.
>> 
>> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>> ---
>>  qapi-schema.json |   28 ++++++++++++++++++++++++++++
>>  qmp-commands.hx  |    7 +++++++
>>  qmp.c            |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 85 insertions(+), 0 deletions(-)
>> 
>> diff --git a/qapi-schema.json b/qapi-schema.json
>> index bc55ed2..015a84a 100644
>> --- a/qapi-schema.json
>> +++ b/qapi-schema.json
>> @@ -1727,6 +1727,34 @@
>>    'returns': [ 'ObjectTypeInfo' ] }
>>  
>>  ##
>> +# @DevicePropertyInfo:
>> +#
>> +# Information about device properties.
>> +#
>> +# @name: the name of the property
>> +# @type: the typename of the property
>> +#
>> +# Since: 1.2
>> +##
>> +{ 'type': 'DevicePropertyInfo',
>> +  'data': { 'name': 'str', 'type': 'str' } }
>> +
>> +##
>> +# @device-list-properties:
>> +#
>> +# List properties associated with a device.
>> +#
>> +# @typename: the type name of a device
>> +#
>> +# Returns: a list of DevicePropertyInfo describing a devices properties
>> +#
>> +# Since: 1.2
>> +##
>> +{ 'command': 'device-list-properties',
>> +  'data': { 'typename': 'str'},
>> +  'returns': [ 'DevicePropertyInfo' ] }
>
> I find it a bit weird that the argument is called typename but everything else
> refers to that same argument as a device.
>
> Maybe we should rename this to device-type-list-properties, DeviceTypePropertyInfo
> and typename to name.

I see where you're coming from but I think I'd prefer to leave it
as-is.  'DeviceType' isn't really a concept in QEMU.

Regards,

Anthony Liguori

>
> But that's minor, I won't oppose to it as it's.
>
>> +
>> +##
>>  # @migrate
>>  #
>>  # Migrates the current running guest to another Virtual Machine.
>> diff --git a/qmp-commands.hx b/qmp-commands.hx
>> index e3cf3c5..5c55528 100644
>> --- a/qmp-commands.hx
>> +++ b/qmp-commands.hx
>> @@ -2215,3 +2215,10 @@ EQMP
>>          .args_type  = "implements:s?,abstract:b?",
>>          .mhandler.cmd_new = qmp_marshal_input_qom_list_types,
>>      },
>> +
>> +    {
>> +        .name       = "device-list-properties",
>> +        .args_type  = "typename:s",
>> +        .mhandler.cmd_new = qmp_marshal_input_device_list_properties,
>> +    },
>> +
>> diff --git a/qmp.c b/qmp.c
>> index fee9fb2..254a32f 100644
>> --- a/qmp.c
>> +++ b/qmp.c
>> @@ -417,3 +417,53 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
>>  
>>      return ret;
>>  }
>> +
>> +DevicePropertyInfoList *qmp_device_list_properties(const char *typename,
>> +                                                   Error **errp)
>> +{
>> +    ObjectClass *klass;
>> +    Property *prop;
>> +    DevicePropertyInfoList *prop_list = NULL;
>> +
>> +    klass = object_class_by_name(typename);
>> +    if (klass == NULL) {
>> +        error_set(errp, QERR_DEVICE_NOT_FOUND, typename);
>> +        return NULL;
>> +    }
>> +
>> +    klass = object_class_dynamic_cast(klass, TYPE_DEVICE);
>> +    if (klass == NULL) {
>> +        error_set(errp, QERR_INVALID_PARAMETER_VALUE,
>> +                  "name", TYPE_DEVICE);
>> +        return NULL;
>> +    }
>> +
>> +    do {
>> +        for (prop = DEVICE_CLASS(klass)->props; prop && prop->name; prop++) {
>> +            DevicePropertyInfoList *entry;
>> +            DevicePropertyInfo *info;
>> +
>> +            /*
>> +             * TODO Properties without a parser are just for dirty hacks.
>> +             * qdev_prop_ptr is the only such PropertyInfo.  It's marked
>> +             * for removal.  This conditional should be removed along with
>> +             * it.
>> +             */
>> +            if (!prop->info->set) {
>> +                continue;           /* no way to set it, don't show */
>> +            }
>> +
>> +            info = g_malloc0(sizeof(*info));
>> +            info->name = g_strdup(prop->name);
>> +            info->type = g_strdup(prop->info->legacy_name ?: prop->info->name);
>> +
>> +            entry = g_malloc0(sizeof(*entry));
>> +            entry->value = info;
>> +            entry->next = prop_list;
>> +            prop_list = entry;
>> +        }
>> +        klass = object_class_get_parent(klass);
>> +    } while (klass != object_class_by_name(TYPE_DEVICE));
>> +
>> +    return prop_list;
>> +}

  reply	other threads:[~2012-08-10 14:40 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 13:37 [Qemu-devel] [PATCH 0/7] qapi: add commands to remove the need to parse -help output Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 1/7] qmp: introduce device-list-properties command Anthony Liguori
2012-07-27 16:05   ` Luiz Capitulino
2012-08-10 14:40     ` Anthony Liguori [this message]
2012-07-27 13:37 ` [Qemu-devel] [PATCH 2/7] qapi: mark QOM commands stable Anthony Liguori
2012-07-27 16:06   ` Luiz Capitulino
2012-08-10 14:40     ` Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 3/7] qapi: add query-machines command Anthony Liguori
2012-07-27 16:12   ` Luiz Capitulino
2012-08-10 14:41     ` Anthony Liguori
2012-08-10 14:50       ` Luiz Capitulino
2012-08-10 16:06         ` Anthony Liguori
2012-08-10 16:15           ` Luiz Capitulino
2012-07-27 17:25   ` Eric Blake
2012-07-27 18:12     ` Anthony Liguori
2012-07-27 18:28       ` Eric Blake
2012-07-27 13:37 ` [Qemu-devel] [PATCH 4/7] compiler: add macro for GCC weak symbols Anthony Liguori
2012-07-27 13:50   ` Peter Maydell
2012-07-27 14:27     ` Anthony Liguori
2012-07-27 14:45       ` Peter Maydell
2012-07-27 15:31         ` Anthony Liguori
2012-07-27 19:34           ` Blue Swirl
2012-07-27 20:51             ` Anthony Liguori
2012-07-27 21:04               ` Blue Swirl
2012-07-27 22:40                 ` Anthony Liguori
2012-07-28  6:25                   ` Markus Armbruster
2012-07-28  8:52                     ` Blue Swirl
2012-07-28  8:45                   ` Blue Swirl
2012-07-28  6:50           ` Peter Maydell
2012-07-28  8:58             ` Blue Swirl
2012-07-27 15:32     ` Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 5/7] qapi: add query-cpudefs command Anthony Liguori
2012-07-27 14:00   ` Peter Maydell
2012-07-27 15:01     ` Anthony Liguori
2012-07-27 16:19   ` Luiz Capitulino
2012-07-27 18:37   ` Eric Blake
2012-07-27 13:37 ` [Qemu-devel] [PATCH 6/7] target-i386: add implementation of query-cpudefs Anthony Liguori
2012-07-31 15:57   ` Eduardo Habkost
2012-08-10 14:43     ` Anthony Liguori
2012-08-10 15:59       ` Eduardo Habkost
2012-08-10 16:37         ` Anthony Liguori
2012-08-10 16:51           ` Eduardo Habkost
2012-08-10 17:09             ` Anthony Liguori
2012-08-10 17:31               ` Eduardo Habkost
2012-07-27 13:37 ` [Qemu-devel] [PATCH 7/7] target-ppc: " Anthony Liguori
2012-07-27 16:21 ` [Qemu-devel] [PATCH 0/7] qapi: add commands to remove the need to parse -help output Luiz Capitulino
2012-07-27 16:37   ` Daniel P. Berrange
  -- strict thread matches above, loose matches on Subject: below --
2012-08-10 16:04 [Qemu-devel] [PATCH 0/7] qapi: add commands to remove the need (v2) Anthony Liguori
2012-08-10 16:04 ` [Qemu-devel] [PATCH 1/7] qmp: introduce device-list-properties command Anthony Liguori

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=87obmi6cah.fsf@codemonkey.ws \
    --to=aliguori@us.ibm.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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.