From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: qemu-devel@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
"Andreas Färber" <afaerber@suse.de>,
"Daniel P. Berrange" <berrange@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 6/8] qom: object_class_property_iter_init() function
Date: Thu, 27 Oct 2016 17:34:45 +0200 [thread overview]
Message-ID: <20161027173445.4cae7fe3@nial.brq.redhat.com> (raw)
In-Reply-To: <1477499426-9550-7-git-send-email-ehabkost@redhat.com>
On Wed, 26 Oct 2016 14:30:24 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:
> The new function will allow us to iterate over class properties
> using the same logic we use for object properties. Unit test
> included.
with current master this patch doesn't apply:
Applying: qom: object_class_property_iter_init() function
Context reduced to (2/2) to apply fragment at 1010
Context reduced to (2/2) to apply fragment at 1019
error: patch failed: qom/object.c:1017
error: qom/object.c: patch does not apply
error: patch failed: tests/check-qom-proplist.c:524
error: tests/check-qom-proplist.c: patch does not apply
Patch failed at 0001 qom: object_class_property_iter_init() function
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> include/qom/object.h | 14 ++++++++++++++
> qom/object.c | 11 +++++++++--
> tests/check-qom-proplist.c | 28 ++++++++++++++++++++++++++++
> 3 files changed, 51 insertions(+), 2 deletions(-)
>
> diff --git a/include/qom/object.h b/include/qom/object.h
> index 5ecc2d1..6e3646e 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -995,6 +995,20 @@ void object_property_iter_init(ObjectPropertyIterator *iter,
> Object *obj);
>
> /**
> + * object_class_property_iter_init:
> + * @klass: the class
> + *
> + * Initializes an iterator for traversing all properties
> + * registered against an object class and all parent classes.
> + *
> + * It is forbidden to modify the property list while iterating,
> + * whether removing or adding properties.
> + */
> +void object_class_property_iter_init(ObjectPropertyIterator *iter,
> + ObjectClass *klass);
> +
> +
> +/**
> * object_property_iter_next:
> * @iter: the iterator instance
> *
> diff --git a/qom/object.c b/qom/object.c
> index 7a05e35..3ae9cc7 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -1010,6 +1010,14 @@ void object_property_iter_init(ObjectPropertyIterator *iter,
> iter->nextclass = object_get_class(obj);
> }
>
> +
> +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);
> +}
> +
> ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter)
> {
> gpointer key, val;
> @@ -1017,8 +1025,7 @@ ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter)
> if (!iter->nextclass) {
> return NULL;
> }
> - g_hash_table_iter_init(&iter->iter, iter->nextclass->properties);
> - iter->nextclass = object_class_get_parent(iter->nextclass);
> + object_class_property_iter_init(iter, iter->nextclass);
> }
> return val;
> }
> diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
> index a92acc9..769549c 100644
> --- a/tests/check-qom-proplist.c
> +++ b/tests/check-qom-proplist.c
> @@ -496,6 +496,33 @@ static void test_dummy_iterator(void)
> }
>
>
> +static void test_dummy_class_iterator(void)
> +{
> + ObjectClass *klass = object_class_by_name(TYPE_DUMMY);
> + ObjectProperty *prop;
> + ObjectPropertyIterator iter;
> + bool seensv = false, seenav = false, seentype;
> +
> + object_class_property_iter_init(&iter, klass);
> + while ((prop = object_property_iter_next(&iter))) {
> + if (g_str_equal(prop->name, "sv")) {
> + seensv = true;
> + } else if (g_str_equal(prop->name, "av")) {
> + seenav = true;
> + } else if (g_str_equal(prop->name, "type")) {
> + /* This prop comes from the base Object class */
> + seentype = true;
> + } else {
> + g_printerr("Found prop '%s'\n", prop->name);
> + g_assert_not_reached();
> + }
> + }
> + g_assert(seenav);
> + g_assert(seensv);
> + g_assert(seentype);
> +}
> +
> +
> static void test_dummy_delchild(void)
> {
> Object *parent = object_get_objects_root();
> @@ -524,6 +551,7 @@ int main(int argc, char **argv)
> g_test_add_func("/qom/proplist/badenum", test_dummy_badenum);
> g_test_add_func("/qom/proplist/getenum", test_dummy_getenum);
> g_test_add_func("/qom/proplist/iterator", test_dummy_iterator);
> + g_test_add_func("/qom/proplist/class_iterator", test_dummy_class_iterator);
> g_test_add_func("/qom/proplist/delchild", test_dummy_delchild);
>
> return g_test_run();
next prev parent reply other threads:[~2016-10-27 15:34 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 16:30 [Qemu-devel] [PATCH v3 0/8] qdev class properties + abstract class support on device-list-properties Eduardo Habkost
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 1/8] tests: check-qom-proplist: Remove duplicate "bv" property Eduardo Habkost
2016-10-27 14:13 ` Igor Mammedov
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 2/8] tests: check-qom-proplist: Use &error_abort to catch errors Eduardo Habkost
2016-10-27 14:16 ` Igor Mammedov
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 3/8] qdev: device_class_set_props() function Eduardo Habkost
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 4/8] qdev: Extract property-default code to qdev_property_set_to_default() Eduardo Habkost
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 5/8] qdev: Register static properties as class properties Eduardo Habkost
2016-10-27 14:51 ` Igor Mammedov
2016-10-27 14:57 ` Eduardo Habkost
2016-10-27 15:30 ` Igor Mammedov
2016-10-27 16:37 ` Eduardo Habkost
2016-10-29 14:00 ` Igor Mammedov
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 6/8] qom: object_class_property_iter_init() function Eduardo Habkost
2016-10-27 15:34 ` Igor Mammedov [this message]
2016-10-27 16:49 ` Eduardo Habkost
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 7/8] qmp: Support abstract classes on device-list-properties Eduardo Habkost
2016-10-26 16:30 ` [Qemu-devel] [PATCH v3 8/8] qdev: Warning about using object_class_property_add() in new code Eduardo Habkost
2016-10-26 16:48 ` Peter Maydell
2016-10-26 16:57 ` Eduardo Habkost
2016-10-26 17:57 ` Peter Maydell
2016-10-26 19:36 ` Eduardo Habkost
2016-10-27 19:48 ` [Qemu-devel] [PATCH v3 0/8] qdev class properties + abstract class support on device-list-properties Eduardo Habkost
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=20161027173445.4cae7fe3@nial.brq.redhat.com \
--to=imammedo@redhat.com \
--cc=afaerber@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=ehabkost@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).