diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2014-06-18 17:58:32 +0800 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2014-07-01 09:15:02 +0200 |
commit | 67cc7e0aaca835ed68cf3bd34f4d51a21232792f (patch) | |
tree | 1db022a67f3f1899a5dd5ee1c90412dfb836772c /hw/core/qdev.c | |
parent | ee512c6f21b2f76ae923e3a4cabbd58899ff7ae1 (diff) |
qdev: add qdev_alias_all_properties()
The qdev_alias_all_properties() function creates QOM alias properties
for each qdev property on a DeviceState. This is useful for parent
objects that wish to forward property accesses to their children.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Diffstat (limited to 'hw/core/qdev.c')
-rw-r--r-- | hw/core/qdev.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/hw/core/qdev.c b/hw/core/qdev.c index d1eba3cc3d..732e7294c2 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -780,6 +780,27 @@ void qdev_property_add_static(DeviceState *dev, Property *prop, } } +/* @qdev_alias_all_properties - Add alias properties to the source object for + * all qdev properties on the target DeviceState. + */ +void qdev_alias_all_properties(DeviceState *target, Object *source) +{ + ObjectClass *class; + Property *prop; + + class = object_get_class(OBJECT(target)); + do { + DeviceClass *dc = DEVICE_CLASS(class); + + for (prop = dc->props; prop && prop->name; prop++) { + object_property_add_alias(source, prop->name, + OBJECT(target), prop->name, + &error_abort); + } + class = object_class_get_parent(class); + } while (class != object_class_by_name(TYPE_DEVICE)); +} + static bool device_get_realized(Object *obj, Error **errp) { DeviceState *dev = DEVICE(obj); |