Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-24 Thread QingFeng Hao


在 2018/4/24 19:49, Dr. David Alan Gilbert 写道:
> * QingFeng Hao (ha...@linux.vnet.ibm.com) wrote:
>>
>>
>> 在 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 
>>> 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.
> 
> So while I think it would be good to handle all the cases, I'd be happy
> to take just the current enhancements to qom-list (once the cleanups that Eric
> suggested are fixed).  Being able to see even just the int/bool/strings
> is very useful and something I've wanted for a while.
> 
Yes, agree! Thanks!
> Dave
> 
>> Thanks!
>>
>>>
>>> Signed-off-by: Ricardo Perez Blanco 
>>> ---
>>>  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

Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-24 Thread Perez Blanco, Ricardo (Nokia - BE/Antwerp)
Hi,

As David mentioned and after using it for a while in my own project, I found 
very useful printing the values for these common types.

I will summarize your comments and send a new patch.

Kind regards,

Ricardo Perez Blanco

-Original Message-
From: Dr. David Alan Gilbert [mailto:dgilb...@redhat.com] 
Sent: Tuesday, April 24, 2018 1:49 PM
To: QingFeng Hao 
Cc: Perez Blanco, Ricardo (Nokia - BE/Antwerp) 
; qemu-devel@nongnu.org; arm...@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Show values and description when using 
"qom-list"

* QingFeng Hao (ha...@linux.vnet.ibm.com) wrote:
> 
> 
> 在 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 
> > 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.

So while I think it would be good to handle all the cases, I'd be happy to take 
just the current enhancements to qom-list (once the cleanups that Eric 
suggested are fixed).  Being able to see even just the int/bool/strings is very 
useful and something I've wanted for a while.

Dave

> Thanks!
> 
> > 
> > Signed-off-by: Ricardo Perez Blanco 
> > ---
> >  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

Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-24 Thread Dr. David Alan Gilbert
* QingFeng Hao (ha...@linux.vnet.ibm.com) wrote:
> 
> 
> 在 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 
> > 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.

So while I think it would be good to handle all the cases, I'd be happy
to take just the current enhancements to qom-list (once the cleanups that Eric
suggested are fixed).  Being able to see even just the int/bool/strings
is very useful and something I've wanted for a while.

Dave

> Thanks!
> 
> > 
> > Signed-off-by: Ricardo Perez Blanco 
> > ---
> >  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->

Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-18 Thread QingFeng Hao


在 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 
> 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 
> ---
>  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




Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-17 Thread Eric Blake
On 04/13/2018 03:05 AM, Perez Blanco, Ricardo (Nokia - BE/Antwerp) wrote:
> Dear all,
> 
> Here you can find my first contribution to qemu. Please, do not hesitate to 
> do any kind of remark.

Welcome to the community.  Looking forward to your v2 patch submission
(see my reply to your followup, for more things to fix before you send v2).


> 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).
> 
> Signed-off-by: Ricardo Perez Blanco 
> ---
>  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);
> +}

Technically, you should be checking 'if (value->has_value)'.  It happens
that our current code sets value->value to NULL if value->has_value is
false, but that's less reliable.  Someday, we may improve our QAPI code
generator to quit generating has_FOO members when FOO is an optional
pointer and NULL is an obvious indication that FOO was not provided (at
which point, your code as written is correct), but we're not there yet.


> +++ b/qapi/misc.json
> @@ -1328,10 +1328,12 @@
>  #
>  # @description: if specified, the description of the property.
>  #
> +# @value: if specified, the value of the property.

Missing a mention that this field is '(since 2.13)'.

> +#
>  # 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)) {

This will accept a type named "strange"; is that intentional?

> +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) {

Likewise, this will accept a type named "internal".  I'm not sure if
your manual checking for types by names is the best approach; and the
fact that we are stringizing the result instead of using the natural
JSON type (a string for "str", a number for "int") is a bit worrisome.

> +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");
> +}

