So clients can set the top level id string. Signed-off-by: Peter Crosthwaite <peter.crosthwa...@xilinx.com> ---
hw/core/qdev.c | 13 +++++++++++-- include/hw/qdev-core.h | 2 +- qdev-monitor.c | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 60f9df1..a32e39b 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -833,13 +833,16 @@ static void device_initfn(Object *obj) device_get_hotpluggable, NULL, NULL); class = object_get_class(OBJECT(dev)); - do { + for (;;) { for (prop = DEVICE_CLASS(class)->props; prop && prop->name; prop++) { qdev_property_add_legacy(dev, prop, &error_abort); qdev_property_add_static(dev, prop, &error_abort); } + if (class == object_class_by_name(TYPE_DEVICE)) { + break; + } class = object_class_get_parent(class); - } while (class != object_class_by_name(TYPE_DEVICE)); + } object_property_add_link(OBJECT(dev), "parent_bus", TYPE_BUS, (Object **)&dev->parent_bus, NULL, 0, @@ -906,6 +909,11 @@ static void device_unparent(Object *obj) } } +static Property device_props[] = { + DEFINE_PROP_STRING("device-id", DeviceState, id), + DEFINE_PROP_END_OF_LIST(), +}; + static void device_class_init(ObjectClass *class, void *data) { DeviceClass *dc = DEVICE_CLASS(class); @@ -913,6 +921,7 @@ static void device_class_init(ObjectClass *class, void *data) class->unparent = device_unparent; dc->realize = device_realize; dc->unrealize = device_unrealize; + dc->props = device_props; /* by default all devices were considered as hotpluggable, * so with intent to check it in generic qdev_unplug() / diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h index dbe473c..38557d3 100644 --- a/include/hw/qdev-core.h +++ b/include/hw/qdev-core.h @@ -143,7 +143,7 @@ struct DeviceState { Object parent_obj; /*< public >*/ - const char *id; + char *id; bool realized; QemuOpts *opts; int hotplugged; diff --git a/qdev-monitor.c b/qdev-monitor.c index 9268c87..f0713a9 100644 --- a/qdev-monitor.c +++ b/qdev-monitor.c @@ -531,7 +531,8 @@ DeviceState *qdev_device_add(QemuOpts *opts) id = qemu_opts_id(opts); if (id) { - dev->id = id; + /* FIXME: Qdev String props cant handle consts */ + dev->id = (char *)id; } if (dev->id) { -- 1.9.2.1.g06c4abd