From: "Daniel P. Berrange" <berrange@redhat.com>
To: "Andreas Färber" <afaerber@suse.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v3 6/7] qom: add a object_property_add_enum helper method
Date: Tue, 12 May 2015 17:53:11 +0100 [thread overview]
Message-ID: <20150512165310.GQ18200@redhat.com> (raw)
In-Reply-To: <554CF626.5000009@suse.de>
On Fri, May 08, 2015 at 07:45:10PM +0200, Andreas Färber wrote:
> Am 01.05.2015 um 12:30 schrieb Daniel P. Berrange:
>
> Looks good in general. Some minor nits below, and one limitation
> possibly worth mentioning in the second paragraph of the commit message:
> It assumes a 1:1 mapping. I do guess most ones are, but I remember some
> CPUID bits having different names for the same values, for instance.
Worst case, in that edge case, we can simply not use this stricter
enum property type - just carry on with existing custom property
> > diff --git a/include/qom/object.h b/include/qom/object.h
> > index bf76f7a..f6a2a9d 100644
> > --- a/include/qom/object.h
> > +++ b/include/qom/object.h
> > @@ -1271,6 +1271,25 @@ void object_property_add_bool(Object *obj, const char *name,
> > Error **errp);
> >
> > /**
> > + * object_property_add_enum:
> > + * @obj: the object to add a property to
> > + * @name: the name of the property
> > + * @typename: the name of the enum data type
> > + * @get: the getter or NULL if the property is write-only.
>
> %NULL
>
> > + * @set: the setter or NULL if the property is read-only
> > + * @errp: if an error occurs, a pointer to an area to store the error
> > + *
> > + * Add a enum property using getters/setters. This function will add a
> > + * property of type 'enum'.
>
> This is slightly ambiguous, as I understand it the type we're actually
> using is the one in @typename, not "enum"?
Yeah, you are right - this doc mistake is left over from a previous
version before Paolo asked me to add the @typename parameter.
> > diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c
> > index 9f16cdb..de142e3 100644
> > --- a/tests/check-qom-proplist.c
> > +++ b/tests/check-qom-proplist.c
> > @@ -32,10 +32,28 @@ typedef struct DummyObjectClass DummyObjectClass;
> > #define DUMMY_OBJECT(obj) \
> > OBJECT_CHECK(DummyObject, (obj), TYPE_DUMMY)
> >
> > +typedef enum DummyAnimal DummyAnimal;
> > +
> > +enum DummyAnimal {
> > + DUMMY_FROG,
> > + DUMMY_ALLIGATOR,
> > + DUMMY_PLATYPUS,
> > +
> > + DUMMY_LAST,
> > +};
> > +
> > +static const char *const dummyanimalmap[DUMMY_LAST + 1] = {
>
> dummy_animal_map would be slightly easier to read.
Sure
> > +static void test_dummy_badenum(void)
> > +{
> > + Error *err = NULL;
> > + Object *parent = container_get(object_get_root(),
> > + "/objects");
> > + DummyObject *dobj = DUMMY_OBJECT(
> > + object_new_propv(TYPE_DUMMY,
> > + parent,
> > + "dummy0",
> > + &err,
> > + "bv", "yes",
> > + "sv", "Hiss hiss hiss",
> > + "av", "yeti",
> > + NULL));
> > +
> > + g_assert(dobj == NULL);
>
> Superfluous.
>
> > + g_assert(err != NULL);
> > + g_assert(g_str_equal(error_get_pretty(err),
> > + "Invalid parameter 'yeti'"));
>
> Same question as in previous test: alternatives?
Yep, will check
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
next prev parent reply other threads:[~2015-05-12 16:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-01 10:29 [Qemu-devel] [PATCH v3 0/7] qom: misc fixes & enhancements to support TLS work Daniel P. Berrange
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 1/7] qom: fix typename of 'policy' enum property in hostmem obj Daniel P. Berrange
2015-05-08 14:28 ` Andreas Färber
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 2/7] qom: document user creatable object types in help text Daniel P. Berrange
2015-05-08 14:31 ` Andreas Färber
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 3/7] qom: create objects in two phases Daniel P. Berrange
2015-05-08 14:37 ` Andreas Färber
2015-05-08 14:40 ` Paolo Bonzini
2015-05-12 16:55 ` Daniel P. Berrange
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 4/7] qom: add object_new_propv / object_new_proplist constructors Daniel P. Berrange
2015-05-08 17:10 ` Andreas Färber
2015-05-08 17:18 ` Paolo Bonzini
2015-05-08 17:22 ` Andreas Färber
2015-05-08 20:16 ` Eric Blake
2015-05-12 16:49 ` Daniel P. Berrange
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 5/7] qom: make enum string tables const-correct Daniel P. Berrange
2015-05-08 17:19 ` Andreas Färber
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 6/7] qom: add a object_property_add_enum helper method Daniel P. Berrange
2015-05-08 17:45 ` Andreas Färber
2015-05-12 16:53 ` Daniel P. Berrange [this message]
2015-05-01 10:30 ` [Qemu-devel] [PATCH v3 7/7] qom: don't pass string table to object_get_enum method Daniel P. Berrange
2015-05-08 17:54 ` Andreas Färber
2015-05-12 16:54 ` Daniel P. Berrange
2015-05-05 10:33 ` [Qemu-devel] [PATCH v3 0/7] qom: misc fixes & enhancements to support TLS work Paolo Bonzini
2015-05-05 15:37 ` Andreas Färber
2015-05-08 12:31 ` Paolo Bonzini
2015-05-08 12:34 ` Andreas Färber
2015-05-08 14:20 ` Paolo Bonzini
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=20150512165310.GQ18200@redhat.com \
--to=berrange@redhat.com \
--cc=afaerber@suse.de \
--cc=pbonzini@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).