Since the ->value field is optional, you have to set
entry->value->has_value = true anywhere that you are setting
entry->value->value to a string.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-17 Thread Eric Blake
On 04/16/2018 07:00 AM, Perez Blanco, Ricardo (Nokia - BE/Antwerp) wrote:
> Hi,
> 
> A new patch (to be rebase on top of my previous one). 

A patch-to-a-patch doesn't work well.  Instead, run:

git rebase -i origin

then mark the second patch as 'squash' before closing the editor, and
git will merge the two patches into one.  Then resend things with 'v2'
in the subject line, by using 'git send-email -v2 ...'.

More patch submission hints at https://wiki.qemu.org/Contribute/SubmitAPatch

> 
> From 77f7217c07d5e3892f26082f220954678eb375b3 Mon Sep 17 00:00:00 2001
> From: Ricardo Perez Blanco 
> Date: Mon, 16 Apr 2018 13:51:42 +0200
> Subject: [PATCH] [PATCHv2] Show values and description when using "qom-list"
> 
> For debugging purposes it is very useful to:

This is not in 'git send-email' format, which makes it harder for our
automated tooling to evaluate your patch.

>  - 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).
> 
> Signed-off-by: Ricardo Perez Blanco 
> ---
>  qmp.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/qmp.c b/qmp.c
> index 750b5d0..5be9d8d 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -249,12 +249,14 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, 
> Error **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));
> +(long int) object_property_get_int(
> +obj, entry->value->name, errp));

This is wrong.  Casting 'int64_t' to 'long int' on a 32-bit platform
silently truncates the value.  You don't want the cast; instead, you
should be using "%"PRId64 in place of "%ld", so that your printf format
always matches the correct spelling corresponding to the 64-bit value
you will be printing.


> -Original Message-
> From: no-re...@patchew.org [mailto:no-re...@patchew.org] 
> Sent: Friday, April 13, 2018 2:54 PM
> To: Perez Blanco, Ricardo (Nokia - BE/Antwerp) 
> 
> Cc: f...@redhat.com; qemu-devel@nongnu.org; dgilb...@redhat.com; 
> arm...@redhat.com
> Subject: Re: [Qemu-devel] [PATCH] Show values and description when using 
> "qom-list"
> 
> Hi,
> 

Also, you are top-posting, which makes it hard to follow your
conversation.  On technical lists, it is better to reply inline instead
of top-posting, and to trim content that is not essential to your reply.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-16 Thread Perez Blanco, Ricardo (Nokia - BE/Antwerp)
Hi,

A new patch (to be rebase on top of my previous one). 

From 77f7217c07d5e3892f26082f220954678eb375b3 Mon Sep 17 00:00:00 2001
From: Ricardo Perez Blanco 
Date: Mon, 16 Apr 2018 13:51:42 +0200
Subject: [PATCH] [PATCHv2] 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).

Signed-off-by: Ricardo Perez Blanco 
---
 qmp.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qmp.c b/qmp.c
