On Tue, Aug 14, 2012 at 10:50 PM, Anthony Liguori <aligu...@us.ibm.com> wrote:
> "Peter A. G. Crosthwaite" <peter.crosthwa...@petalogix.com> writes:
>
>> Hi All. A couple of times now ive had debug issues due to silent failure of
>> object_property_set. This function silently fails if the requested property
>> does not exist for the target object. To trap this error I applied the patch
>> below to my tree, but I am assuming that this is not mergeable as is as im
>> guessing there are clients out there that are speculatively trying to set 
>> props.
>>
>> Could someone confirm the expected policy here? is setting a non-existant
>> property supposed to be a no-op (as it currently is) or should it fail
>> gracefully?
>
> Are you calling set via object_property_set_[str,int,bool,...]?

object_propert_set_link()
>
> Why don't you add a terminal error to those functions if setting fails and 
> errp
> is NULL.
>

That all works. Thanks for the help.

Do we want no consider adding no_fail() versions of these functions
though? It could get tedious is machine models have to have an
assertion call after every object property set just to check the
property exists. Here's my code as it stands:

Error *errp = NULL;
object_property_set_link(OBJECT(dev), OBJECT(cpus[0]), "cpu0", &errp);
assert_no_error(errp);

Regards,
Peter

> Regards,
>
> Anthony Liguori
>
>>
>> Whats the best meachinism for creating a no_fail version of 
>> object_property_set,
>> for the 90% case where a non-existant property is an error in machine model
>> development?
>>
>> Signed-off-by: Peter A. G. Crosthwaite <peter.crosthwa...@petalogix.com>
>> ---
>>  qom/object.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index a552be2..6e875a8 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -687,7 +687,7 @@ void object_property_set(Object *obj, Visitor *v, const 
>> char *name,
>>  {
>>      ObjectProperty *prop = object_property_find(obj, name, errp);
>>      if (prop == NULL) {
>> -        return;
>> +        abort();
>>      }
>>
>>      if (!prop->set) {
>> --
>> 1.7.0.4
>

Reply via email to