[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: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors |
Date: |
Tue, 19 May 2015 18:11:05 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 |
On 19/05/2015 17:55, Daniel P. Berrange wrote:
> 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.
For an example of the same pattern:
DeviceState *qdev_try_create(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
if (!bus) {
bus = sysbus_get_default();
}
qdev_set_parent_bus(dev, bus);
object_unref(OBJECT(dev));
return dev;
}
Effectively this is idea as GObject's "floating reference".
qdev_set_parent_bus (in qdev_try_create) and object_property_add_child
(in Daniel's patches) "sink" the floating reference by doing
object_unref. If we had floating references, the object would be
returned to the caller unref'ed anyway.
Of course, the reference can go away via QMP. But that will only happen
after the caller would have called object_unref itself.
Paolo
- [Qemu-devel] [PATCH v4 4/8] qom: add helper method for getting user objects root, (continued)
- [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, 2015/05/19
- Re: [Qemu-devel] [PATCH v4 5/8] qom: add object_new_with_props / object_new_withpropv constructors,
Paolo Bonzini <=
- 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