The `TypeInfo::class_data` value of an interface is never properly propagated for initializations of all types implementing the interface. Although interfaces are rarely used, IMHO their functionality is currently a bit incomplete.
A `TypeInfo fooable_info` of an interface "fooable" may have the `.class_base_init` callback and the `.class_data` field defined. Let's assume that `.class_data = 0xdeadbeef`. Additionally, the `fooable_info` is only used to allocate one associated instance of `TypeImpl`, let's say `fooable_impl`. Then, for each type `TypeInfo xyz_info`, that implements the interface "fooable", there is another `TypeInfo info` (and associated TypeImpl) automatically created within `type_initialize_interface()`. The automatic `info` reflects the fact that the interface "fooable" is implemented by `xyz_info` (for example by having `.name="xyz::fooable"`). In a way, the `info` inherits from `fooable_impl`, for example it sets `.parent` field accordingly. The problem is that this inheritance is fixed by the implementation of `type_initialize_interface` and the `info.class_data` is always `NULL`. Further, this NULL value is passed to `fooable_info::class_base_init()`, where actually a common-sense expectation would be to have the `0xdeadbeef` from the interface definition. The fix below seems to be the easiest solution. Another option would be to dereference `klass->type->parent_type->...->parent_type->class_data` but the `TypeImpl` definition is (perhaps on purpose) private to `qom/object.c`. Signed-off-by: Maciej Bielski <bielski.mac...@gmail.com> --- qom/object.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qom/object.c b/qom/object.c index aac08351b7..dc305e14b0 100644 --- a/qom/object.c +++ b/qom/object.c @@ -248,6 +248,7 @@ static void type_initialize_interface(TypeImpl *ti, TypeImpl *interface_type, TypeImpl *iface_impl; info.parent = parent_type->name; + info.class_data = parent_type->class_data; info.name = g_strdup_printf("%s::%s", ti->name, interface_type->name); info.abstract = true; -- 2.21.0