diff mbox

[qom,v1,1/1] qom: object: remove parent pointer when unparenting

Message ID 97a5753d0e2e5d8ce43730fb0d8595ceb69261a9.1401151094.git.peter.crosthwaite@xilinx.com
State New
Headers show

Commit Message

Peter Crosthwaite May 27, 2014, 12:39 a.m. UTC
Certain parts of the QOM framework test this pointer to determine if
an object is parented. Nuke it when the object is unparented to allow
for reuse of an object after unparenting.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---

 qom/object.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Peter Crosthwaite June 2, 2014, 12:35 a.m. UTC | #1
Ping!

On Tue, May 27, 2014 at 10:39 AM, Peter Crosthwaite
<peter.crosthwaite@xilinx.com> wrote:
> Certain parts of the QOM framework test this pointer to determine if
> an object is parented. Nuke it when the object is unparented to allow
> for reuse of an object after unparenting.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
>
>  qom/object.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/qom/object.c b/qom/object.c
> index e42b254..8319e89 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>      if (obj->parent) {
>          object_property_del_child(obj->parent, obj, NULL);
>      }
> +    obj->parent = NULL;
>      object_unref(obj);
>  }
>
> --
> 1.9.3.1.ga73a6ad
>
Stefan Hajnoczi June 4, 2014, 8:21 a.m. UTC | #2
On Mon, Jun 02, 2014 at 10:35:30AM +1000, Peter Crosthwaite wrote:
> Ping!

Andreas seems to be offline (vacation?).  I'm sure he'll see this when
he gets back.

Stefan
Andreas Färber June 11, 2014, 8:13 a.m. UTC | #3
Am 27.05.2014 02:39, schrieb Peter Crosthwaite:
> Certain parts of the QOM framework test this pointer to determine if
> an object is parented. Nuke it when the object is unparented to allow
> for reuse of an object after unparenting.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> 
>  qom/object.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/qom/object.c b/qom/object.c
> index e42b254..8319e89 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>      if (obj->parent) {
>          object_property_del_child(obj->parent, obj, NULL);
>      }
> +    obj->parent = NULL;
>      object_unref(obj);
>  }
>  

This looks okay to me, and it might also help the segfault on hot-unplug
Stefan and Kevin reported before I went on travels.

Any objection to moving this one line up into the if?

Regards,
Andreas
Peter Crosthwaite June 11, 2014, 10:19 a.m. UTC | #4
On Wed, Jun 11, 2014 at 6:13 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 27.05.2014 02:39, schrieb Peter Crosthwaite:
>> Certain parts of the QOM framework test this pointer to determine if
>> an object is parented. Nuke it when the object is unparented to allow
>> for reuse of an object after unparenting.
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>>
>>  qom/object.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index e42b254..8319e89 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>>      if (obj->parent) {
>>          object_property_del_child(obj->parent, obj, NULL);
>>      }
>> +    obj->parent = NULL;
>>      object_unref(obj);
>>  }
>>
>
> This looks okay to me, and it might also help the segfault on hot-unplug
> Stefan and Kevin reported before I went on travels.
>

Welcome back.

> Any objection to moving this one line up into the if?
>

No problem. Will respin.

Regards,
Peter

> Regards,
> Andreas
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>
Andreas Färber June 11, 2014, 11:28 a.m. UTC | #5
Am 11.06.2014 12:19, schrieb Peter Crosthwaite:
> On Wed, Jun 11, 2014 at 6:13 PM, Andreas Färber <afaerber@suse.de> wrote:
>> Am 27.05.2014 02:39, schrieb Peter Crosthwaite:
>>> Certain parts of the QOM framework test this pointer to determine if
>>> an object is parented. Nuke it when the object is unparented to allow
>>> for reuse of an object after unparenting.
>>>
>>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>> ---
>>>
>>>  qom/object.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/qom/object.c b/qom/object.c
>>> index e42b254..8319e89 100644
>>> --- a/qom/object.c
>>> +++ b/qom/object.c
>>> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>>>      if (obj->parent) {
>>>          object_property_del_child(obj->parent, obj, NULL);
>>>      }
>>> +    obj->parent = NULL;
>>>      object_unref(obj);
>>>  }
>>>
>>
>> This looks okay to me, and it might also help the segfault on hot-unplug
>> Stefan and Kevin reported before I went on travels.
>>
> 
> Welcome back.
> 
>> Any objection to moving this one line up into the if?
>>
> 
> No problem. Will respin.

I've done so myself, but now I wonder why we are checking obj->parent at
all there after we already return if !obj->parent? Is this to guard
against ObjectClass::unparent() changing Object::parent? Either way, the
two variants you posted and I suggested should be fine.

Regards,
Andreas
Paolo Bonzini June 11, 2014, 11:33 a.m. UTC | #6
Il 11/06/2014 13:28, Andreas Färber ha scritto:
> Am 11.06.2014 12:19, schrieb Peter Crosthwaite:
>> On Wed, Jun 11, 2014 at 6:13 PM, Andreas Färber <afaerber@suse.de> wrote:
>>> Am 27.05.2014 02:39, schrieb Peter Crosthwaite:
>>>> Certain parts of the QOM framework test this pointer to determine if
>>>> an object is parented. Nuke it when the object is unparented to allow
>>>> for reuse of an object after unparenting.
>>>>
>>>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>>> ---
>>>>
>>>>  qom/object.c | 1 +
>>>>  1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/qom/object.c b/qom/object.c
>>>> index e42b254..8319e89 100644
>>>> --- a/qom/object.c
>>>> +++ b/qom/object.c
>>>> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>>>>      if (obj->parent) {
>>>>          object_property_del_child(obj->parent, obj, NULL);
>>>>      }
>>>> +    obj->parent = NULL;
>>>>      object_unref(obj);
>>>>  }
>>>>
>>>
>>> This looks okay to me, and it might also help the segfault on hot-unplug
>>> Stefan and Kevin reported before I went on travels.
>>>
>>
>> Welcome back.
>>
>>> Any objection to moving this one line up into the if?
>>>
>>
>> No problem. Will respin.
>
> I've done so myself, but now I wonder why we are checking obj->parent at
> all there after we already return if !obj->parent? Is this to guard
> against ObjectClass::unparent() changing Object::parent? Either way, the
> two variants you posted and I suggested should be fine.

Yes, in case unparent might already end up removing the property.

I have a patch that moves the unparent call to 
object_finalize_child_property and only removes the property here.  The 
patch would apply anyway, so I'm okay with it.

Paolo
Peter Crosthwaite June 11, 2014, 11:52 a.m. UTC | #7
On Wed, Jun 11, 2014 at 9:28 PM, Andreas Färber <afaerber@suse.de> wrote:
> Am 11.06.2014 12:19, schrieb Peter Crosthwaite:
>> On Wed, Jun 11, 2014 at 6:13 PM, Andreas Färber <afaerber@suse.de> wrote:
>>> Am 27.05.2014 02:39, schrieb Peter Crosthwaite:
>>>> Certain parts of the QOM framework test this pointer to determine if
>>>> an object is parented. Nuke it when the object is unparented to allow
>>>> for reuse of an object after unparenting.
>>>>
>>>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>>>> ---
>>>>
>>>>  qom/object.c | 1 +
>>>>  1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/qom/object.c b/qom/object.c
>>>> index e42b254..8319e89 100644
>>>> --- a/qom/object.c
>>>> +++ b/qom/object.c
>>>> @@ -402,6 +402,7 @@ void object_unparent(Object *obj)
>>>>      if (obj->parent) {
>>>>          object_property_del_child(obj->parent, obj, NULL);
>>>>      }
>>>> +    obj->parent = NULL;
>>>>      object_unref(obj);
>>>>  }
>>>>
>>>
>>> This looks okay to me, and it might also help the segfault on hot-unplug
>>> Stefan and Kevin reported before I went on travels.
>>>
>>
>> Welcome back.
>>
>>> Any objection to moving this one line up into the if?
>>>
>>
>> No problem. Will respin.
>
> I've done so myself, but now I wonder why we are checking obj->parent at
> all there after we already return if !obj->parent? Is this to guard
> against ObjectClass::unparent() changing Object::parent? Either way, the
> two variants you posted and I suggested should be fine.
>

Ok will leave it with you. Thanks.

Regards,
Peter

> Regards,
> Andreas
>
> --
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
>
diff mbox

Patch

diff --git a/qom/object.c b/qom/object.c
index e42b254..8319e89 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -402,6 +402,7 @@  void object_unparent(Object *obj)
     if (obj->parent) {
         object_property_del_child(obj->parent, obj, NULL);
     }
+    obj->parent = NULL;
     object_unref(obj);
 }