All of lore.kernel.org
 help / color / mirror / Atom feed
From: QingFeng Hao <haoqf@linux.vnet.ibm.com>
To: "Perez Blanco,
	Ricardo (Nokia - BE/Antwerp)" <ricardo.perez_blanco@nokia.com>,
	"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: "dgilbert@redhat.com" <dgilbert@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"
Date: Thu, 19 Apr 2018 11:51:38 +0800	[thread overview]
Message-ID: <b2eaf385-1d60-a352-f970-7b47d2744d90@linux.vnet.ibm.com> (raw)
In-Reply-To: <AM3PR07MB273186AEFA49A506BFC2D28B3B30@AM3PR07MB273.eurprd07.prod.outlook.com>



在 2018/4/13 16:05, Perez Blanco, Ricardo (Nokia - BE/Antwerp) 写道:
> Dear all,
> 
> Here you can find my first contribution to qemu. Please, do not hesitate to do any kind of remark.
> 
> Based on ac4ba87ae0738d7a77708f8ce31ae2378ab99654
> 
> Kind regards,
> 
> Ricardo Perez Blanco
> 
>>From 65df20cef2846d764a8a821574f5f3643391aac5 Mon Sep 17 00:00:00 2001
> From: Ricardo Perez Blanco <ricardo.perez_blanco@nokia.com>
> Date: Wed, 11 Apr 2018 12:09:11 +0200
> Subject: [PATCH] Show values and description when using "qom-list"
> 
> For debugging purposes it is very useful to:
>  - See the description of the field. This information is already filled
>    in but not shown in "qom-list" command.
>  - Display value of the field. So far, only well known types are
>    implemented (string, str, int, uint, bool).
Need we support other types like QList and QDict? I think yes and suggest a new command
to be introduced like qom-list-property or qom-get. The resorts may be:
	1) print the json string just as Alan's former patch
        2) print the value step by step. Supposing property foo is a structure,
           qom-list-property path foo prints its members as "mem1;mem2;mem3"
           and qom-list-property path foo.mem1 prints mem1's value.
And some properties don't have get/set callback set, which prompts as below if doing
qom-get/set:
(qemu) qom-get /machine kernel-irqchip
Insufficient permission to perform this operation
For these properties I think we may need to not show the value in qom-list.
Thanks!

> 
> Signed-off-by: Ricardo Perez Blanco <ricardo.perez_blanco@nokia.com>
> ---
>  hmp.c          | 13 +++++++++++--
>  qapi/misc.json |  4 +++-
>  qmp.c          | 26 ++++++++++++++++++++++++++
>  3 files changed, 40 insertions(+), 3 deletions(-)
> 
> diff --git a/hmp.c b/hmp.c
> index a25c7bd..967e0b2 100644
> --- a/hmp.c
> +++ b/hmp.c
> @@ -2490,8 +2490,17 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
>          while (list != NULL) {
>              ObjectPropertyInfo *value = list->value;
> 
> -            monitor_printf(mon, "%s (%s)\n",
> -                           value->name, value->type);
> +            monitor_printf(mon, "%s", value->name);
> +            if (value->value) {
> +                monitor_printf(mon, "=%s", value->value);
> +            }
> +            monitor_printf(mon, " (%s)", value->type);
> +            if (value->description) {
> +                monitor_printf(mon, "\r\t\t\t\t\t\t\t\t\t[Description: %s]",
> +                               value->description);
> +            }
> +            monitor_printf(mon, "\n");
> +
>              list = list->next;
>          }
>          qapi_free_ObjectPropertyInfoList(start);
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 5636f4a..6b3b4de 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -1328,10 +1328,12 @@
>  #
>  # @description: if specified, the description of the property.
>  #
> +# @value: if specified, the value of the property.
> +#
>  # Since: 1.2
>  ##
>  { 'struct': 'ObjectPropertyInfo',
> -  'data': { 'name': 'str', 'type': 'str', '*description': 'str' } }
> +  'data': { 'name': 'str', 'type': 'str', '*description':'str', '*value':'str' } }
> 
>  ##
>  # @qom-list:
> diff --git a/qmp.c b/qmp.c
> index f722616..750b5d0 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -237,6 +237,32 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
> 
>          entry->value->name = g_strdup(prop->name);
>          entry->value->type = g_strdup(prop->type);
> +        if (prop->description) {
> +            entry->value->description = g_strdup(prop->description);
> +        }
> +        if ((g_ascii_strncasecmp(entry->value->type, "string", 6) == 0) ||
> +            (g_ascii_strncasecmp(entry->value->type, "str", 3) == 0)) {
> +            Error **errp = NULL;
> +            entry->value->value = g_strdup_printf("\"%s\"",
> +                object_property_get_str(obj, entry->value->name, errp));
> +        }
> +        if (g_ascii_strncasecmp(entry->value->type, "int", 3) == 0) {
> +            Error **errp = NULL;
> +            entry->value->value = g_strdup_printf("%ld",
> +                object_property_get_int(obj, entry->value->name, errp));
> +        }
> +        if (g_ascii_strncasecmp(entry->value->type, "uint", 4) == 0) {
> +            Error **errp = NULL;
> +            entry->value->value = g_strdup_printf("%lu",
> +                object_property_get_uint(obj, entry->value->name, errp));
> +        }
> +        if (g_ascii_strncasecmp(entry->value->type, "bool", 4) == 0) {
> +            Error **errp = NULL;
> +            entry->value->value = g_strdup_printf("%s",
> +               (object_property_get_bool(obj, entry->value->name, errp) == true)
> +                ? "true" : "false");
> +        }
> +
>      }
> 
>      return props;
> --
> 1.8.3.1
> 
> 

-- 
Regards
QingFeng Hao

  parent reply	other threads:[~2018-04-19  3:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-13  8:05 [Qemu-devel] [PATCH] Show values and description when using "qom-list" Perez Blanco, Ricardo (Nokia - BE/Antwerp)
2018-04-13 12:53 ` no-reply
2018-04-16 12:00   ` Perez Blanco, Ricardo (Nokia - BE/Antwerp)
2018-04-17 19:11     ` Eric Blake
2018-04-17 19:19 ` Eric Blake
2018-04-19  3:51 ` QingFeng Hao [this message]
2018-04-24 11:49   ` Dr. David Alan Gilbert
2018-04-24 12:17     ` Perez Blanco, Ricardo (Nokia - BE/Antwerp)
2018-04-25  0:38     ` QingFeng Hao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b2eaf385-1d60-a352-f970-7b47d2744d90@linux.vnet.ibm.com \
    --to=haoqf@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=ricardo.perez_blanco@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.