index 750b5d0..5be9d8d 100644
--- a/qmp.c
+++ b/qmp.c
@@ -249,12 +249,14 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, 
Error **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));
+(long int) 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));
+(long unsigned int) object_property_get_uint(
+obj, entry->value->name, errp));
 }
 if (g_ascii_strncasecmp(entry->value->type, "bool", 4) == 0) {
 Error **errp = NULL;
--
1.8.3.1

Kind regards,

Ricardo Perez Blanco

-Original Message-
From: no-re...@patchew.org [mailto:no-re...@patchew.org] 
Sent: Friday, April 13, 2018 2:54 PM
To: Perez Blanco, Ricardo (Nokia - BE/Antwerp) 
Cc: f...@redhat.com; qemu-devel@nongnu.org; dgilb...@redhat.com; 
arm...@redhat.com
Subject: Re: [Qemu-devel] [PATCH] Show values and description when using 
"qom-list"

Hi,

This series failed docker-mingw@fedora build test. Please find the testing 
commands and their output below. If you have Docker installed, you can probably 
reproduce it locally.

Type: series
Message-id: 
am3pr07mb273186aefa49a506bfc2d28b3...@am3pr07mb273.eurprd07.prod.outlook.com
Subject: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info export SHOW_ENV=1 export J=8 time make 
docker-test-mingw@fedora === TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
a36eb4615e Show values and description when using "qom-list"

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-t5rjlzak/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   fedora
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-t5rjlzak/src'
  GEN 
/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot'...
done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'6b3d716e2b6472eb7189d3220552280ef3d832ce'
  COPYRUNNER
RUN test-mingw in qemu:fedora
Packages installed:
PyYAML-3.12-5.fc27.x86_64
SDL2-devel-2.0.7-2.fc27.x86_64
bc-1.07.1-3.fc27.x86_64
bison-3.0.4-8.fc27.x86_64
bluez-libs-devel-5.48-3.fc27.x86_64
brlapi-devel-0.6.6-8.fc27.x86_64
bzip2-1.0.6-24.fc27.x86_64
bzip2-devel-1.0.6-24.fc27.x86_64
ccache-3.3.6-1.fc27.x86_64
clang-5.0.1-5.fc27.x86_64
device-mapper-multipath-devel-0.7.1-9.git847cc43.fc27.x86_64
findutils-4.6.0-16.fc27.x86_64
flex-2.6.1-5.fc27.x86_64
gcc-7.3.1-5.fc27.x86_64
gcc-c++-7.3.1-5.fc27.x86_64
gettext-0.19.8.1-12.fc27.x86_64
git-2.14.3-3.fc27.x86_64
glib2-devel-2.54.3-2.fc27.x86_64
glusterfs-api-devel-3.12.7-1.fc27.x86_64
gnutls-devel-

Re: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-13 Thread no-reply
Hi,

This series failed docker-mingw@fedora build test. Please find the testing 
commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

Type: series
Message-id: 
am3pr07mb273186aefa49a506bfc2d28b3...@am3pr07mb273.eurprd07.prod.outlook.com
Subject: [Qemu-devel] [PATCH] Show values and description when using "qom-list"

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
a36eb4615e Show values and description when using "qom-list"

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into '/var/tmp/patchew-tester-tmp-t5rjlzak/src/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
  BUILD   fedora
make[1]: Entering directory '/var/tmp/patchew-tester-tmp-t5rjlzak/src'
  GEN 
/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot'...
done.
Your branch is up-to-date with 'origin/test'.
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc'
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot/dtc'...
Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
Submodule 'ui/keycodemapdb' (git://git.qemu.org/keycodemapdb.git) registered 
for path 'ui/keycodemapdb'
Cloning into 
'/var/tmp/patchew-tester-tmp-t5rjlzak/src/docker-src.2018-04-13-08.51.25.18679/qemu.tar.vroot/ui/keycodemapdb'...
Submodule path 'ui/keycodemapdb': checked out 
'6b3d716e2b6472eb7189d3220552280ef3d832ce'
  COPYRUNNER
RUN test-mingw in qemu:fedora 
Packages installed:
PyYAML-3.12-5.fc27.x86_64
SDL2-devel-2.0.7-2.fc27.x86_64
bc-1.07.1-3.fc27.x86_64
bison-3.0.4-8.fc27.x86_64
bluez-libs-devel-5.48-3.fc27.x86_64
brlapi-devel-0.6.6-8.fc27.x86_64
bzip2-1.0.6-24.fc27.x86_64
bzip2-devel-1.0.6-24.fc27.x86_64
ccache-3.3.6-1.fc27.x86_64
clang-5.0.1-5.fc27.x86_64
device-mapper-multipath-devel-0.7.1-9.git847cc43.fc27.x86_64
findutils-4.6.0-16.fc27.x86_64
flex-2.6.1-5.fc27.x86_64
gcc-7.3.1-5.fc27.x86_64
gcc-c++-7.3.1-5.fc27.x86_64
gettext-0.19.8.1-12.fc27.x86_64
git-2.14.3-3.fc27.x86_64
glib2-devel-2.54.3-2.fc27.x86_64
glusterfs-api-devel-3.12.7-1.fc27.x86_64
gnutls-devel-3.5.18-2.fc27.x86_64
gtk3-devel-3.22.26-2.fc27.x86_64
hostname-3.18-4.fc27.x86_64
libaio-devel-0.3.110-9.fc27.x86_64
libasan-7.3.1-5.fc27.x86_64
libattr-devel-2.4.47-21.fc27.x86_64
libcap-devel-2.25-7.fc27.x86_64
libcap-ng-devel-0.7.8-5.fc27.x86_64
libcurl-devel-7.55.1-10.fc27.x86_64
libfdt-devel-1.4.6-1.fc27.x86_64
libpng-devel-1.6.31-1.fc27.x86_64
librbd-devel-12.2.4-1.fc27.x86_64
libssh2-devel-1.8.0-5.fc27.x86_64
libubsan-7.3.1-5.fc27.x86_64
libusbx-devel-1.0.21-4.fc27.x86_64
libxml2-devel-2.9.7-1.fc27.x86_64
llvm-5.0.1-6.fc27.x86_64
lzo-devel-2.08-11.fc27.x86_64
make-4.2.1-4.fc27.x86_64
mingw32-SDL-1.2.15-9.fc27.noarch
mingw32-bzip2-1.0.6-9.fc27.noarch
mingw32-curl-7.54.1-2.fc27.noarch
mingw32-glib2-2.54.1-1.fc27.noarch
mingw32-gmp-6.1.2-2.fc27.noarch
mingw32-gnutls-3.5.13-2.fc27.noarch
mingw32-gtk2-2.24.31-4.fc27.noarch
mingw32-gtk3-3.22.16-1.fc27.noarch
mingw32-libjpeg-turbo-1.5.1-3.fc27.noarch
mingw32-libpng-1.6.29-2.fc27.noarch
mingw32-libssh2-1.8.0-3.fc27.noarch
mingw32-libtasn1-4.13-1.fc27.noarch
mingw32-nettle-3.3-3.fc27.noarch
mingw32-pixman-0.34.0-3.fc27.noarch
mingw32-pkg-config-0.28-9.fc27.x86_64
mingw64-SDL-1.2.15-9.fc27.noarch
mingw64-bzip2-1.0.6-9.fc27.noarch
mingw64-curl-7.54.1-2.fc27.noarch
mingw64-glib2-2.54.1-1.fc27.noarch
mingw64-gmp-6.1.2-2.fc27.noarch
mingw64-gnutls-3.5.13-2.fc27.noarch
mingw64-gtk2-2.24.31-4.fc27.noarch
mingw64-gtk3-3.22.16-1.fc27.noarch
mingw64-libjpeg-turbo-1.5.1-3.fc27.noarch
mingw64-libpng-1.6.29-2.fc27.noarch
mingw64-libssh2-1.8.0-3.fc27.noarch
mingw64-libtasn1-4.13-1.fc27.noarch
mingw64-nettle-3.3-3.fc27.noarch
mingw64-pixman-0.34.0-3.fc27.noarch
mingw64-pkg-config-0.28-9.fc27.x86_64
ncurses-devel-6.0-13.20170722.fc27.x86_64
nettle-devel-3.4-1.fc27.x86_64
nss-devel-3.36.0-1.0.fc27.x86_64
numactl-devel-2.0.11-5.fc27.x86_64
package libjpeg-devel is not installed
perl-5.26.1-403.fc27.x86_64
pixman-devel-0.34.0-4.fc27.x86_64
python3-3.6.2-13.fc27.x86_64
snappy-devel-1.1.4-5.fc27.x86_64
sparse-0.5.1-2.fc27.x86_64
spice-server-devel-0.14.0-1.fc27.x86_64
systemtap-sdt-devel-3.2-3.fc27.x86_64
tar-1.29-7.fc27.x86_64
usbredir-devel-0.7.1-5.fc27.x86_64
virglrenderer-devel-0.6.0-3.20170210git76b3da97b.fc27.x86_64
vte3-devel-0.36.

[Qemu-devel] [PATCH] Show values and description when using "qom-list"

2018-04-13 Thread 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 
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).

Signed-off-by: Ricardo Perez Blanco 
---
 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