All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC 0/6] OptsVisitor: support / flatten integer ranges for repeating options
@ 2013-07-18 13:59 Laszlo Ersek
  2013-07-18 13:59 ` [Qemu-devel] [RFC 1/6] OptsVisitor: introduce basic list modes Laszlo Ersek
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Laszlo Ersek @ 2013-07-18 13:59 UTC (permalink / raw)
  To: qemu-devel, pbonzini, gaowanlong

Consider the following QAPI schema fragment, for the purpose of command
line parsing with OptsVisitor:

  { 'type': 'UInt16', 'data': { 'u16': 'uint16' }}

  { 'union': 'NumaOptions',
    'data': {
      'node': 'NumaNodeOptions',
      'mem' : 'NumaMemOptions' }}

  { 'type': 'NumaNodeOptions',
    'data': {
      '*nodeid': 'int',
      '*cpus'  : ['UInt16'] }}

  { 'type': 'NumaMemOptions',
    'data': {
      '*nodeid': 'int',
      '*size'  : 'size' }}

OptsVisitor already accepts the following command line with the above:

  -numa node,nodeid=3,cpus=0,cpus=1,cpus=2,cpus=6,cpus=7,cpus=8

Paolo suggested in
<http://thread.gmane.org/gmane.comp.emulators.qemu/222589/focus=222732>
that OptsVisitor should allow the following shortcut:

  -numa node,nodeid=3,cpus=0-2,cpus=6-8

and that the code processing the "cpus" list should encounter all six
elements (0, 1, 2, 6, 7, 8) individually.

The series tries to implement this. Both signed and unsigned values and
intervals should be supported:

  * 0     (zero)
  * 1-5   (one to five)
  * 4-4   (four to four, range with one element)
  * -2    (minus two)
  * -5-8  (minus two to plus eight)
  * -9--6 (minus nine to minus six)

As documented in commit eb7ee2cb, for parsing repeated options in
general, the list element type must be a struct with one mandatory
scalar field. For interval flattening, this underlying scalar type must
be an integer type. The restrictions imposed by its signedness and size
(in the above example, 'uint16') should be enforced entry-wise as usual.

That is, examining the 'uint16' example above with

  -numa node,nodeid=3,cpus=65534-65537

this is equivalent to

  -numa node,nodeid=3,cpus=65534,cpus=65535,cpus=65536,cpus=65537

and visit_type_uint16() [qapi/qapi-visit-core.c] will catch the first
element (= 65536) that has been parsed by opts_type_int() but cannot be
represented as 'uint16'.


I wrote this last night -- it is untested. I'm asking for help with a
gtester-based unit test. I'd appreciate if someone could whip up the
scaffolding (I don't even remember how to build & invoke the testers!)
and I'd fill in the test cases.

Thanks.

Laszlo Ersek (6):
  OptsVisitor: introduce basic list modes
  OptsVisitor: introduce list modes for interval flattening
  OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESS
  OptsVisitor: rebase opts_type_uint64() to parse_uint_full()
  OptsVisitor: opts_type_uint64(): recognize intervals when
    LM_IN_PROGRESS
  OptsVisitor: don't try to flatten overlong integer ranges

 include/qapi/opts-visitor.h |    6 ++
 qapi/opts-visitor.c         |  159 +++++++++++++++++++++++++++++++++++--------
 2 files changed, 135 insertions(+), 30 deletions(-)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-07-18 16:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-18 13:59 [Qemu-devel] [RFC 0/6] OptsVisitor: support / flatten integer ranges for repeating options Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 1/6] OptsVisitor: introduce basic list modes Laszlo Ersek
2013-07-18 14:53   ` Paolo Bonzini
2013-07-18 15:45     ` Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 2/6] OptsVisitor: introduce list modes for interval flattening Laszlo Ersek
2013-07-18 14:56   ` Paolo Bonzini
2013-07-18 15:57     ` Laszlo Ersek
2013-07-18 16:03       ` Paolo Bonzini
2013-07-18 16:14         ` Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 3/6] OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESS Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 4/6] OptsVisitor: rebase opts_type_uint64() to parse_uint_full() Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 5/6] OptsVisitor: opts_type_uint64(): recognize intervals when LM_IN_PROGRESS Laszlo Ersek
2013-07-18 13:59 ` [Qemu-devel] [RFC 6/6] OptsVisitor: don't try to flatten overlong integer ranges Laszlo Ersek

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.