qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 0/8] OptsVisitor: support / flatten integer ranges for repeating options
Date: Mon, 22 Jul 2013 23:07:28 +0200	[thread overview]
Message-ID: <1374527256-27631-1-git-send-email-lersek@redhat.com> (raw)

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" to .gitignore
  OptsVisitor: introduce unit tests, with test cases for range
    flattening

 tests/Makefile              |    6 +-
 qapi-schema-test.json       |   15 +++
 include/qapi/opts-visitor.h |    6 +
 qapi/opts-visitor.c         |  184 ++++++++++++++++++++++++-----
 tests/test-opts-visitor.c   |  275 +++++++++++++++++++++++++++++++++++++++++++
 .gitignore                  |    2 +
 6 files changed, 456 insertions(+), 32 deletions(-)
 create mode 100644 tests/test-opts-visitor.c

             reply	other threads:[~2013-07-22 21:19 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-22 21:07 Laszlo Ersek [this message]
2013-07-22 21:07 ` [Qemu-devel] [PATCH 1/8] OptsVisitor: introduce basic list modes Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 2/8] OptsVisitor: introduce list modes for interval flattening Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 3/8] OptsVisitor: opts_type_int(): recognize intervals when LM_IN_PROGRESS Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 4/8] OptsVisitor: rebase opts_type_uint64() to parse_uint_full() Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 5/8] OptsVisitor: opts_type_uint64(): recognize intervals when LM_IN_PROGRESS Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 6/8] OptsVisitor: don't try to flatten overlong integer ranges Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 7/8] add "test-int128" to .gitignore Laszlo Ersek
2013-07-22 21:07 ` [Qemu-devel] [PATCH 8/8] OptsVisitor: introduce unit tests, with test cases for range flattening Laszlo Ersek
2013-07-22 22:04   ` Eric Blake
2013-07-22 22:24     ` Laszlo Ersek
2013-07-22 22:26       ` Eric Blake
2013-07-22 22:37         ` Laszlo Ersek
2013-08-19 19:26   ` Luiz Capitulino
2013-08-19 19:55     ` Laszlo Ersek
2013-08-19 20:04       ` Laszlo Ersek
2013-07-29  9:47 ` [Qemu-devel] [PATCH 0/8] OptsVisitor: support / flatten integer ranges for repeating options Laszlo Ersek
2013-07-29 11:01   ` Paolo Bonzini
2013-07-29 11:11     ` Wanlong Gao
2013-07-29 11:30       ` Laszlo Ersek
2013-08-16  7:15 ` Laszlo Ersek

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=1374527256-27631-1-git-send-email-lersek@redhat.com \
    --to=lersek@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).