[email protected] writes:
>> This permits setting ObjectProperty's optional @qapi_type. For now,
>> all callers pass null. Callers updated with this Coccinelle script:
>>
>> @@
>> identifier fun = {
>> object_property_try_add, object_property_add, object_class_property_add
>> };
>> expression obj, name, type;
>> @@
>> - fun(obj, name, type,
>> + fun(obj, name, type, NULL,
>> ...)
>>
>> Signed-off-by: Markus Armbruster <[email protected]>
>> Message-ID: <[email protected]>
[...]
>> diff --git a/include/qom/object.h b/include/qom/object.h
>> index e9b380462ded..84b273e53545 100644
>> --- a/include/qom/object.h
>> +++ b/include/qom/object.h
>> @@ -1163,6 +1163,7 @@ void object_unref(void *obj);
>> * defined. Sub namespaces are constructed by using a prefix and then
>> * to angle brackets. For instance, the type 'virtio-net-pci' in the
>> * 'link' namespace would be 'link<virtio-net-pci>'.
>> + * @qapi_type: QAPI type info descriptor
>> * @get: The getter to be called to read a property. If this is NULL, then
>> * the property cannot be read.
>> * @set: the setter to be called to write a property. If this is NULL,
>> @@ -1188,6 +1189,7 @@ void object_unref(void *obj);
>> */
>> ObjectProperty *object_property_try_add(Object *obj, const char *name,
>> const char *type,
>> + QAPITypeInfo *qapi_type,
>
> should be const QAPITypeInfo *
Yes. Not caught by the compiler, because there are just three calls,
and I messed up the two of them that should pass something, as you noted
below. Not caught by my testing probably because pretty much nothing
uses them.
>> ObjectPropertyAccessor *get,
>> ObjectPropertyAccessor *set,
>> ObjectPropertyRelease *release,
>> @@ -1203,6 +1205,7 @@ ObjectProperty *object_property_try_add(Object *obj,
>> const char *name,
>> * defined. Sub namespaces are constructed by using a prefix and then
>> * to angle brackets. For instance, the type 'virtio-net-pci' in the
>> * 'link' namespace would be 'link<virtio-net-pci>'.
>> + * @qapi_type: QAPI type info descriptor
>> * @get: The getter to be called to read a property. If this is NULL, then
>> * the property cannot be read.
>> * @set: the setter to be called to write a property. If this is NULL,
>> @@ -1220,6 +1223,7 @@ ObjectProperty *object_property_try_add(Object *obj,
>> const char *name,
>> */
>> ObjectProperty *object_property_add(Object *obj, const char *name,
>> const char *type,
>> + const QAPITypeInfo *qapi_type,
>> ObjectPropertyAccessor *get,
>> ObjectPropertyAccessor *set,
>> ObjectPropertyRelease *release,
>> @@ -1237,6 +1241,7 @@ void object_property_del(Object *obj, const char
>> *name);
>>
>> ObjectProperty *object_class_property_add(ObjectClass *klass, const char
>> *name,
>> const char *type,
>> + const QAPITypeInfo *qapi_type,
>> ObjectPropertyAccessor *get,
>> ObjectPropertyAccessor *set,
>> ObjectPropertyRelease *release,
>> diff --git a/iothread.c b/iothread.c
>> index 76eea6df3861..7084d336a400 100644
>> --- a/iothread.c
>> +++ b/iothread.c
>> @@ -315,19 +315,19 @@ static void iothread_class_init(ObjectClass *klass,
>> const void *class_data)
>> bc->init = iothread_init;
>> bc->update_params = iothread_set_aio_context_params;
>>
>> - object_class_property_add(klass, "poll-max-ns", "int64",
>> + object_class_property_add(klass, "poll-max-ns", "int64", NULL,
>> iothread_get_poll_param,
>> iothread_set_poll_param,
>> NULL, &poll_max_ns_info);
>> - object_class_property_add(klass, "poll-grow", "int64",
>> + object_class_property_add(klass, "poll-grow", "int64", NULL,
>> iothread_get_poll_param,
>> iothread_set_poll_param,
>> NULL, &poll_grow_info);
>> - object_class_property_add(klass, "poll-shrink", "int64",
>> + object_class_property_add(klass, "poll-shrink", "int64", NULL,
>> iothread_get_poll_param,
>> iothread_set_poll_param,
>> NULL, &poll_shrink_info);
>> - object_class_property_add(klass, "poll-weight", "int64",
>> + object_class_property_add(klass, "poll-weight", "int64", NULL,
>> iothread_get_poll_param,
>> iothread_set_poll_param,
>> NULL, &poll_weight_info);
>> diff --git a/net/colo-compare.c b/net/colo-compare.c
>> index 5986fb1e8800..7d4a2db522ad 100644
>> --- a/net/colo-compare.c
>> +++ b/net/colo-compare.c
>> @@ -1373,15 +1373,15 @@ static void colo_compare_init(Object *obj)
>> object_property_add_str(obj, "notify_dev",
>> compare_get_notify_dev, compare_set_notify_dev);
>>
>> - object_property_add(obj, "compare_timeout", "uint64",
>> + object_property_add(obj, "compare_timeout", "uint64", NULL,
>> compare_get_timeout,
>> compare_set_timeout, NULL, NULL);
>>
>> - object_property_add(obj, "expired_scan_cycle", "uint32",
>> + object_property_add(obj, "expired_scan_cycle", "uint32", NULL,
>> compare_get_expired_scan_cycle,
>> compare_set_expired_scan_cycle, NULL, NULL);
>>
>> - object_property_add(obj, "max_queue_size", "uint32",
>> + object_property_add(obj, "max_queue_size", "uint32", NULL,
>> get_max_queue_size,
>> set_max_queue_size, NULL, NULL);
>>
>> diff --git a/net/dump.c b/net/dump.c
>> index 0c39f09892c2..558115b9c9e3 100644
>> --- a/net/dump.c
>> +++ b/net/dump.c
>> @@ -238,7 +238,8 @@ static void filter_dump_class_init(ObjectClass *oc,
>> const void *data)
>> {
>> NetFilterClass *nfc = NETFILTER_CLASS(oc);
>>
>> - object_class_property_add(oc, "maxlen", "uint32",
>> filter_dump_get_maxlen,
>> + object_class_property_add(oc, "maxlen", "uint32", NULL,
>> + filter_dump_get_maxlen,
>> filter_dump_set_maxlen, NULL, NULL);
>> object_class_property_add_str(oc, "file", file_dump_get_filename,
>> file_dump_set_filename);
>> diff --git a/net/filter-buffer.c b/net/filter-buffer.c
>> index 427da24097f2..f56b2cfaf0b1 100644
>> --- a/net/filter-buffer.c
>> +++ b/net/filter-buffer.c
>> @@ -182,7 +182,7 @@ static void filter_buffer_class_init(ObjectClass *oc,
>> const void *data)
>> {
>> NetFilterClass *nfc = NETFILTER_CLASS(oc);
>>
>> - object_class_property_add(oc, "interval", "uint32",
>> + object_class_property_add(oc, "interval", "uint32", NULL,
>> filter_buffer_get_interval,
>> filter_buffer_set_interval, NULL, NULL);
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index c34b47312f29..0fbd4a7edfbe 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -1340,6 +1340,7 @@ void object_unref(void *objptr)
>>
>> ObjectProperty *
>> object_property_try_add(Object *obj, const char *name, const char *type,
>> + QAPITypeInfo *qapi_type,
>> ObjectPropertyAccessor *get,
>> ObjectPropertyAccessor *set,
>> ObjectPropertyRelease *release,
>> @@ -1357,8 +1358,8 @@ object_property_try_add(Object *obj, const char *name,
>> const char *type,
>> for (i = 0; i < INT16_MAX; ++i) {
>> char *full_name = g_strdup_printf("%s[%d]", name_no_array, i);
>>
>> - ret = object_property_try_add(obj, full_name, type, get, set,
>> - release, opaque, NULL);
>> + ret = object_property_try_add(obj, full_name, type, NULL,
>
> Propagate @qapi_type to the generated name[i] properties.
Yes, this is #1, and ...
>> + get, set, release, opaque, NULL);
>> g_free(full_name);
>> if (ret) {
>> break;
>> @@ -1379,6 +1380,7 @@ object_property_try_add(Object *obj, const char *name,
>> const char *type,
>>
>> prop->name = g_strdup(name);
>> prop->type = g_strdup(type);
>> + prop->qapi_type = qapi_type;
>>
>> prop->get = get;
>> prop->set = set;
>> @@ -1393,12 +1395,13 @@ object_property_try_add(Object *obj, const char
>> *name, const char *type,
>>
>> ObjectProperty *
>> object_property_add(Object *obj, const char *name, const char *type,
>> + const QAPITypeInfo *qapi_type,
>> ObjectPropertyAccessor *get,
>> ObjectPropertyAccessor *set,
>> ObjectPropertyRelease *release,
>> void *opaque)
>> {
>> - return object_property_try_add(obj, name, type, get, set, release,
>> + return object_property_try_add(obj, name, type, NULL, get, set, release,
>
> This should pass @qapi_type also
... this is #2.
Thanks!