From: Alexander Graf <agraf@suse.de>
To: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Eric Auger" <eric.auger@linaro.org>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
"qemu-ppc Mailing List" <qemu-ppc@nongnu.org>,
"Stalley, Sean" <sean.stalley@intel.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Andreas Färber" <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 2/6] qom: Allow to make integer qom properties writeable
Date: Wed, 02 Jul 2014 09:46:32 +0200 [thread overview]
Message-ID: <53B3B8D8.507@suse.de> (raw)
In-Reply-To: <CAEgOgz6=BJCLw8=_khjbB95GWZe_n--x_f=WNDx-iHMGxGGJPA@mail.gmail.com>
On 02.07.14 05:48, Peter Crosthwaite wrote:
> On Wed, Jul 2, 2014 at 7:49 AM, Alexander Graf <agraf@suse.de> wrote:
>> We have helper functions to easily expose integers as QOM object properties.
>> However, these are read only.
> I think this is a good idea, and _ptr properties should have some write-ability.
>
>> Let's introduce some easy helpers that would
>> just write to the values.
>>
>> We also add a new parameter to the property registration that allows us to
>> specify the setter function. If we need special magic to happen, we can make
>> it happen in our own setters. Otherwise we can just use one of the provided
>> helper setters that implement generic value writes for integers.
>>
>> With this we can easily create read-write qom variables, but maintain the
>> flexibility to diverge slightly from the default case.
>>
> But I think it's inconsistent that the read path is automatic and
> write path required an open-coded callback to be added. If you need
> open-codedness then it can be achieved with just raw
> object_property_set. The real issue is that the other side (e.g. the
> read handler for a side-effected write) will need to be open coded too
> leading to mass boiler plate (is this the problem you are trying to
> solve?).
I was trying to think of a nice middle ground between flexibility that's
needed and flexibility that's required. I think it's very common to have
* read-only properties
* read-write properties
* read-write properties with special handling for the write path
(checks mostly, boundary or permission)
> I think we can minimise the number of core QOM API use cases while
> achieving your goal by:
>
> 1: Leaving the _ptr APIs as minimal having no open-coded capability.
> 2: Adding global trivial getter and setter fns that can be passed to
> the lower level object_property_add.
That'd be an alternative approach - I would just open codedly call
object_property_add with the global helpers then. I'm not sure that's
incredibly nicer though.
In the code flow you describe above, a read-only accessor would be
declared the same way it does today. Read-write ones would already have
to go via object_property_add.
So we either add clumsy code in the actual user files (which we try to
reduce) or we end up adding another set of _rw functions (which is what
I did at first - it's ugly) or we add an enum as parameter (which I did
then, but it's also ugly, see next email).
I'm not passionate about the approach I ended up taking, but I couldn't
think of a better middle ground. If you are passionate about it though I
can easily declare the getters public as well and just use
object_property_add() explicitly.
> When one side of a property (either read or write) has a side effect,
> go open-coded (you can also call the trivial setter/getter from your
> open coded fn for the actual ptr read/write to avoid device code
> having to manage visitors). Then add the trivial setter/getter for the
> other side. LOC should be roughly the same as this soln.
>
> This also supports the rarer case of a property with read side effects
> (can't think of a use case yet but i sure it's out there).
Yeah, I can't really think of too many properties that really should
have read side effects ;).
Alex
next prev parent reply other threads:[~2014-07-02 7:46 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-01 21:49 [Qemu-devel] [PATCH 0/6] Dynamic sysbus device allocation support Alexander Graf
2014-07-01 21:49 ` [Qemu-devel] [PATCH 1/6] qom: macroify integer property helpers Alexander Graf
2014-07-02 3:29 ` Peter Crosthwaite
2014-07-02 7:39 ` Alexander Graf
2014-07-01 21:49 ` [Qemu-devel] [PATCH 2/6] qom: Allow to make integer qom properties writeable Alexander Graf
2014-07-02 3:48 ` Peter Crosthwaite
2014-07-02 7:46 ` Alexander Graf [this message]
2014-07-01 21:49 ` [Qemu-devel] [PATCH 3/6] sysbus: Add user map hints Alexander Graf
2014-07-02 4:12 ` Peter Crosthwaite
2014-07-02 8:24 ` Alexander Graf
2014-07-02 8:26 ` Paolo Bonzini
2014-07-02 9:03 ` Peter Crosthwaite
2014-07-02 9:07 ` Alexander Graf
2014-07-02 9:17 ` Paolo Bonzini
2014-07-02 9:19 ` Alexander Graf
2014-07-02 9:26 ` Paolo Bonzini
2014-07-01 21:49 ` [Qemu-devel] [PATCH 4/6] sysbus: Make devices spawnable via -device Alexander Graf
2014-07-02 6:32 ` Paolo Bonzini
2014-07-02 15:36 ` Alexander Graf
2014-07-01 21:49 ` [Qemu-devel] [PATCH 5/6] PPC: e500: Support dynamically spawned sysbus devices Alexander Graf
2014-07-01 22:50 ` Scott Wood
2014-07-02 17:12 ` Alexander Graf
2014-07-02 17:26 ` Scott Wood
2014-07-02 17:30 ` Alexander Graf
2014-07-02 17:52 ` Scott Wood
2014-07-02 17:59 ` Alexander Graf
2014-07-02 19:34 ` Scott Wood
2014-07-02 20:59 ` Alexander Graf
2014-07-01 21:49 ` [Qemu-devel] [PATCH 6/6] e500: Add support for eTSEC in device tree Alexander Graf
2014-07-01 22:56 ` Scott Wood
2014-07-02 17:24 ` Alexander Graf
2014-07-02 17:32 ` Scott Wood
2014-07-02 17:34 ` Alexander Graf
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=53B3B8D8.507@suse.de \
--to=agraf@suse.de \
--cc=afaerber@suse.de \
--cc=eric.auger@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=sean.stalley@intel.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.