Loading hw/qdev.c +26 −0 Original line number Diff line number Diff line Loading @@ -1174,6 +1174,32 @@ DeviceState *qdev_get_root(void) return qdev_root; } static void qdev_get_child_property(DeviceState *dev, Visitor *v, void *opaque, const char *name, Error **errp) { DeviceState *child = opaque; gchar *path; path = qdev_get_canonical_path(child); visit_type_str(v, &path, name, errp); g_free(path); } void qdev_property_add_child(DeviceState *dev, const char *name, DeviceState *child, Error **errp) { gchar *type; type = g_strdup_printf("child<%s>", child->info->name); qdev_property_add(dev, name, type, qdev_get_child_property, NULL, NULL, child, errp); qdev_ref(child); g_free(type); } static gchar *qdev_get_path_in(DeviceState *parent, DeviceState *dev) { DeviceProperty *prop; Loading hw/qdev.h +20 −0 Original line number Diff line number Diff line Loading @@ -527,4 +527,24 @@ gchar *qdev_get_canonical_path(DeviceState *dev); */ DeviceState *qdev_resolve_path(const char *path, bool *ambiguous); /** * @qdev_property_add_child - Add a child property to a device * * Child properties form the composition tree. All devices need to be a child * of another device. Devices can only be a child of one device. * * There is no way for a child to determine what its parent is. It is not * a bidirectional relationship. This is by design. * * @dev - the device to add a property to * * @name - the name of the property * * @child - the child device * * @errp - if an error occurs, a pointer to an area to store the area */ void qdev_property_add_child(DeviceState *dev, const char *name, DeviceState *child, Error **errp); #endif Loading
hw/qdev.c +26 −0 Original line number Diff line number Diff line Loading @@ -1174,6 +1174,32 @@ DeviceState *qdev_get_root(void) return qdev_root; } static void qdev_get_child_property(DeviceState *dev, Visitor *v, void *opaque, const char *name, Error **errp) { DeviceState *child = opaque; gchar *path; path = qdev_get_canonical_path(child); visit_type_str(v, &path, name, errp); g_free(path); } void qdev_property_add_child(DeviceState *dev, const char *name, DeviceState *child, Error **errp) { gchar *type; type = g_strdup_printf("child<%s>", child->info->name); qdev_property_add(dev, name, type, qdev_get_child_property, NULL, NULL, child, errp); qdev_ref(child); g_free(type); } static gchar *qdev_get_path_in(DeviceState *parent, DeviceState *dev) { DeviceProperty *prop; Loading
hw/qdev.h +20 −0 Original line number Diff line number Diff line Loading @@ -527,4 +527,24 @@ gchar *qdev_get_canonical_path(DeviceState *dev); */ DeviceState *qdev_resolve_path(const char *path, bool *ambiguous); /** * @qdev_property_add_child - Add a child property to a device * * Child properties form the composition tree. All devices need to be a child * of another device. Devices can only be a child of one device. * * There is no way for a child to determine what its parent is. It is not * a bidirectional relationship. This is by design. * * @dev - the device to add a property to * * @name - the name of the property * * @child - the child device * * @errp - if an error occurs, a pointer to an area to store the area */ void qdev_property_add_child(DeviceState *dev, const char *name, DeviceState *child, Error **errp); #endif