[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 0/6] OptsVisitor: support / flatten integer ranges for
From: |
Laszlo Ersek |
Subject: |
[Qemu-devel] [RFC 0/6] OptsVisitor: support / flatten integer ranges for repeating options |
Date: |
Thu, 18 Jul 2013 15:59:18 +0200 |
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(-)
- [Qemu-devel] [RFC 0/6] OptsVisitor: support / flatten integer ranges for repeating options,
Laszlo Ersek <=
[Qemu-devel] [RFC 4/6] OptsVisitor: rebase opts_type_uint64() to parse_uint_full(), Laszlo Ersek, 2013/07/18
[Qemu-devel] [RFC 3/6] OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESS, Laszlo Ersek, 2013/07/18