summaryrefslogtreecommitdiffstats
path: root/hw/core/qdev-properties.c
diff options
context:
space:
mode:
authorFam Zheng2017-07-14 04:14:52 +0200
committerPaolo Bonzini2017-07-14 12:04:42 +0200
commit5b4ff3c661374b2df247e12b58667e4643b30af1 (patch)
tree96beea107bb99a102dbbb423e061d841adf788a5 /hw/core/qdev-properties.c
parentqdev: Introduce PropertyInfo.create (diff)
downloadqemu-5b4ff3c661374b2df247e12b58667e4643b30af1.tar.gz
qemu-5b4ff3c661374b2df247e12b58667e4643b30af1.tar.xz
qemu-5b4ff3c661374b2df247e12b58667e4643b30af1.zip
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>
Diffstat (limited to 'hw/core/qdev-properties.c')
-rw-r--r--hw/core/qdev-properties.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 113ce7df46..5429c63e23 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -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,
+};