Patchwork [10/16] qom: release previous object when setting

login
register
mail settings
Submitter Corey Minyard
Date July 15, 2012, 8:25 p.m.
Message ID <1342383911-6094-10-git-send-email-minyard@acm.org>
Download mbox | patch
Permalink /patch/171090/
State New
Headers show

Comments

Corey Minyard - July 15, 2012, 8:25 p.m.
From: Corey Minyard <cminyard@mvista.com>

When setting an object, if you don't release the previous object
that was there, it may become unusable.  This change allows a
chardev to be removed from one object's properties and added to
another's.
---
 qom/object.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
Paolo Bonzini - July 16, 2012, 6:24 a.m.
Il 15/07/2012 22:25, minyard@acm.org ha scritto:
> From: Corey Minyard <cminyard@mvista.com>
> 
> When setting an object, if you don't release the previous object
> that was there, it may become unusable.  This change allows a
> chardev to be removed from one object's properties and added to
> another's.
> ---
>  qom/object.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 00bb3b0..484dc77 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -731,6 +731,8 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
>      if (!prop->set) {
>          error_set(errp, QERR_PERMISSION_DENIED);
>      } else {
> +	if (prop->release)
> +	    prop->release(obj, name, prop->opaque);
>          prop->set(obj, v, prop->opaque, name, errp);
>      }
>  }
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

... but you need to run scripts/checkpatch.pl on your patches to conform
to coding style.

Thanks!

Paolo
Corey Minyard - July 17, 2012, 12:07 a.m.
On 07/16/2012 01:24 AM, Paolo Bonzini wrote:
> Il 15/07/2012 22:25, minyard@acm.org ha scritto:
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> When setting an object, if you don't release the previous object
>> that was there, it may become unusable.  This change allows a
>> chardev to be removed from one object's properties and added to
>> another's.
>> ---
>>   qom/object.c |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index 00bb3b0..484dc77 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -731,6 +731,8 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
>>       if (!prop->set) {
>>           error_set(errp, QERR_PERMISSION_DENIED);
>>       } else {
>> +	if (prop->release)
>> +	    prop->release(obj, name, prop->opaque);
>>           prop->set(obj, v, prop->opaque, name, errp);
>>       }
>>   }
>>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
>
> ... but you need to run scripts/checkpatch.pl on your patches to conform
> to coding style.
Ok.  I'm running everything through the script.  I didn't realize the 
coding standard was that different from Linux.

Thanks,

-corey

Patch

diff --git a/qom/object.c b/qom/object.c
index 00bb3b0..484dc77 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -731,6 +731,8 @@  void object_property_set(Object *obj, Visitor *v, const char *name,
     if (!prop->set) {
         error_set(errp, QERR_PERMISSION_DENIED);
     } else {
+	if (prop->release)
+	    prop->release(obj, name, prop->opaque);
         prop->set(obj, v, prop->opaque, name, errp);
     }
 }