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>
This commit is contained in:
parent
ee512c6f21
commit
67cc7e0aac
@ -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)
|
static bool device_get_realized(Object *obj, Error **errp)
|
||||||
{
|
{
|
||||||
DeviceState *dev = DEVICE(obj);
|
DeviceState *dev = DEVICE(obj);
|
||||||
|
@ -193,6 +193,8 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
|
|||||||
*/
|
*/
|
||||||
void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
|
void qdev_property_add_static(DeviceState *dev, Property *prop, Error **errp);
|
||||||
|
|
||||||
|
void qdev_alias_all_properties(DeviceState *target, Object *source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @qdev_prop_set_after_realize:
|
* @qdev_prop_set_after_realize:
|
||||||
* @dev: device
|
* @dev: device
|
||||||
|
Loading…
Reference in New Issue
Block a user