Skip to content

OptsVisitor: support / flatten integer ranges for repeating options

Laszlo Ersek qemu-devel 2 versions – Applied

Status from this message: Applied to the qmp branch, thanks.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest8 patches 3 repliesApplied
  2. v18 patches 12 repliesSuperseded

Changes in v2 from the cover letter

- rebased to current master (patch #8 only applied with "git am -3"),
- now patch #7 adds "test-bitops" too to .gitignore,
- patch #8 updates "qapi-schema-test.out" to keep it in synch with the test schema changes warranted by the opts-visitor unit tests.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/8OptsVisitor: introduce basic list modesqapi/opts-visitor.c+35 -100 replies
2/8OptsVisitor: introduce list modes for interval flatteningqapi/opts-visitor.c+65 -20 replies
3/8OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESSqapi/opts-visitor.c+28 -60 replies
4/8OptsVisitor: rebase opts_type_uint64() to parse_uint_full()qapi/opts-visitor.c+5 -180 replies
5/8OptsVisitor: opts_type_uint64(): recognize intervals when LM_IN_PROGRESSqapi/opts-visitor.c+27 -50 replies
6/8OptsVisitor: don't try to flatten overlong integer rangesinclude/qapi/opts-visitor.h qapi/opts-visitor.c+11 -20 replies
7/8add "test-int128" and "test-bitops" to .gitignore.gitignore+2 -00 replies
8/8OptsVisitor: introduce unit tests, with test cases for range flattening.gitignore tests/Makefile tests/qapi-schema/qapi-schema-test.json +2 more+300 -30 replies

Reviews trailers per patch

None of the 8 patches has a Reviewed-by or Acked-by.

PatchWanlong Gao
SeriesT-b
1/8
2/8
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/8] OptsVisitor: support / flatten integer ranges for repeating options

v1->v2:
- rebased to current master (patch #8 only applied with "git am -3"),
- now patch #7 adds "test-bitops" too to .gitignore,
- patch #8 updates "qapi-schema-test.out" to keep it in synch with the test schema changes warranted by the opts-visitor unit tests.

rfc->v1:
- addressed Paolo's comments for patches 1 and 2,
- patches 7 and 8 are new (unit tests),
- updated the cover letter to take native lists into account, plus cleaned it up.

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

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

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

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

(Commit eb7ee2cb ("qapi: introduce OptsVisitor") had originally documented OptsVisitor's general schema requirements for parsing repeated options such that the list element type had to be a struct with one mandatory scalar field. Accordingly, the RFC version of this series required for interval flattening that this underlying scalar type be an integer type. However, since commit a678e26c ("qapi: pad GenericList value fields to 64 bits") we've had reliable native lists; OptsVisitor turns out to support them automatically.)

OptsVisitor already accepts the following command line with the above schema:

-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 implements this feature. Both signed and unsigned values and intervals are supported in general:

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

* -9--6 (minus nine to minus six)

The restrictions imposed by the native list element's signedness and size (in the above schema example, 'uint16') are enforced element-wise as usual. That is, for 'uint16', the command line option

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

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'.

Laszlo Ersek (8):
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 add "test-int128" and "test-bitops" to .gitignore
OptsVisitor: introduce unit tests, with test cases for range
flattening

 tests/Makefile                          |    6 +-
 tests/qapi-schema/qapi-schema-test.json |   15 ++
 include/qapi/opts-visitor.h             |    6 +
 qapi/opts-visitor.c                     |  184 +++++++++++++++++----
 tests/test-opts-visitor.c               |  275 +++++++++++++++++++++++++++++++
 .gitignore                              |    3 +
 tests/qapi-schema/qapi-schema-test.out  |    6 +-
 7 files changed, 461 insertions(+), 34 deletions(-)
 create mode 100644 tests/test-opts-visitor.c