qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: Markus Armbruster <armbru@redhat.com>, Greg Kurz <groug@kaod.org>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	qemu-ppc@nongnu.org, qemu-devel@nongnu.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v2 for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object
Date: Mon, 18 Nov 2019 10:51:07 +0100	[thread overview]
Message-ID: <a88d4d7d-f088-1115-6f0c-1b80c9a37743@kaod.org> (raw)
In-Reply-To: <87zhgtwn63.fsf@dusky.pond.sub.org>

On 18/11/2019 10:26, Markus Armbruster wrote:
> Greg Kurz <groug@kaod.org> writes:
> 
>> There's a recurring pattern in the code where a const link is added to a
>> newly instanciated object and the link is then used in the object's realize
>> function to keep a pointer to the QOM entity which the link points to.
>>
>> void create_obj_b(Object *obj_a)
>> {
>>     Object *obj_b;
>>
>>     obj_b = object_new(TYPE_B);
>>     object_property_add_const_link(obj_b, "link-to-a", obj_a, &error_abort);
>>     object_property_set_bool(obj_b, true, "realized", &error_abort);
>> }
>>
>> void object_b_realize(DeviceState *dev, Error **errp)
>> {
>>     Object *obj_a;
>>
>>     obj_a = object_property_get_link(OBJECT(dev), "link-to-a", errp);
>>     if (!obj_a) {
>>         return;
>>     }
>>
>>     obj_b->obj_a = A(obj_a); // If obj_b->obj_a is changed, the link property
>>                              // still points to the original obj_a that was
>>                              // passed to object_property_add_const_link()
>> }
>>
>> Confusing bugs could arise if the pointer and the link go out of sync for
>> some reason. This can be avoided if the property is defined to directly use
>> the pointer with the DEFINE_PROP_LINK() macro.
>>
>> This series just does that for all occurences of the fragile pattern in
>> the XIVE and PNV code.
> 
> Have you looked for the pattern elsewhere?

I can take care of the Aspeed machine. I followed the same pattern there.

C.



  reply	other threads:[~2019-11-18  9:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 15:55 [PATCH v2 for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 1/8] xive: Link "cpu" property to XiveTCTX::cs pointer Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 2/8] xive: Link "xive" property to XiveSource::xive pointer Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 3/8] xive: Link "xive" property to XiveEndSource::xrtr pointer Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 4/8] ppc/pnv: Link "psi" property to PnvLpc::psi pointer Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 5/8] ppc/pnv: Link "psi" property to PnvOCC::psi pointer Greg Kurz
2019-11-15 15:55 ` [PATCH v2 for-5.0 6/8] ppc/pnv: Link "chip" property to PnvHomer::chip pointer Greg Kurz
2019-11-15 15:56 ` [PATCH v2 for-5.0 7/8] ppc/pnv: Link "chip" property to PnvCore::chip pointer Greg Kurz
2019-11-15 15:56 ` [PATCH v2 for-5.0 8/8] ppc/pnv: Link "chip" property to PnvXive::chip pointer Greg Kurz
2019-11-16  1:28 ` [PATCH v2 for-5.0 0/8] ppc: Consolidate QOM links and pointers to the same object David Gibson
2019-11-18  9:26 ` Markus Armbruster
2019-11-18  9:51   ` Cédric Le Goater [this message]
2019-11-18 11:01   ` Greg Kurz

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=a88d4d7d-f088-1115-6f0c-1b80c9a37743@kaod.org \
    --to=clg@kaod.org \
    --cc=armbru@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=groug@kaod.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@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).