[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors |
Date: |
Tue, 19 May 2015 18:08:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
Am 19.05.2015 um 17:55 schrieb Daniel P. Berrange:
> On Tue, May 19, 2015 at 05:52:14PM +0200, Andreas Färber wrote:
>> Am 13.05.2015 um 18:14 schrieb Daniel P. Berrange:
>>> +Object *object_new_with_propv(const char *typename,
>>> + Object *parent,
>>> + const char *id,
>>> + Error **errp,
>>> + va_list vargs)
>>> +{
>>> + Object *obj;
>>> + ObjectClass *klass;
>>> + Error *local_err = NULL;
>>> +
>>> + klass = object_class_by_name(typename);
>>> + if (!klass) {
>>> + error_setg(errp, "invalid object type: %s", typename);
>>> + return NULL;
>>> + }
>>> +
>>> + if (object_class_is_abstract(klass)) {
>>> + error_setg(errp, "object type '%s' is abstract", typename);
>>> + return NULL;
>>> + }
>>> + obj = object_new(typename);
>>> +
>>> + if (object_set_propv(obj, &local_err, vargs) < 0) {
>>> + goto error;
>>> + }
>>> +
>>> + object_property_add_child(parent, id, obj, &local_err);
>>> + if (local_err) {
>>> + goto error;
>>> + }
>>> +
>>> + if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
>>> + user_creatable_complete(obj, &local_err);
>>> + if (local_err) {
>>> + object_unparent(obj);
>>> + goto error;
>>> + }
>>> + }
>>> +
>>> + object_unref(OBJECT(obj));
>>> + return obj;
>>
>> This looks fishy. Either we return obj and need to retain a ref for that
>> (caller's responsibility to unref) or we unref it and return void.
>> Or am I misreading the code?
>
> Paolo told me on previous posting that object_property_add_child()
> holds a reference on 'obj' for as long as it is registered in the
> object hierarchy composition. So it sufficient to rely on that long
> term reference, and let the caller dispose of the object by calling
> object_unparent(obj) when finally done.
Heh, that's why I like reviewing my patches myself. That reference can
go away via QMP. For the CPU I have a patch pending to fix some corner
cases. We can do that as follow-up here though.
Regards,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Dilip Upmanyu, Graham Norton; HRB
21284 (AG Nürnberg)
- [Qemu-devel] [PATCH v4 3/8] vl: create (most) objects before creating chardev backends, (continued)
- [Qemu-devel] [PATCH v4 3/8] vl: create (most) objects before creating chardev backends, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 4/8] qom: add helper method for getting user objects root, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 8/8] qom: don't pass string table to object_get_enum method, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 2/8] doc: document user creatable object types in help text, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 6/8] qom: make enum string tables const-correct, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 7/8] qom: add a object_property_add_enum helper method, Daniel P. Berrange, 2015/05/13
- [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Daniel P. Berrange, 2015/05/13
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Andreas Färber, 2015/05/19
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Daniel P. Berrange, 2015/05/19
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors,
Andreas Färber <=
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Paolo Bonzini, 2015/05/19
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Eduardo Habkost, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Daniel P. Berrange, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Andreas Färber, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Eduardo Habkost, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Daniel P. Berrange, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Andreas Färber, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Eduardo Habkost, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Andreas Färber, 2015/05/20
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors, Eduardo Habkost, 2015/05/20