[Qemu-devel] [PATCH 05/25] qom: push type up to Object
Now that Object is a type, add an instance_init function and push the "type" property from qdev to there. Signed-off-by: Paolo Bonzini --- hw/qdev.c|6 -- qom/object.c | 11 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 0d3c0fc..bb6c1aa 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -510,11 +510,6 @@ char* qdev_get_fw_dev_path(DeviceState *dev) return strdup(path); } -static char *qdev_get_type(Object *obj, Error **errp) -{ -return g_strdup(object_get_typename(obj)); -} - /** * Legacy property handling */ @@ -630,7 +625,6 @@ static void device_initfn(Object *obj) qdev_property_add_static(dev, prop, NULL); } -object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL); qdev_prop_set_defaults(dev, qdev_get_props(dev)); } diff --git a/qom/object.c b/qom/object.c index 585619d..f3ffaa6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1215,6 +1215,16 @@ void object_property_add_str(Object *obj, const char *name, prop, errp); } +static char *qdev_get_type(Object *obj, Error **errp) +{ +return g_strdup(object_get_typename(obj)); +} + +static void object_instance_init(Object *obj) +{ +object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); +} + static void register_types(void) { static TypeInfo interface_info = { @@ -1226,6 +1236,7 @@ static void register_types(void) static TypeInfo object_info = { .name = TYPE_OBJECT, .instance_size = sizeof(Object), +.instance_init = object_instance_init, .abstract = true, }; -- 1.7.9.3
Re: [Qemu-devel] [PATCH 05/25] qom: push type up to Object
Am 03.04.2012 13:15, schrieb Paolo Bonzini: > Now that Object is a type, add an instance_init function and push > the "type" property from qdev to there. > > Signed-off-by: Paolo Bonzini Reviewed-by: Andreas Färber But please change the subject to 'qom: Push "type" property up to Object', otherwise it's confusing. ;) Andreas -- SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 05/25] qom: push type up to Object
On 04/03/2012 06:15 AM, Paolo Bonzini wrote: Now that Object is a type, add an instance_init function and push the "type" property from qdev to there. Signed-off-by: Paolo Bonzini Reviewed-by: Anthony Liguori Regards, Anthony Liguori --- hw/qdev.c|6 -- qom/object.c | 11 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/qdev.c b/hw/qdev.c index 0d3c0fc..bb6c1aa 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -510,11 +510,6 @@ char* qdev_get_fw_dev_path(DeviceState *dev) return strdup(path); } -static char *qdev_get_type(Object *obj, Error **errp) -{ -return g_strdup(object_get_typename(obj)); -} - /** * Legacy property handling */ @@ -630,7 +625,6 @@ static void device_initfn(Object *obj) qdev_property_add_static(dev, prop, NULL); } -object_property_add_str(OBJECT(dev), "type", qdev_get_type, NULL, NULL); qdev_prop_set_defaults(dev, qdev_get_props(dev)); } diff --git a/qom/object.c b/qom/object.c index 585619d..f3ffaa6 100644 --- a/qom/object.c +++ b/qom/object.c @@ -1215,6 +1215,16 @@ void object_property_add_str(Object *obj, const char *name, prop, errp); } +static char *qdev_get_type(Object *obj, Error **errp) +{ +return g_strdup(object_get_typename(obj)); +} + +static void object_instance_init(Object *obj) +{ +object_property_add_str(obj, "type", qdev_get_type, NULL, NULL); +} + static void register_types(void) { static TypeInfo interface_info = { @@ -1226,6 +1236,7 @@ static void register_types(void) static TypeInfo object_info = { .name = TYPE_OBJECT, .instance_size = sizeof(Object), +.instance_init = object_instance_init, .abstract = true, };