Re: [Qemu-devel] [PATCH for-2.5] block: make 'stats-intervals' a list of integers

2015-11-11 Thread Eric Blake
On 11/11/2015 06:17 AM, Alberto Garcia wrote:
> This is the natural JSON representation and prevents us from having to
> decode the list manually.
> 
> Signed-off-by: Alberto Garcia 
> ---
>  blockdev.c | 64 
> ++
>  qapi/block-core.json   |  7 +++---
>  tests/qemu-iotests/136 |  2 +-
>  3 files changed, 48 insertions(+), 25 deletions(-)
> 

> +for (entry = qlist_first(interval_list); entry;
> + entry = qlist_next(entry)) {
> +unsigned length;
> +switch (qobject_type(entry->value)) {
>  
> -if (*stats_intervals == '\0') {
> -error_setg(, "stats-intervals can't have an empty 
> value");
> -}
> -
> -for (i = 0; !error && intervals[i] != NULL; i++) {
> +case QTYPE_QSTRING: {

> +case QTYPE_QINT: {

Why are we accepting both string and int here, but typing it as 'int' in
qapi?  I guess its due to how command line parsing passes in strings
rather than ints?

But that should be okay.

Reviewed-by: Eric Blake 

We may eventually want to add an alternate type that takes both int and
string from QMP (parsing the port number of server addresses is another
spot that could benefit from such an alternate), but that's a project
for 2.6.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature


Re: [Qemu-devel] [PATCH for-2.5] block: make 'stats-intervals' a list of integers

2015-11-11 Thread Alberto Garcia
On Wed 11 Nov 2015 04:32:42 PM CET, Eric Blake wrote:
>> -for (i = 0; !error && intervals[i] != NULL; i++) {
>> +case QTYPE_QSTRING: {
>
>> +case QTYPE_QINT: {
>
> Why are we accepting both string and int here, but typing it as 'int' in
> qapi?  I guess its due to how command line parsing passes in strings
> rather than ints?

Yes.

Berto