[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] 答复: Re: [PATCH v3 1/3] qom: make base type user-creatable
From: |
Lin Ma |
Subject: |
[Qemu-devel] 答复: Re: [PATCH v3 1/3] qom: make base type user-creatable abstract |
Date: |
Mon, 10 Oct 2016 08:32:35 -0600 |
>>> "Daniel P. Berrange" <address@hidden> 2016/9/26 星期一 下午 6:37 >>>
>On Mon, Sep 26, 2016 at 06:16:25PM +0800, Lin Ma wrote:
>> Signed-off-by: Lin Ma <address@hidden>
>> ---
>> qom/object_interfaces.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
>> index bf59846..9288242 100644
>> --- a/qom/object_interfaces.c
>> +++ b/qom/object_interfaces.c
>> @@ -217,6 +217,7 @@ static void register_types(void)
>> static const TypeInfo uc_interface_info = {
>> .name = TYPE_USER_CREATABLE,
>> .parent = TYPE_INTERFACE,
>> + .abstract = true,
>> .class_size = sizeof(UserCreatableClass),
>> };
>
>This doesn't make any conceptual sense. UserCreatable is an inteface and
>by definition all interfaces are abstract.
>
Sorry for the late reply, I was on vacation.
oh...indeed, add '.abstract = true' for an interface is not a good idea.
>Were you trying to fix some particular real bug here ? If so, we almost
>certainly need a different fix to what's suggested here, because QOM
>should automatically treat all interfaces as abstract by their very
>nature.
>
For other interfaces, say 'acpi-device-interface' or 'ipmi-interface', it's fine
as they are not user creatable. but for 'user-creatable', when performing
'qemu-system-x86_64 -object user-creatable,id=foo', segfault happens:
$ qemu-system-x86_64 -object user-creatable,id=foo
**
ERROR:/work/armbru/qemu/qom/object.c:361:object_initialize_with_type:
assertion failed (type->instance_size >= sizeof(Object)): (0 >= 40)
Aborted (core dumped)
How about the following changes to skip TYPE_USER_CREATABLE in function
user_creatable_add_type ?
@@ -102,7 +102,8 @@ Object *user_creatable_add_type(const char *type, const
char *id,
return NULL;
}
- if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE)) {
+ if (!object_class_dynamic_cast(klass, TYPE_USER_CREATABLE) ||
+ !strcmp(type, TYPE_USER_CREATABLE)) {
error_setg(errp, "object type '%s' isn't supported by
object-add",
type);
return NULL;
...
@@ -229,7 +230,8 @@ int user_creatable_help_func(void *opaque, QemuOpts *opts,
Error **errp)
list = list->next) {
const char *name;
name = object_class_get_name(OBJECT_CLASS(list->data));
- printf("%s\n", name);
+ if (strcmp(name, TYPE_USER_CREATABLE))
+ printf("%s\n", name);
...
Thanks,
Lin
- [Qemu-devel] 答复: Re: [PATCH v3 1/3] qom: make base type user-creatable abstract,
Lin Ma <=