Message ID | 20161020112829.14589-2-lma@suse.com |
---|---|
State | New |
Headers | show |
Lin Ma <lma@suse.com> writes: > Signed-off-by: Lin Ma <lma@suse.com> > --- > qom/object.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/qom/object.c b/qom/object.c > index 7a05e35..4096645 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -747,7 +747,11 @@ ObjectClass *object_get_class(Object *obj) > > bool object_class_is_abstract(ObjectClass *klass) > { > - return klass->type->abstract; > + if (type_is_ancestor(klass->type, type_interface)) { > + return true; > + } else { > + return klass->type->abstract; > + } > } > > const char *object_class_get_name(ObjectClass *klass) Pardon my ignorance... If all types derived from type_interface are abstract, why aren't we setting ->abstract right when such a type is defined? Hmm, perhaps we do? type_initialize_interface() sets info.abstract = true... In case we don't: what about other uses of ->abstract? Why is it okay not to check whether type_interface is an ancestore there?
>>> Markus Armbruster <armbru@redhat.com> 2016/11/4 星期五 上午 2:18 >>> >Lin Ma <lma@suse.com> writes: > >> Signed-off-by: Lin Ma <lma@suse.com> >> --- >> qom/object.c | 6 +++++- >> 1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/qom/object.c b/qom/object.c >> index 7a05e35..4096645 100644 >> --- a/qom/object.c >> +++ b/qom/object.c >> @@ -747,7 +747,11 @@ ObjectClass *object_get_class(Object *obj) >> >> bool object_class_is_abstract(ObjectClass *klass) >> { >> - return klass->type->abstract; >> + if (type_is_ancestor(klass->type, type_interface)) { >> + return true; >> + } else { >> + return klass->type->abstract; >> + } >> } >> >> const char *object_class_get_name(ObjectClass *klass) > >Pardon my ignorance... > >If all types derived from type_interface are abstract, why aren't we >setting ->abstract right when such a type is defined? For lots of interfaces, they already explicitly define abstract as true, say: generic-pc-machine in hw/i386/pc.c, or memory-backend in backends/hostmem.c Please refer to http://lists.nongnu.org/archive/html/qemu-devel/2016-10/msg01955.html hope it could give you some clue. but I see that other interfaces (I randomly picked generic-pc-machine and fw_cfg as examples) still explicitly define 'abstract = true'. >Hmm, perhaps we do? type_initialize_interface() sets info.abstract = >true... For interfaces, I guess not. >In case we don't: what about other uses of ->abstract? Why is it okay >not to check whether type_interface is an ancestore there? For lots of interfaces, they already explicitly define abstract as true, say: generic-pc-machine in hw/i386/pc.c, or memory-backend in backends/hostmem.c So they can be checked through ->abstract, dont need to check whether type_interface is an ancestore. Thanks, Lin
diff --git a/qom/object.c b/qom/object.c index 7a05e35..4096645 100644 --- a/qom/object.c +++ b/qom/object.c @@ -747,7 +747,11 @@ ObjectClass *object_get_class(Object *obj) bool object_class_is_abstract(ObjectClass *klass) { - return klass->type->abstract; + if (type_is_ancestor(klass->type, type_interface)) { + return true; + } else { + return klass->type->abstract; + } } const char *object_class_get_name(ObjectClass *klass)
Signed-off-by: Lin Ma <lma@suse.com> --- qom/object.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)