mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
qdev: Introduce DEFINE_PROP_LINK
This property can be used to replace the object_property_add_link in device code, to add a link to other objects, which is a common pattern. Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <20170714021509.23681-4-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
faabdbb792
commit
5b4ff3c661
3 changed files with 28 additions and 0 deletions
|
@ -1214,3 +1214,21 @@ PropertyInfo qdev_prop_size = {
|
|||
.set = set_size,
|
||||
.set_default_value = set_default_value_uint,
|
||||
};
|
||||
|
||||
/* --- object link property --- */
|
||||
|
||||
static void create_link_property(Object *obj, Property *prop, Error **errp)
|
||||
{
|
||||
Object **child = qdev_get_prop_ptr(DEVICE(obj), prop);
|
||||
|
||||
object_property_add_link(obj, prop->name, prop->link_type,
|
||||
child,
|
||||
qdev_prop_allow_set_link_before_realize,
|
||||
OBJ_PROP_LINK_UNREF_ON_RELEASE,
|
||||
errp);
|
||||
}
|
||||
|
||||
PropertyInfo qdev_prop_link = {
|
||||
.name = "link",
|
||||
.create = create_link_property,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue