Marc-AndrĂ© Lureau <[email protected]> writes:

> Wire up the new qapi-type field in all four QMP handlers that return
> ObjectPropertyInfo or ObjectPropertyValue: qom-list, qom-list-get,
> device-list-properties, and qom-list-properties.
>
> When an ObjectProperty has a qapi_type set, the masked QAPI type name
> is copied into the response, allowing clients to cross-reference with
> query-qmp-schema.

Again, I'd mention that no property has it set just yet.

>
> Signed-off-by: Marc-AndrĂ© Lureau <[email protected]>
> ---
>  qom/qom-qmp-cmds.c | 32 +++++++++++++++++++-------------
>  1 file changed, 19 insertions(+), 13 deletions(-)
>
> diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c
> index 48b38d2b7f7..30af2cef53e 100644
> --- a/qom/qom-qmp-cmds.c
> +++ b/qom/qom-qmp-cmds.c
> @@ -25,9 +25,22 @@
>  #include "qapi/qobject-input-visitor.h"
>  #include "qapi/qobject-output-visitor.h"
>  #include "qemu/cutils.h"
> +#include "qapi/qapi-type-info.h"
>  #include "qom/object_interfaces.h"
>  #include "qom/qom-qobject.h"
>  
> +static ObjectPropertyInfo *qom_property_info(ObjectProperty *prop)
> +{
> +    ObjectPropertyInfo *info = g_new0(ObjectPropertyInfo, 1);
> +
> +    info->name = g_strdup(prop->name);
> +    info->type = g_strdup(prop->type);
> +    if (prop->qapi_type) {
> +        info->qapi_type = g_strdup(prop->qapi_type->schema_name);
> +    }
> +    return info;
> +}
> +
>  static Object *qom_resolve_path(const char *path, Error **errp)
>  {
>      bool ambiguous = false;
> @@ -58,12 +71,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, 
> Error **errp)
>  
>      object_property_iter_init(&iter, obj);
>      while ((prop = object_property_iter_next(&iter))) {
> -        ObjectPropertyInfo *value = g_new0(ObjectPropertyInfo, 1);
> -
> -        QAPI_LIST_PREPEND(props, value);
> -
> -        value->name = g_strdup(prop->name);
> -        value->type = g_strdup(prop->type);
> +        QAPI_LIST_PREPEND(props, qom_property_info(prop));

Non-idempotent macro arguments scare me.  This one works, because
QAPI_LIST_PREPEND() evaluates its second argument exactly once.  It even
spells it out in a contract.  Okay.

>      }
>  
>      return props;
> @@ -78,6 +86,9 @@ static void qom_list_add_property_value(Object *obj, 
> ObjectProperty *prop,
>  
>      item->name = g_strdup(prop->name);
>      item->type = g_strdup(prop->type);
> +    if (prop->qapi_type) {
> +        item->qapi_type = g_strdup(prop->qapi_type->schema_name);
> +    }
>      item->value = object_property_get_qobject(obj, prop->name, NULL);
>  }
>  
> @@ -225,9 +236,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const 
> char *typename,
>              continue;
>          }
>  
> -        info = g_new0(ObjectPropertyInfo, 1);
> -        info->name = g_strdup(prop->name);
> -        info->type = g_strdup(prop->type);
> +        info = qom_property_info(prop);
>          info->description = g_strdup(prop->description);
>          info->default_value = qobject_ref(prop->defval);
>  
> @@ -268,11 +277,8 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const 
> char *typename,
>          object_property_iter_init(&iter, obj);
>      }
>      while ((prop = object_property_iter_next(&iter))) {
> -        ObjectPropertyInfo *info;
> +        ObjectPropertyInfo *info = qom_property_info(prop);
>  
> -        info = g_malloc0(sizeof(*info));
> -        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);

Reviewed-by: Markus Armbruster <[email protected]>


Reply via email to