All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Valentin Rakush <valentin.rakush@gmail.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, lcapitulino@redhat.com,
	asmetanin@virtuozzo.com, den@openvz.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH v5] qom, qmp, hmp, qapi: create qom-type-prop-list for class properties
Date: Tue, 26 Jan 2016 13:35:38 -0200	[thread overview]
Message-ID: <20160126153538.GN3869@thinpad.lan.raisama.net> (raw)
In-Reply-To: <1453710287-12706-1-git-send-email-valentin.rakush@gmail.com>

On Mon, Jan 25, 2016 at 11:24:47AM +0300, Valentin Rakush wrote:
> This patch adds support for qom-type-prop-list command to list object
> class properties. A later patch will use this functionality to
> implement x86_64-cpu properties.
> 
> Signed-off-by: Valentin Rakush <valentin.rakush@gmail.com>
> Cc: Luiz Capitulino <lcapitulino@redhat.com>
> Cc: Eric Blake <eblake@redhat.com>
> Cc: Markus Armbruster <armbru@redhat.com>
> Cc: Andreas Färber <afaerber@suse.de>
> Cc: Daniel P. Berrange <berrange@redhat.com>
> Cc: Eduardo Habkost <ehabkost@redhat.com>
> ---
[...]
> diff --git a/qmp.c b/qmp.c
> index 53affe2..baf25c0 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -460,6 +460,37 @@ ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
>      return ret;
>  }
>  
> +ObjectPropertyInfoList *qmp_qom_type_prop_list(const char *typename, Error **errp)
> +{
> +    ObjectClass *klass;
> +    ObjectPropertyInfoList *props = NULL;
> +    ObjectProperty *prop;
> +    ObjectPropertyIterator iter;
> +
> +    klass = object_class_by_name(typename);
> +    if (!klass) {
> +        error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND,
> +                  "Object class '%s' not found", typename);
> +        return NULL;
> +    }
> +
> +    object_class_property_iter_init(&iter, klass);
> +    while ((prop = object_property_iter_next(&iter))) {
> +        ObjectPropertyInfoList *entry = g_new0(ObjectPropertyInfoList, 1);
> +
> +        if (entry) {
> +            entry->value = g_new0(ObjectPropertyInfo, 1);
> +            entry->next = props;
> +            props = entry;
> +
> +            entry->value->name = g_strdup(prop->name);
> +            entry->value->type = g_strdup(prop->type);
> +        }
> +    }
> +
> +    return props;
> +}
> +

We already have "-device <type>,help", and it uses a completely
different mechanism for listing properties. There's no reason for
having two arbitrarily different APIs for listing properties
returning different results.

If qmp_device_list_properties() is not enough for you, please
clarify why, so we can consider improving it.


>  /* Return a DevicePropertyInfo for a qdev property.
>   *
>   * If a qdev property with the given name does not exist, use the given default
> diff --git a/qom/object.c b/qom/object.c
> index 5ff97ab..cabd91d 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -994,6 +994,13 @@ ObjectProperty *object_property_find(Object *obj, const char *name,
>      return NULL;
>  }
>  
> +void object_class_property_iter_init(ObjectPropertyIterator *iter,
> +                                     ObjectClass *klass)
> +{
> +    g_hash_table_iter_init(&iter->iter, klass->properties);
> +    iter->nextclass = object_class_get_parent(klass);
> +}
> +
>  void object_property_iter_init(ObjectPropertyIterator *iter,
>                                 Object *obj)
>  {
> -- 
> 1.8.3.1
> 

-- 
Eduardo

  reply	other threads:[~2016-01-26 15:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-25  8:24 [Qemu-devel] [PATCH v5] qom, qmp, hmp, qapi: create qom-type-prop-list for class properties Valentin Rakush
2016-01-26 15:35 ` Eduardo Habkost [this message]
2016-01-26 15:42   ` Eric Blake
2016-01-26 15:51   ` Daniel P. Berrange
2016-01-26 17:26     ` Eduardo Habkost
2016-01-26 22:19       ` Daniel P. Berrange
2016-01-27  9:53         ` Valentin Rakush
2016-01-27 15:09         ` Eduardo Habkost
2016-01-27 15:23           ` Daniel P. Berrange
2016-01-29 10:03             ` Valentin Rakush
2016-01-29 15:28               ` Eduardo Habkost
2016-01-31 13:40                 ` Valentin Rakush
2016-02-02 15:55                   ` Eduardo Habkost
2016-02-07 14:52                     ` Valentin Rakush

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=20160126153538.GN3869@thinpad.lan.raisama.net \
    --to=ehabkost@redhat.com \
    --cc=afaerber@suse.de \
    --cc=armbru@redhat.com \
    --cc=asmetanin@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=valentin.rakush@gmail.com \
    /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.