mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
qom: add child properties (composition) (v3)
Child properties express a relationship of composition. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
dc45c21f39
commit
3de1c3e82d
2 changed files with 46 additions and 0 deletions
26
hw/qdev.c
26
hw/qdev.c
|
@ -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…
Add table
Add a link
Reference in a new issue