All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: mdroth@linux.vnet.ibm.com, qemu-devel@nongnu.org, afaerber@suse.de
Subject: Re: [Qemu-devel] [PATCH 1/2] add visitor for parsing int[KMGT] input string
Date: Fri, 14 Dec 2012 14:20:48 +0100	[thread overview]
Message-ID: <20121214142048.3b98e8e0@thinkpad.mammed.net> (raw)
In-Reply-To: <20121212181642.GI3236@otherpad.lan.raisama.net>

On Wed, 12 Dec 2012 16:16:42 -0200
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, Dec 10, 2012 at 10:33:06PM +0100, Igor Mammedov wrote:
> > Caller of visit_type_suffixed_int() have to specify
> > value of 'K' suffix using suffix_factor argument.
> > Example of selecting suffix_factor value:
> >  * Kbytes: 1024
> >  * Khz: 1000
> > 
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> 
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
> 
> 
> I wonder if we could later introduce a visit_type_frequency() function
> that simply calls visit_type_suffixed_int(). This would allow us to use
> a 'frequency' type on QAPI, like the existing 'size' type we already
> have.
> 
> I suggest having explicitly distinct types on QAPI because the 'size'
> type probably won't abort (and maybe it _can't_ abort, to keep
> compatibility) in case it finds a "100MB" string. Likewise, the
It won't accept MB with current code, but we could probably pass
something like custom suffix table {KHz => 1000, MHz=>1000000, ...}  instead
of unit for variables that accept frequency, and a corresponding table for
sizes and whatever else if needed. Than we could use only
visit_type_suffixed_int() and avoid creating an extra boiler code for every
kind of units that might be needed in future.
  
> 'frequency' type wouldn't abort in case it finds a "100MHz" string.
> 
> With separate types, we could also make the 'frequency' type _not_
> accept "100B" as a valid string (strtosz_suffix_unit() accepts "B" as a
> valid suffix, today).
> 
> 
> > ---
> >  v3:
> >   - Fix errp check. Spotted-By: Andreas Färber <afaerber@suse.de>
> >   - s/type_unit_suffixed_int/type_suffixed_int/
> >   - use 'suffix_factor' instead of 'unit'
> >   - document visit_type_suffixed_int()
> >   - add comment on current impl. limitation
> >  v2:
> >   - convert type_freq to type_unit_suffixed_int.
> >   - provide qapi_dealloc_type_unit_suffixed_int() impl.
> > ---
> >  qapi/qapi-dealloc-visitor.c |  8 ++++++++
> >  qapi/qapi-visit-core.c      | 35 +++++++++++++++++++++++++++++++++++
> >  qapi/qapi-visit-core.h      |  4 ++++
> >  qapi/string-input-visitor.c | 25 +++++++++++++++++++++++++
> >  4 files changed, 72 insertions(+)
> > 
> [...]
> 
> -- 
> Eduardo
> 


-- 
Regards,
  Igor

  reply	other threads:[~2012-12-14 13:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-10 21:33 [Qemu-devel] [PATCH 0/2 v2] introduce visitor for parsing suffixed integer Igor Mammedov
2012-12-10 21:33 ` [Qemu-devel] [PATCH 1/2] add visitor for parsing int[KMGT] input string Igor Mammedov
2012-12-12 18:16   ` Eduardo Habkost
2012-12-14 13:20     ` Igor Mammedov [this message]
2012-12-14 18:18       ` Eduardo Habkost
2012-12-10 21:33 ` [Qemu-devel] [PATCH 2/2] target-i386: use visit_type_suffixed_int() to parse tsc_freq property value Igor Mammedov
2012-12-12 18:16   ` Eduardo Habkost
2012-12-23 20:34 ` [Qemu-devel] [PATCH 0/2 v2] introduce visitor for parsing suffixed integer Anthony Liguori
2012-12-24 14:03   ` Igor Mammedov
2012-12-26 12:51   ` Eduardo Habkost

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=20121214142048.3b98e8e0@thinkpad.mammed.net \
    --to=imammedo@redhat.com \
    --cc=afaerber@suse.de \
    --cc=ehabkost@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /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.