diff options
| author | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-12 14:29:31 -0600 |
|---|---|---|
| committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-12-15 09:20:48 -0600 |
| commit | 3de1c3e82d06ac7fe789d912feb8876c0a8b270e (patch) | |
| tree | d454680822a190b55b710aac509c5713643cd171 /hw/qdev.c | |
| parent | dc45c21f39f826e7ab4b8e86fc4d0c987fad3fb7 (diff) | |
| download | focaccia-qemu-3de1c3e82d06ac7fe789d912feb8876c0a8b270e.tar.gz focaccia-qemu-3de1c3e82d06ac7fe789d912feb8876c0a8b270e.zip | |
qom: add child properties (composition) (v3)
Child properties express a relationship of composition. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/qdev.c')
| -rw-r--r-- | hw/qdev.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/hw/qdev.c b/hw/qdev.c index 2519f00787..167f459996 100644 --- a/hw/qdev.c +++ b/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; |