diff mbox series

[RFC,1/5] qom: preserve get/set presence in aliased properties

Message ID 20181214165657.749-2-rkagan@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series expose negotiated virtio features in r/o properties | expand

Commit Message

Roman Kagan Dec. 14, 2018, 4:57 p.m. UTC
Usually in order to tell if a property is read-only, write-only, or
read-write, one has to look at whether it has .get or .set methods.

However, property aliases are always defined with both, and it's not
until the call to the getter or setter when the support for the
corresponding operation can be found out.

To make it easier to determine if an operation is supported for an alias
property, only assign it getter and setter if the target property has
the corresponding method.

Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/qom/object.c b/qom/object.c
index 17921c0a71..b362ebab19 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -2382,8 +2382,8 @@  void object_property_add_alias(Object *obj, const char *name,
     prop->target_name = g_strdup(target_name);
 
     op = object_property_add(obj, name, prop_type,
-                             property_get_alias,
-                             property_set_alias,
+                             target_prop->get ? property_get_alias : NULL,
+                             target_prop->set ? property_set_alias : NULL,
                              property_release_alias,
                              prop, &local_err);
     if (local_err) {