qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Eduardo Habkost" <ehabkost@redhat.com>,
	"Pratik Parvati" <pratikp@vayavyalabs.com>,
	qemu-devel@nongnu.org
Subject: Re: sysbus_create_simple Vs qdev_create
Date: Thu, 30 Jul 2020 15:38:18 +0200	[thread overview]
Message-ID: <f024c884-bf7d-e098-2664-64a847dd97d8@redhat.com> (raw)
In-Reply-To: <87zh7hxjqa.fsf@dusky.pond.sub.org>

On 30/07/20 14:36, Markus Armbruster wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> On 30/07/20 12:03, Markus Armbruster wrote:
>>> qdev C layer:
>>>
>>>     frob->prop = 42;
>>>
>>> Least cognitive load.
>>>
>>> QOM has no C layer.
>>
>> Not really, a QOM object is totally free to do frob->prop = 42.  And
>> just like we didn't do that outside device implementation in qdev as our
>> tithe to the Church of Information Hiding; the same applies to QOM.
> 
> I screwed up the part of my argument that actually has a hope to be
> valid, let me try again.
> 
> With qdev, you can always do frob->prop = 42, because properties are
> always backed by a struct member.
> 
> With QOM, properties are built around visitor-based getters and setters.
> This means you can always do (but never actually would do) something
> like
> 
>     fortytwo = qnum_from_int(42);
>     v = qobject_input_visitor_new(fortytwo);
>     set_prop(OBJECT(frob), v, "prop", cookie, &err);
>     visit_free(v);
>     qobject_unref(fortytwo);
> 
> where set_prop() is the setter you passed to object_property_add(), and
> @cookie is the opaque value you passed along with it.
> 
> *Maybe* set_prop() wraps around a simpler setter you can call directly,
> or even a struct member you can set directy.  QOM does not care.
> 
> And that's my point: QOM does not care for the C layer.

Ok, I think I got it.  In practice it depends on how much you want to
hide the implementation of the properties and (especially for
set-only-before-realize properties) the answer will be "not at all
inside the device implementation".  So inside the implementation you can
always break the information hiding layer if needed (usually for
performance or as you point out sanity), and I don't think there is a
substantial difference between qdev and QOM.

But yeah, I'm willing to concede that QOM the QAPI-- layer of QOM comes
first and the C layer comes second. :)

Paolo



  reply	other threads:[~2020-07-30 13:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 16:09 sysbus_create_simple Vs qdev_create Pratik Parvati
2020-07-14 16:17 ` Pratik Parvati
2020-07-14 17:02   ` Philippe Mathieu-Daudé
2020-07-15  8:32     ` Markus Armbruster
2020-07-15 13:58       ` Pratik Parvati
2020-07-15 14:11         ` Peter Maydell
2020-07-15 14:37         ` Markus Armbruster
2020-07-16 22:21           ` Eduardo Habkost
2020-07-17  5:10             ` Markus Armbruster
2020-07-17 16:23               ` Eduardo Habkost
2020-07-17 16:30                 ` Daniel P. Berrangé
2020-07-17 17:15                   ` Peter Maydell
2020-07-20  7:39                     ` Markus Armbruster
2020-07-20  7:38                 ` Markus Armbruster
2020-07-20 15:59                   ` Eduardo Habkost
2020-07-21  6:00                     ` Markus Armbruster
2020-07-27 14:29                       ` Paolo Bonzini
2020-07-28  7:19                         ` Markus Armbruster
2020-07-28 17:38                           ` Paolo Bonzini
2020-07-28 22:47                             ` Eduardo Habkost
2020-07-29  9:54                               ` Paolo Bonzini
2020-07-29 13:18                                 ` Markus Armbruster
2020-07-29 16:08                                   ` Paolo Bonzini
2020-07-30 10:03                                     ` Markus Armbruster
2020-07-30 11:09                                       ` Paolo Bonzini
2020-07-30 12:36                                         ` Markus Armbruster
2020-07-30 13:38                                           ` Paolo Bonzini [this message]
2020-07-29 14:32                                 ` Eduardo Habkost
2020-07-29 16:01                                   ` Paolo Bonzini
2020-07-29 16:08                                     ` Eduardo Habkost
2020-07-29 16:14                                       ` Paolo Bonzini
2020-07-29  7:46                             ` Markus Armbruster

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=f024c884-bf7d-e098-2664-64a847dd97d8@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=philmd@redhat.com \
    --cc=pratikp@vayavyalabs.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).