[PATCH v6 1/4] qom: add default value

Maksim Davydov posted 4 patches 1 year ago
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Beraldo Leal <bleal@redhat.com>, Eric Blake <eblake@redhat.com>, Markus Armbruster <armbru@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Alexander Bulekov <alxndr@bu.edu>, Bandan Das <bsd@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, Thomas Huth <thuth@redhat.com>, Darren Kenny <darren.kenny@oracle.com>, Qiuhao Li <Qiuhao.Li@outlook.com>, Laurent Vivier <lvivier@redhat.com>
There is a newer version of this series
[PATCH v6 1/4] qom: add default value
Posted by Maksim Davydov 1 year ago
qmp_qom_list_properties can print default values if they are available
as qmp_device_list_properties does, because both of them use the
ObjectPropertyInfo structure with default_value field. This can be useful
when working with "not device" types (e.g. memory-backend).

Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
---
 qom/qom-qmp-cmds.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
index 7c087299de..e91a235347 100644
--- a/qom/qom-qmp-cmds.c
+++ b/qom/qom-qmp-cmds.c
@@ -212,6 +212,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
         info->name = g_strdup(prop->name);
         info->type = g_strdup(prop->type);
         info->description = g_strdup(prop->description);
+        info->default_value = qobject_ref(prop->defval);
 
         QAPI_LIST_PREPEND(prop_list, info);
     }
-- 
2.34.1
Re: [PATCH v6 1/4] qom: add default value
Posted by Markus Armbruster 12 months ago
Maksim Davydov <davydov-max@yandex-team.ru> writes:

> qmp_qom_list_properties can print default values if they are available
> as qmp_device_list_properties does, because both of them use the
> ObjectPropertyInfo structure with default_value field. This can be useful
> when working with "not device" types (e.g. memory-backend).
>
> Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  qom/qom-qmp-cmds.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
> index 7c087299de..e91a235347 100644
> --- a/qom/qom-qmp-cmds.c
> +++ b/qom/qom-qmp-cmds.c
> @@ -212,6 +212,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
>          info->name = g_strdup(prop->name);
>          info->type = g_strdup(prop->type);
>          info->description = g_strdup(prop->description);
> +        info->default_value = qobject_ref(prop->defval);
>  
>          QAPI_LIST_PREPEND(prop_list, info);
>      }

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Re: [PATCH v6 1/4] qom: add default value
Posted by Philippe Mathieu-Daudé 1 year ago
On 8/11/23 16:38, Maksim Davydov wrote:
> qmp_qom_list_properties can print default values if they are available
> as qmp_device_list_properties does, because both of them use the
> ObjectPropertyInfo structure with default_value field. This can be useful
> when working with "not device" types (e.g. memory-backend).
> 
> Signed-off-by: Maksim Davydov <davydov-max@yandex-team.ru>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>   qom/qom-qmp-cmds.c | 1 +
>   1 file changed, 1 insertion(+)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>