All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication
@ 2017-10-02 15:25 Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@' Markus Armbruster
                   ` (31 more replies)
  0 siblings, 32 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

This is a prototype to demonstrate where I'm headed.  PATCH 01-28 are
infrastructure, PATCH 29-32 QAPIfy a few options.

Plenty of infrastrucure work remains.  Some of it is marked TODO/FIXME
in the patches.  I've excluded work to improve backward keyval.c
compatibility with QemuOpts quirks for now.

Command line introspection is provided by query-qmp-schema for now.
Perhaps it should be separate.  See PATCH 25.

Documentation is generated into qemu-qmp-ref.*.  Perhaps it should be
separate.  See PATCH 26.

main() iterates over argv[] twice.  The second loop "executes" some
options directly.  PATCH 29+30 QAPIfy two of them.  Other options it
converts into a more convenient form, for later execution.  PATCH
31+32 QAPIfy two of them: the conversion becomes a no-op, because
QAPIfication already produces a convenient data type.

"Later execution" means the command line is executed in some magic
order mortal users can't predict.  Strict left-to-right would be
simpler and cleaner, but backward compatibility may compel us to
remain complicated and unclean.

qemu-img already duplicates --option.  I suspect we'll end up wanting
to QAPIfy that as well, sharing the common part of the QAPI schema.

Based-on: 20171002111111.26932-1-armbru@redhat.com
    [PULL 0/3] QAPI patches for 2017-10-02
Based-on: 20171002134538.23332-1-armbru@redhat.com
    [PATCH 0/3] hmp-commands-info: Texinfo fixes
Based-on: 20171002140307.5292-1-armbru@redhat.com
    [PATCH 0/8] qemu-options: Texinfo and --help fixes
Based-on: 20171002141341.24616-1-armbru@redhat.com
    [PATCH 00/11] qapi: Cleanups around qapi2texi

Markus Armbruster (32):
  tests/qapi-schema: Improve coverage of '@'
  texi2pod: Support @verbatim environment
  qapi2texi: Fix for examples containing '@'
  qapi2texi: Fix for '@' not followed by \w character
  qapi2texi: Provide access to Texinfo markup
  qapi2texi: Drop | example markup
  qapi: Drop superfluous allow_optional=True
  qapi: Simplify check_name() parameters
  qapi: check_type() parameter allow_optional is now unused, drop
  qapi: Don't run generators twice
  qapi: Drop the options to generate only .c or .h
  qapi: Use argparse to parse command line arguments
  qapi: Use argparse to open schema file
  qapi: Rework generated code for built-in types
  tests/qapi-schema: Improve simple union coverage
  qapi: Factor out _make_implicit_wrapper_type()
  qapi: Fix simple union lowering with multiple schemas
  docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax
  qapi: Accept double-quoted strings
  qapi: Frontend for defining command line options
  qapi: Define QAPIOptionKind and QAPIOption automatically
  qapi: New helper c_string()
  qapi-options: Command line option backend
  qapi-options: Generate help string
  qapi-introspect: Include command line options information
  qapi2texi: Include command line options information
  os-posix: Drop misleading comment
  vl: QAPIfy command line option definition
  qapi/options: QAPIfy --echr argument type
  qapi/options: QAPIfy --watchdog-action argument type
  qapi/options: QAPIfy --blockdev argument type
  qapi/options: QAPIfy --add-fd argument type

 .gitignore                               |    4 +-
 Makefile                                 |  101 +-
 Makefile.objs                            |    4 +-
 docs/devel/qapi-code-gen.txt             |   83 +-
 include/qemu-common.h                    |    2 +-
 os-posix.c                               |   27 +-
 os-win32.c                               |    3 +-
 qapi-schema.json                         |    9 +-
 qapi/introspect.json                     |   22 +-
 qapi/options.json                        | 4574 ++++++++++++++++++++++++++++++
 qemu-doc.texi                            |    4 +-
 qemu-options-wrapper.h                   |   41 -
 qemu-options.h                           |   36 -
 qemu-options.hx                          | 4256 ---------------------------
 qga/Makefile.objs                        |    1 +
 scripts/qapi-commands.py                 |   13 +-
 scripts/qapi-event.py                    |   12 +-
 scripts/qapi-introspect.py               |   44 +-
 scripts/qapi-options.py                  |  212 ++
 scripts/qapi-types.py                    |   78 +-
 scripts/qapi-visit.py                    |   74 +-
 scripts/qapi.py                          |  350 ++-
 scripts/qapi2texi.py                     |   88 +-
 scripts/texi2pod.pl                      |   11 +-
 tests/Makefile.include                   |   56 +-
 tests/qapi-schema/builtins.err           |    0
 tests/qapi-schema/builtins.exit          |    1 +
 tests/qapi-schema/builtins.json          |    1 +
 tests/qapi-schema/builtins.out           |   33 +
 tests/qapi-schema/comments.out           |    3 -
 tests/qapi-schema/doc-bad-section.out    |    3 -
 tests/qapi-schema/doc-good.json          |   46 +-
 tests/qapi-schema/doc-good.out           |   70 +-
 tests/qapi-schema/doc-good.texi          |   82 +-
 tests/qapi-schema/empty.out              |    3 -
 tests/qapi-schema/event-case.out         |    3 -
 tests/qapi-schema/ident-with-escape.out  |    3 -
 tests/qapi-schema/include-relpath.out    |    3 -
 tests/qapi-schema/include-repetition.out |    3 -
 tests/qapi-schema/include-simple.out     |    3 -
 tests/qapi-schema/indented-expr.out      |    3 -
 tests/qapi-schema/qapi-schema-test.json  |   26 +-
 tests/qapi-schema/qapi-schema-test.out   |   64 +-
 tests/qapi-schema/test-qapi.py           |   22 +-
 tests/test-qapi-options.c                |   74 +
 vl.c                                     |  809 +++---
 46 files changed, 6151 insertions(+), 5209 deletions(-)
 create mode 100644 qapi/options.json
 delete mode 100644 qemu-options-wrapper.h
 delete mode 100644 qemu-options.h
 delete mode 100644 qemu-options.hx
 create mode 100644 scripts/qapi-options.py
 create mode 100644 tests/qapi-schema/builtins.err
 create mode 100644 tests/qapi-schema/builtins.exit
 create mode 100644 tests/qapi-schema/builtins.json
 create mode 100644 tests/qapi-schema/builtins.out
 create mode 100644 tests/test-qapi-options.c

-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@'
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:37   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment Markus Armbruster
                   ` (30 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Demonstrates a qapi2texi.py bug: it can fail to escape '@'.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/qapi-schema/doc-good.json | 3 +++
 tests/qapi-schema/doc-good.out  | 3 +++
 tests/qapi-schema/doc-good.texi | 4 ++++
 3 files changed, 10 insertions(+)

diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 97ab4625ff..44098d7f1a 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -10,6 +10,7 @@
 #
 # *strong* _with emphasis_
 # @var {in braces}
+# lone @ BUG: gets passed to Texinfo unescaped
 # * List item one
 # - Two, multiple
 #   lines
@@ -46,6 +47,7 @@
 # <- out
 # Examples:
 # - *verbatim*
+# - @at sign
 # - {braces}
 ##
 
@@ -115,6 +117,7 @@
 # <- out
 # Examples:
 # - *verbatim*
+# - @at sign BUG: gets passed to Texinfo unescaped
 # - {braces}
 # Since: 2.10
 ##
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 1d2c250527..b732b81119 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -38,6 +38,7 @@ doc freeform
 
 *strong* _with emphasis_
 @var {in braces}
+lone @ BUG: gets passed to Texinfo unescaped
 * List item one
 - Two, multiple
 lines
@@ -74,6 +75,7 @@ Example:
 <- out
 Examples:
 - *verbatim*
+- @at sign
 - {braces}
 doc symbol=Enum
     body=
@@ -136,6 +138,7 @@ Duis aute irure dolor
 <- out
     section=Examples
 - *verbatim*
+- @at sign BUG: gets passed to Texinfo unescaped
 - {braces}
     section=Since
 2.10
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 1778312581..840a492249 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -4,6 +4,7 @@
 
 @strong{strong} @emph{with emphasis}
 @code{var} @{in braces@}
+lone @ BUG: gets passed to Texinfo unescaped
 @itemize @bullet
 @item
 List item one
@@ -69,6 +70,8 @@ Examples:
 @item
 @strong{verbatim}
 @item
+@code{at} sign
+@item
 @{braces@}
 @end itemize
 
@@ -206,6 +209,7 @@ Duis aute irure dolor
 @b{Examples:}
 @example
 - *verbatim*
+- @at sign BUG: gets passed to Texinfo unescaped
 - @{braces@}
 @end example
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@' Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-05 14:58   ` Eric Blake
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@' Markus Armbruster
                   ` (29 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/texi2pod.pl | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
index 39ce584a32..2171f8b819 100755
--- a/scripts/texi2pod.pl
+++ b/scripts/texi2pod.pl
@@ -85,6 +85,13 @@ if (defined $out) {
 
 while(defined $inf) {
 while(<$inf>) {
+    # Verbatim environment
+    if (defined $endw and $endw eq "verbatim"
+	and not (/^\@end\s+([a-z]+)/ and $1 eq $endw)) {
+	$section .= "\t".$_;
+	next;
+    }
+
     # Certain commands are discarded without further processing.
     /^\@(?:
 	 [a-z]+index		# @*index: useful only in complete manual
@@ -165,7 +172,7 @@ while(<$inf>) {
 	if ($ended =~ /^(?:ifset|ifclear|ignore|menu|iftex)$/) {
 	    $skipping = pop @skstack;
 	    next;
-	} elsif ($ended =~ /^(?:example|smallexample|display
+	} elsif ($ended =~ /^(?:example|smallexample|display|verbatim
                             |quotation|deftp|deftypefn)$/x) {
 	    $shift = "";
 	    $_ = "";	# need a paragraph break
@@ -311,7 +318,7 @@ while(<$inf>) {
 	$_ = "\n=over 4\n";
     };
 
-    /^\@((?:small)?example|display)/ and do {
+    /^\@((?:small)?example|display|verbatim)/ and do {
 	push @endwstack, $endw;
 	$endw = $1;
 	$shift = "\t";
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@'
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@' Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:45   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character Markus Armbruster
                   ` (28 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Instead of quoting example text so that the @example environment shows
it verbatim, simply use the @verbatim environment.

Examples are no longer indented in output, because makeinfo doesn't
indent @verbatim, unlike @example.
TODO keep indentation somehow?

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi2texi.py            | 12 +++++-------
 tests/qapi-schema/doc-good.json |  2 +-
 tests/qapi-schema/doc-good.out  |  2 +-
 tests/qapi-schema/doc-good.texi | 16 ++++++++--------
 4 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index 92e2af2cd6..1500afc553 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -52,13 +52,11 @@ def subst_braces(doc):
 
 
 def texi_example(doc):
-    """Format @example"""
-    # TODO: Neglects to escape @ characters.
-    # We should probably escape them in subst_braces(), and rename the
-    # function to subst_special() or subs_texi_special().  If we do that, we
-    # need to delay it until after subst_vars() in texi_format().
-    doc = subst_braces(doc).strip('\n')
-    return EXAMPLE_FMT(code=doc)
+    """Format example text"""
+    return """@verbatim
+{code}
+@end verbatim
+""".format(code=doc.strip('\n'))
 
 
 def texi_format(doc):
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 44098d7f1a..54a0012d5f 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -117,7 +117,7 @@
 # <- out
 # Examples:
 # - *verbatim*
-# - @at sign BUG: gets passed to Texinfo unescaped
+# - @at sign
 # - {braces}
 # Since: 2.10
 ##
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index b732b81119..a62d2d879c 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -138,7 +138,7 @@ Duis aute irure dolor
 <- out
     section=Examples
 - *verbatim*
-- @at sign BUG: gets passed to Texinfo unescaped
+- @at sign
 - {braces}
     section=Since
 2.10
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 840a492249..3b77f2f675 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -201,17 +201,17 @@ Ut enim ad minim veniam
 Duis aute irure dolor
 
 @b{Example:}
-@example
+@verbatim
 -> in
 <- out
-@end example
+@end verbatim
 
 @b{Examples:}
-@example
+@verbatim
 - *verbatim*
-- @at sign BUG: gets passed to Texinfo unescaped
-- @{braces@}
-@end example
+- @at sign
+- {braces}
+@end verbatim
 
 @b{Since:}
 2.10
@@ -227,11 +227,11 @@ If you're bored enough to read this, go see a video of boxed cats
 @b{Arguments:} the members of @code{Object}
 
 @b{Example:}
-@example
+@verbatim
 -> in
 
 <- out
-@end example
+@end verbatim
 
 @end deftypefn
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (2 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@' Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:47   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 05/32] qapi2texi: Provide access to Texinfo markup Markus Armbruster
                   ` (27 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi2texi.py            | 22 ++++++++++++----------
 tests/qapi-schema/doc-good.json |  2 +-
 tests/qapi-schema/doc-good.out  |  2 +-
 tests/qapi-schema/doc-good.texi |  2 +-
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index 1500afc553..cfcd8a19f0 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -41,14 +41,17 @@ def subst_emph(doc):
     return re.sub(r'\b_([^_\n]+)_\b', r'@emph{\1}', doc)
 
 
-def subst_vars(doc):
-    """Replaces @var by @code{var}"""
-    return re.sub(r'@([\w-]+)', r'@code{\1}', doc)
-
-
-def subst_braces(doc):
-    """Replaces {} with @{ @}"""
-    return doc.replace('{', '@{').replace('}', '@}')
+def subst_special(doc):
+    ret = ''
+    for m in re.finditer(r'([^@{}]*)(@([-\w]*)|[{}])?', doc):
+        ret += m.group(1)
+        if m.group(3):
+            # format @NAME as @code{NAME}
+            ret += '@code{' + m.group(3) + '}'
+        elif m.group(2):
+            # escape Texinfo's special characters
+            ret += '@' + m.group(2)
+    return ret
 
 
 def texi_example(doc):
@@ -71,8 +74,7 @@ def texi_format(doc):
     - */-: generates an @itemize list
     """
     ret = ''
-    doc = subst_braces(doc)
-    doc = subst_vars(doc)
+    doc = subst_special(doc)
     doc = subst_emph(doc)
     doc = subst_strong(doc)
     inlist = ''
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 54a0012d5f..274004a8b6 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -10,7 +10,7 @@
 #
 # *strong* _with emphasis_
 # @var {in braces}
-# lone @ BUG: gets passed to Texinfo unescaped
+# lone @
 # * List item one
 # - Two, multiple
 #   lines
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index a62d2d879c..46261d5010 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -38,7 +38,7 @@ doc freeform
 
 *strong* _with emphasis_
 @var {in braces}
-lone @ BUG: gets passed to Texinfo unescaped
+lone @
 * List item one
 - Two, multiple
 lines
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 3b77f2f675..8777cbb7fb 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -4,7 +4,7 @@
 
 @strong{strong} @emph{with emphasis}
 @code{var} @{in braces@}
-lone @ BUG: gets passed to Texinfo unescaped
+lone @@
 @itemize @bullet
 @item
 List item one
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 05/32] qapi2texi: Provide access to Texinfo markup
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (3 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 06/32] qapi2texi: Drop | example markup Markus Armbruster
                   ` (26 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

qapi2texi supports very limited formatting markup reminiscent of
MarkDown, which it translates to Texinfo.  It's basically defined by
example, and has multiple issues, in particular with lists.
Nevertheless, it has served our (modest) needs so far.

However, our needs are about to grow: I'm going to move command line
documentation from qemu-options.hx into schema doc comments, similar
to how we moved QMP documentation in merge commit 23eb9e6.  The QMP
documentation was plain text, and the markup was created to make it
look decent in generated Texinfo with minimal change.  The command
line documentation is already in Texinfo.  Dumbing it down to what
qapi2texi supports would be a lot of work, for a sad result.  Making
qapi2texi sufficiently powerful for a non-sad result would also be a
lot of work, and stupid; the world doesn't need more text markup
languages.  Not even more text markup language implementations.

Supporting Texinfo in doc comments would be ideal.  Can't do, since we
blew the '@' character on schema name references.  Instead, let's try
the stupidest solution that could possibly work: provide an escape to
Texinfo.  Looks like this:

    # !texinfo
    # @c This is Texinfo
    # @appendix Tips and Tricks
    # !end texinfo

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/devel/qapi-code-gen.txt    | 13 +++++++++++++
 scripts/qapi2texi.py            | 19 ++++++++++++++++---
 tests/qapi-schema/doc-good.json | 11 +++++++++++
 tests/qapi-schema/doc-good.out  | 11 +++++++++++
 tests/qapi-schema/doc-good.texi |  9 +++++++++
 5 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index f04c63fe82..0334ef37ef 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -97,6 +97,9 @@ permitted.
 do not work over multiple lines). @foo is used to reference a name in
 the schema.
 
+You can also embed Texinfo markup.  '!texinfo' switches to Texinfo,
+and '!end texinfo' switches back.
+
 Example:
 
 ##
@@ -112,6 +115,16 @@ Example:
 # | -> do this
 # | <- get that
 #
+# Texinfo markup:
+# !texinfo
+# @table @samp
+# @item foo
+# This is the text for
+# @samp{foo}.
+# @item bar
+# Text for @samp{bar}.
+# @end table
+# !end texinfo
 ##
 
 
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index cfcd8a19f0..e356f911bb 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -74,14 +74,27 @@ def texi_format(doc):
     - */-: generates an @itemize list
     """
     ret = ''
-    doc = subst_special(doc)
-    doc = subst_emph(doc)
-    doc = subst_strong(doc)
     inlist = ''
+    intexi = False
     lastempty = False
+
     for line in doc.split('\n'):
         empty = line == ''
 
+        if not intexi and line == '!texinfo':
+            intexi = True
+            continue
+        if intexi and line == '!end texinfo':
+            intexi = False
+            continue
+        if intexi:
+            ret += line + '\n'
+            continue
+
+        line = subst_special(line)
+        line = subst_emph(line)
+        line = subst_strong(line)
+
         # FIXME: Doing this in a single if / elif chain is
         # problematic.  For instance, a line without markup terminates
         # a list if it follows a blank line (reaches the final elif),
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 274004a8b6..5fcca8dc85 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -31,6 +31,17 @@
 # | example
 # | multiple lines
 #
+# !texinfo
+# @table @samp
+# @item foo
+# This is the text for
+# @samp{foo}.
+#
+# @item bar
+# Text for @samp{bar}.
+# @end table
+# !end texinfo
+#
 # Returns: the King
 # Since: the first age
 # Notes:
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 46261d5010..7c4aecbaa2 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -59,6 +59,17 @@ is numbered
 | example
 | multiple lines
 
+!texinfo
+@table @samp
+@item foo
+This is the text for
+@samp{foo}.
+
+@item bar
+Text for @samp{bar}.
+@end table
+!end texinfo
+
 Returns: the King
 Since: the first age
 Notes:
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 8777cbb7fb..b7171ff6d1 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -44,8 +44,17 @@ multiple lines
 @end example
 
 
+@table @samp
+@item foo
+This is the text for
+@samp{foo}.
+
+@item bar
+Text for @samp{bar}.
+@end table
 @end enumerate
 
+
 Returns: the King
 Since: the first age
 Notes:
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 06/32] qapi2texi: Drop | example markup
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (4 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 05/32] qapi2texi: Provide access to Texinfo markup Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True Markus Armbruster
                   ` (25 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Doc comment lines starting with '|' are examples.  qapi2texi.py puts
each line in its own @example environment, which is wrong.
Fortunately, this kind of example markup is used in just one place
outside tests.  Replace it by Texinfo markup, and drop the '|'
feature.

tests/qapi-schema/doc-good.texi changes, because unlike the '|'
markup, !texinfo terminates lists.  See the FIXME in texi_format().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/devel/qapi-code-gen.txt    | 10 ----------
 qapi-schema.json                |  8 ++++++--
 scripts/qapi2texi.py            |  9 +--------
 tests/qapi-schema/doc-good.json |  8 ++++++--
 tests/qapi-schema/doc-good.out  |  8 ++++++--
 tests/qapi-schema/doc-good.texi | 10 +++-------
 6 files changed, 22 insertions(+), 31 deletions(-)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 0334ef37ef..579807f6a5 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -65,11 +65,6 @@ Double the '=' for a subsection title:
 
     # == Subection title
 
-'|' denotes examples:
-
-    # | Text of the example, may span
-    # | multiple lines
-
 '*' starts an itemized list:
 
     # * First item, may span
@@ -110,11 +105,6 @@ Example:
 # 1. with a list
 # 2. like that
 #
-# And some code:
-# | $ echo foo
-# | -> do this
-# | <- get that
-#
 # Texinfo markup:
 # !texinfo
 # @table @samp
diff --git a/qapi-schema.json b/qapi-schema.json
index 3490a5edaf..a6ef550fd5 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -20,8 +20,12 @@
 #
 # Example:
 #
-# | -> data issued by the Client
-# | <- Server data response
+# !texinfo
+# @verbatim
+# -> data issued by the Client
+# <- Server data response
+# @end verbatim
+# !end texinfo
 #
 # Please, refer to the QMP specification (docs/interop/qmp-spec.txt) for
 # detailed information on the Server command and response formats.
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index e356f911bb..bfd1c676e1 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -25,11 +25,6 @@ TYPE_FMT = """
 
 """.format
 
-EXAMPLE_FMT = """@example
-{code}
-@end example
-""".format
-
 
 def subst_strong(doc):
     """Replaces *foo* by @strong{foo}"""
@@ -103,9 +98,7 @@ def texi_format(doc):
         #
         # Make sure to update section "Documentation markup" in
         # docs/devel/qapi-code-gen.txt when fixing this.
-        if line.startswith('| '):
-            line = EXAMPLE_FMT(code=line[2:])
-        elif line.startswith('= '):
+        if line.startswith('= '):
             line = '@section ' + line[2:]
         elif line.startswith('== '):
             line = '@subsection ' + line[3:]
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index 5fcca8dc85..d3ddf828ef 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -28,8 +28,12 @@
 #
 # - another item
 #
-# | example
-# | multiple lines
+# !texinfo
+# @verbatim
+# example
+# multiple lines
+# @end verbatim
+# !end texinfo
 #
 # !texinfo
 # @table @samp
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index 7c4aecbaa2..f0ba51db4b 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -56,8 +56,12 @@ is numbered
 
 - another item
 
-| example
-| multiple lines
+!texinfo
+@verbatim
+example
+multiple lines
+@end verbatim
+!end texinfo
 
 !texinfo
 @table @samp
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index b7171ff6d1..4a9162c2a2 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -35,13 +35,11 @@ is numbered
 @item
 another item
 
-@example
+@verbatim
 example
-@end example
-
-@example
 multiple lines
-@end example
+@end verbatim
+@end enumerate
 
 
 @table @samp
@@ -52,8 +50,6 @@ This is the text for
 @item bar
 Text for @samp{bar}.
 @end table
-@end enumerate
-
 
 Returns: the King
 Since: the first age
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (5 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 06/32] qapi2texi: Drop | example markup Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:52   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters Markus Armbruster
                   ` (24 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

check_command() passes allow_optional=True to check_type().  Useless
unless you also pass allow_dict=True, which check_command() doesn't.
Drop the superfluous argument.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 43a54bf40f..248af89b0b 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -695,7 +695,7 @@ def check_command(expr, info):
         returns_meta += ['built-in', 'alternate', 'enum']
     check_type(info, "'returns' for command '%s'" % name,
                expr.get('returns'), allow_array=True,
-               allow_optional=True, allow_metas=returns_meta)
+               allow_metas=returns_meta)
 
 
 def check_event(expr, info):
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (6 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:54   ` Marc-André Lureau
  2017-10-04 10:54   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop Markus Armbruster
                   ` (23 subsequent siblings)
  31 siblings, 2 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Replace flags @enum_member, @allow_optional by string @meta:
'member-enum' implies @enum_member, 'member-struct' implies
@allow_optional.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 248af89b0b..208010c241 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -593,8 +593,7 @@ valid_name = re.compile(r'^(__[a-zA-Z0-9.-]+_)?'
                         '[a-zA-Z][a-zA-Z0-9_-]*$')
 
 
-def check_name(info, source, name, allow_optional=False,
-               enum_member=False):
+def check_name(info, source, name, meta):
     global valid_name
     membername = name
 
@@ -602,12 +601,12 @@ def check_name(info, source, name, allow_optional=False,
         raise QAPISemError(info, "%s requires a string name" % source)
     if name.startswith('*'):
         membername = name[1:]
-        if not allow_optional:
+        if meta != 'member-struct':
             raise QAPISemError(info, "%s does not allow optional name '%s'"
                                % (source, name))
     # Enum members can start with a digit, because the generated C
     # code always prefixes it with the enum name
-    if enum_member and membername[0].isdigit():
+    if meta == 'member-enum' and membername[0].isdigit():
         membername = 'D' + membername
     # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty'
     # and 'q_obj_*' implicit type names.
@@ -618,7 +617,7 @@ def check_name(info, source, name, allow_optional=False,
 
 def add_name(name, info, meta, implicit=False):
     global all_names
-    check_name(info, "'%s'" % meta, name)
+    check_name(info, "'%s'" % meta, name, meta)
     # FIXME should reject names that differ only in '_' vs. '.'
     # vs. '-', because they're liable to clash in generated C.
     if name in all_names:
@@ -667,8 +666,7 @@ def check_type(info, source, value, allow_array=False,
 
     # value is a dictionary, check that each member is okay
     for (key, arg) in value.items():
-        check_name(info, "Member of %s" % source, key,
-                   allow_optional=allow_optional)
+        check_name(info, "Member of %s" % source, key, 'member-struct')
         if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'):
             raise QAPISemError(info, "Member of %s uses reserved name '%s'"
                                % (source, key))
@@ -741,7 +739,7 @@ def check_union(expr, info):
         # The value of member 'discriminator' must name a non-optional
         # member of the base struct.
         check_name(info, "Discriminator of flat union '%s'" % name,
-                   discriminator)
+                   discriminator, 'member-union')
         discriminator_type = base_members.get(discriminator)
         if not discriminator_type:
             raise QAPISemError(info,
@@ -760,7 +758,7 @@ def check_union(expr, info):
     if len(members) == 0:
         raise QAPISemError(info, "Union '%s' cannot have empty 'data'" % name)
     for (key, value) in members.items():
-        check_name(info, "Member of union '%s'" % name, key)
+        check_name(info, "Member of union '%s'" % name, key, 'member-union')
 
         # Each value must name a known type
         check_type(info, "Member '%s' of union '%s'" % (key, name),
@@ -794,7 +792,8 @@ def check_alternate(expr, info):
                            "Alternate '%s' should have at least two branches "
                            "in 'data'" % name)
     for (key, value) in members.items():
-        check_name(info, "Member of alternate '%s'" % name, key)
+        check_name(info, "Member of alternate '%s'" % name, key,
+                   'member-alternate')
 
         # Ensure alternates have no type conflicts.
         check_type(info, "Member '%s' of alternate '%s'" % (key, name),
@@ -836,8 +835,7 @@ def check_enum(expr, info):
         raise QAPISemError(info,
                            "Enum '%s' requires a string for 'prefix'" % name)
     for member in members:
-        check_name(info, "Member of enum '%s'" % name, member,
-                   enum_member=True)
+        check_name(info, "Member of enum '%s'" % name, member, 'member-enum')
 
 
 def check_struct(expr, info):
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (7 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 10:55   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice Markus Armbruster
                   ` (22 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 208010c241..8f9c5666bd 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -629,8 +629,7 @@ def add_name(name, info, meta, implicit=False):
     all_names[name] = meta
 
 
-def check_type(info, source, value, allow_array=False,
-               allow_dict=False, allow_optional=False,
+def check_type(info, source, value, allow_array=False, allow_dict=False,
                allow_metas=[]):
     global all_names
 
@@ -686,7 +685,7 @@ def check_command(expr, info):
     if boxed:
         args_meta += ['union', 'alternate']
     check_type(info, "'data' for command '%s'" % name,
-               expr.get('data'), allow_dict=not boxed, allow_optional=True,
+               expr.get('data'), allow_dict=not boxed,
                allow_metas=args_meta)
     returns_meta = ['union', 'struct']
     if name in returns_whitelist:
@@ -704,8 +703,7 @@ def check_event(expr, info):
     if boxed:
         meta += ['union', 'alternate']
     check_type(info, "'data' for event '%s'" % name,
-               expr.get('data'), allow_dict=not boxed, allow_optional=True,
-               allow_metas=meta)
+               expr.get('data'), allow_dict=not boxed, allow_metas=meta)
 
 
 def check_union(expr, info):
@@ -728,8 +726,7 @@ def check_union(expr, info):
     else:
         # The object must have a string or dictionary 'base'.
         check_type(info, "'base' for union '%s'" % name,
-                   base, allow_dict=True, allow_optional=True,
-                   allow_metas=['struct'])
+                   base, allow_dict=True, allow_metas=['struct'])
         if not base:
             raise QAPISemError(info, "Flat union '%s' must have a base"
                                % name)
@@ -843,7 +840,7 @@ def check_struct(expr, info):
     members = expr['data']
 
     check_type(info, "'data' for struct '%s'" % name, members,
-               allow_dict=True, allow_optional=True)
+               allow_dict=True)
     check_type(info, "'base' for struct '%s'" % name, expr.get('base'),
                allow_metas=['struct'])
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (8 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:04   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h Markus Armbruster
                   ` (21 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

The generators always generate both .c and .h, but they can route one
of them to the bit bucket.  We run them twice, once to generate .c,
and once to generate .h.  Probably because the naive make rule

    FOO.c FOO.h: qapi-schema.json
	RECIPE

runs RECIPE twice, once to generate FOO.c and once to generate FOO.h.

Employ the usual make trick to generate multiple files in one rule:

    .INTERMEDIATE: FOO-gen
    FOO.c FOO.h: FOO-gen ;
    FOO-gen: qapi-schema.json
        RECIPE

When make needs FOO.c or FOO.h, it runs RECIPE once to generate
intermediate target FOO-gen, then considers both FOO.c and FOO.h
updated.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 Makefile               | 58 +++++++++++++++++++++++++++++++++-----------------
 Makefile.objs          |  2 +-
 tests/Makefile.include | 36 +++++++++++++++++++++----------
 3 files changed, 64 insertions(+), 32 deletions(-)

diff --git a/Makefile b/Makefile
index cee6e28659..784b601247 100644
--- a/Makefile
+++ b/Makefile
@@ -384,24 +384,33 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
 qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
 qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
 
-gen-out-type = $(subst .,-,$(suffix $@))
-
 qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
 
+.INTERMEDIATE: qga/qapi-generated/qga-qapi-types-gen
 qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
+qga/qapi-generated/qga-qapi-types-gen ;
+qga/qapi-generated/qga-qapi-types-gen: \
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
+		-o $(dir $@) -p "qga-" $<, \
 		"GEN","$@")
+
+.INTERMEDIATE: qga/qapi-generated/qga-qapi-visit-gen
 qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
+qga/qapi-generated/qga-qapi-visit-gen ;
+qga/qapi-generated/qga-qapi-visit-gen: \
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
-		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
+		-o $(dir $@) -p "qga-" $<, \
 		"GEN","$@")
+
+.INTERMEDIATE: qga/qapi-generated/qga-qapi-commands-gen
 qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
+qga/qapi-generated/qga-qapi-commands-gen ;
+qga/qapi-generated/qga-qapi-commands-gen: \
 $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
+		-o $(dir $@) -p "qga-" $<, \
 		"GEN","$@")
 
 qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
@@ -419,30 +428,39 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
                $(SRC_PATH)/qapi/transaction.json \
                $(SRC_PATH)/qapi/ui.json
 
-qapi-types.c qapi-types.h :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
+.INTERMEDIATE: qapi-types-gen
+qapi-types.c qapi-types.h: qapi-types-gen ;
+qapi-types-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-		$(gen-out-type) -o "." -b $<, \
+		-b $<, \
 		"GEN","$@")
-qapi-visit.c qapi-visit.h :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
+
+.INTERMEDIATE: qapi-visit-gen
+qapi-visit.c qapi-visit.h: qapi-visit-gen ;
+qapi-visit-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
-		$(gen-out-type) -o "." -b $<, \
+		-b $<, \
 		"GEN","$@")
-qapi-event.c qapi-event.h :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
+
+.INTERMEDIATE: qapi-event-gen
+qapi-event.c qapi-event.h: qapi-event-gen
+qapi-event-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
-		$(gen-out-type) -o "." $<, \
+		$<, \
 		"GEN","$@")
-qmp-commands.h qmp-marshal.c :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
+
+.INTERMEDIATE: qapi-commands-gen
+qmp-commands.h qmp-marshal.c: qapi-commands-gen
+qapi-commands-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o "." $<, \
+		$<, \
 		"GEN","$@")
-qmp-introspect.h qmp-introspect.c :\
-$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
+
+.INTERMEDIATE: qapi-introspect-gen
+qmp-introspect.h qmp-introspect.c: qapi-introspect-gen
+qapi-introspect-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \
-		$(gen-out-type) -o "." $<, \
+		$<, \
 		"GEN","$@")
 
 QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
diff --git a/Makefile.objs b/Makefile.objs
index bdfa3b6177..cc4f94d77a 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -2,7 +2,7 @@
 # Common libraries for tools and emulators
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
-util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
+util-obj-y += qapi-types.o qapi-visit.o qapi-event.o
 
 chardev-obj-y = chardev/
 
diff --git a/tests/Makefile.include b/tests/Makefile.include
index de4a713c25..5d53c58506 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -626,30 +626,44 @@ tests/test-logging$(EXESUF): tests/test-logging.o $(test-util-obj-y)
 tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \
 	$(test-block-obj-y)
 
-tests/test-qapi-types.c tests/test-qapi-types.h :\
+.INTERMEDIATE: tests/test-qapi-types-gen
+tests/test-qapi-types.c tests/test-qapi-types.h: tests/test-qapi-types-gen ;
+tests/test-qapi-types-gen: \
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-		$(gen-out-type) -o tests -p "test-" $<, \
+		-o tests -p "test-" $<, \
 		"GEN","$@")
-tests/test-qapi-visit.c tests/test-qapi-visit.h :\
+
+.INTERMEDIATE: tests/test-qapi-visit-gen
+tests/test-qapi-visit.c tests/test-qapi-visit.h: tests/test-qapi-visit-gen ;
+tests/test-qapi-visit-gen: \
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
-		$(gen-out-type) -o tests -p "test-" $<, \
+		-o tests -p "test-" $<, \
 		"GEN","$@")
-tests/test-qmp-commands.h tests/test-qmp-marshal.c :\
+
+.INTERMEDIATE: tests/test-qapi-commands-gen
+tests/test-qmp-commands.h tests/test-qmp-marshal.c: tests/test-qapi-commands-gen ;
+tests/test-qapi-commands-gen: \
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
-		$(gen-out-type) -o tests -p "test-" $<, \
+		-o tests -p "test-" $<, \
 		"GEN","$@")
-tests/test-qapi-event.c tests/test-qapi-event.h :\
+
+.INTERMEDIATE: tests/test-qapi-event-gen
+tests/test-qapi-event.c tests/test-qapi-event.h: tests/test-qapi-event-gen ;
+tests/test-qapi-event-gen: \
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
-		$(gen-out-type) -o tests -p "test-" $<, \
+		-o tests -p "test-" $<, \
 		"GEN","$@")
-tests/test-qmp-introspect.c tests/test-qmp-introspect.h :\
+
+.INTERMEDIATE: tests/test-qapi-introspect-gen
+tests/test-qmp-introspect.c tests/test-qmp-introspect.h: tests/test-qapi-introspect-gen ;
+tests/test-qapi-introspect-gen: \
 $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \
-		$(gen-out-type) -o tests -p "test-" $<, \
+		-o tests -p "test-" $<, \
 		"GEN","$@")
 
 tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py)
@@ -660,7 +674,7 @@ tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(te
 tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y)
 tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y)
 tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y)
-tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y)
+tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y) qmp-introspect.o
 tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y)
 tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y)
 tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-obj-y)
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (9 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:07   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments Markus Armbruster
                   ` (20 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-commands.py   |  4 ++--
 scripts/qapi-event.py      |  4 ++--
 scripts/qapi-introspect.py |  4 ++--
 scripts/qapi-types.py      |  4 ++--
 scripts/qapi-visit.py      |  4 ++--
 scripts/qapi.py            | 25 ++++---------------------
 6 files changed, 14 insertions(+), 31 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 974d0a4a80..56a1009564 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -253,7 +253,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         self._regy += gen_register_command(name, success_response)
 
 
-(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
+(input_file, output_dir, prefix, opts) = parse_command_line()
 
 c_comment = '''
 /*
@@ -284,7 +284,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
+(fdef, fdecl) = open_output(output_dir, prefix,
                             'qmp-marshal.c', 'qmp-commands.h',
                             c_comment, h_comment)
 
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 07b4b70199..0a308e6b69 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -169,7 +169,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self._event_names.append(name)
 
 
-(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
+(input_file, output_dir, prefix, dummy) = parse_command_line()
 
 c_comment = '''
 /*
@@ -200,7 +200,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
+(fdef, fdecl) = open_output(output_dir, prefix,
                             'qapi-event.c', 'qapi-event.h',
                             c_comment, h_comment)
 
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 032bcea491..c2e46182c8 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -169,7 +169,7 @@ const char %(c_name)s[] = %(c_string)s;
 # We normally mask them, because they're not QMP wire ABI
 opt_unmask = False
 
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, prefix, opts) = \
     parse_command_line('u', ['unmask-non-abi-names'])
 
 for o, a in opts:
@@ -199,7 +199,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
+(fdef, fdecl) = open_output(output_dir, prefix,
                             'qmp-introspect.c', 'qmp-introspect.h',
                             c_comment, h_comment)
 
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 7e3051dbb9..dc7dd08512 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -243,7 +243,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
 # QAPISchemaGenTypeVisitor.visit_end().
 do_builtins = False
 
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, prefix, opts) = \
     parse_command_line('b', ['builtins'])
 
 for o, a in opts:
@@ -280,7 +280,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
+(fdef, fdecl) = open_output(output_dir, prefix,
                             'qapi-types.c', 'qapi-types.h',
                             c_comment, h_comment)
 
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 7e1cfc13f0..9757911d2d 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -327,7 +327,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
 # QAPISchemaGenVisitVisitor.visit_end().
 do_builtins = False
 
-(input_file, output_dir, do_c, do_h, prefix, opts) = \
+(input_file, output_dir, prefix, opts) = \
     parse_command_line('b', ['builtins'])
 
 for o, a in opts:
@@ -363,7 +363,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
+(fdef, fdecl) = open_output(output_dir, prefix,
                             'qapi-visit.c', 'qapi-visit.h',
                             c_comment, h_comment)
 
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 8f9c5666bd..5434987108 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1931,8 +1931,6 @@ def parse_command_line(extra_options='', extra_long_options=[]):
 
     output_dir = ''
     prefix = ''
-    do_c = False
-    do_h = False
     extra_opts = []
 
     for oa in opts:
@@ -1947,30 +1945,22 @@ def parse_command_line(extra_options='', extra_long_options=[]):
             prefix = a
         elif o in ('-o', '--output-dir'):
             output_dir = a + '/'
-        elif o in ('-c', '--source'):
-            do_c = True
-        elif o in ('-h', '--header'):
-            do_h = True
         else:
             extra_opts.append(oa)
 
-    if not do_c and not do_h:
-        do_c = True
-        do_h = True
-
     if len(args) != 1:
         print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
         sys.exit(1)
     fname = args[0]
 
-    return (fname, output_dir, do_c, do_h, prefix, extra_opts)
+    return (fname, output_dir, prefix, extra_opts)
 
 #
 # Generate output files with boilerplate
 #
 
 
-def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
+def open_output(output_dir, prefix, c_file, h_file,
                 c_comment, h_comment):
     guard = guardname(prefix + h_file)
     c_file = output_dir + prefix + c_file
@@ -1983,15 +1973,8 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
             if e.errno != errno.EEXIST:
                 raise
 
-    def maybe_open(really, name, opt):
-        if really:
-            return open(name, opt)
-        else:
-            import StringIO
-            return StringIO.StringIO()
-
-    fdef = maybe_open(do_c, c_file, 'w')
-    fdecl = maybe_open(do_h, h_file, 'w')
+    fdef = open(c_file, 'w')
+    fdecl = open(h_file, 'w')
 
     fdef.write(mcgen('''
 /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (10 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:13   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file Markus Armbruster
                   ` (19 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Less code than with getopt, and we get --help for free.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-commands.py       | 13 +++++-----
 scripts/qapi-event.py          | 12 ++++-----
 scripts/qapi-introspect.py     | 22 +++++++---------
 scripts/qapi-types.py          | 22 ++++++----------
 scripts/qapi-visit.py          | 24 +++++++----------
 scripts/qapi.py                | 58 +++++++++++++++---------------------------
 scripts/qapi2texi.py           | 11 +++++---
 tests/qapi-schema/test-qapi.py | 10 +++++---
 8 files changed, 74 insertions(+), 98 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 56a1009564..76cc9cc8a4 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -214,7 +214,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds)
     QTAILQ_INIT(cmds);
 
 ''',
-                c_prefix=c_name(prefix, protect=False))
+                c_prefix=c_name(args.prefix, protect=False))
     ret += registry
     ret += mcgen('''
 }
@@ -253,7 +253,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
         self._regy += gen_register_command(name, success_response)
 
 
-(input_file, output_dir, prefix, opts) = parse_command_line()
+args = common_argument_parser().parse_args()
 
 c_comment = '''
 /*
@@ -284,7 +284,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, prefix,
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
                             'qmp-marshal.c', 'qmp-commands.h',
                             c_comment, h_comment)
 
@@ -302,7 +302,7 @@ fdef.write(mcgen('''
 #include "%(prefix)sqmp-commands.h"
 
 ''',
-                 prefix=prefix))
+                 prefix=args.prefix))
 
 fdecl.write(mcgen('''
 #include "%(prefix)sqapi-types.h"
@@ -312,9 +312,10 @@ fdecl.write(mcgen('''
 
 void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
 ''',
-                  prefix=prefix, c_prefix=c_name(prefix, protect=False)))
+                  prefix=args.prefix,
+                  c_prefix=c_name(args.prefix, protect=False)))
 
-schema = QAPISchema(input_file)
+schema = QAPISchema(args.schema)
 gen = QAPISchemaGenCommandVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 0a308e6b69..1c61751bc0 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -169,7 +169,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
         self._event_names.append(name)
 
 
-(input_file, output_dir, prefix, dummy) = parse_command_line()
+args = common_argument_parser().parse_args()
 
 c_comment = '''
 /*
@@ -200,7 +200,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, prefix,
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
                             'qapi-event.c', 'qapi-event.h',
                             c_comment, h_comment)
 
@@ -213,7 +213,7 @@ fdef.write(mcgen('''
 #include "qapi/qmp-event.h"
 
 ''',
-                 prefix=prefix))
+                 prefix=args.prefix))
 
 fdecl.write(mcgen('''
 #include "qapi/error.h"
@@ -222,11 +222,11 @@ fdecl.write(mcgen('''
 #include "%(prefix)sqapi-types.h"
 
 ''',
-                  prefix=prefix))
+                  prefix=args.prefix))
 
-event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
+event_enum_name = c_name(args.prefix + 'QAPIEvent', protect=False)
 
-schema = QAPISchema(input_file)
+schema = QAPISchema(args.schema)
 gen = QAPISchemaGenEventVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index c2e46182c8..ad87fc57e3 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -64,7 +64,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
         # generate C
         # TODO can generate awfully long lines
         jsons.extend(self._jsons)
-        name = c_name(prefix, protect=False) + 'qmp_schema_json'
+        name = c_name(args.prefix, protect=False) + 'qmp_schema_json'
         self.decl = mcgen('''
 extern const char %(c_name)s[];
 ''',
@@ -165,16 +165,12 @@ const char %(c_name)s[] = %(c_string)s;
         arg_type = arg_type or self._schema.the_empty_object_type
         self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)})
 
+parser = common_argument_parser()
 # Debugging aid: unmask QAPI schema's type names
 # We normally mask them, because they're not QMP wire ABI
-opt_unmask = False
-
-(input_file, output_dir, prefix, opts) = \
-    parse_command_line('u', ['unmask-non-abi-names'])
-
-for o, a in opts:
-    if o in ('-u', '--unmask-non-abi-names'):
-        opt_unmask = True
+parser.add_argument('-u', '--unmask-non-abi-names', action='store_true',
+                    help='unmask non-ABI names')
+args = parser.parse_args()
 
 c_comment = '''
 /*
@@ -199,7 +195,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, prefix,
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
                             'qmp-introspect.c', 'qmp-introspect.h',
                             c_comment, h_comment)
 
@@ -208,10 +204,10 @@ fdef.write(mcgen('''
 #include "%(prefix)sqmp-introspect.h"
 
 ''',
-                 prefix=prefix))
+                 prefix=args.prefix))
 
-schema = QAPISchema(input_file)
-gen = QAPISchemaGenIntrospectVisitor(opt_unmask)
+schema = QAPISchema(args.schema)
+gen = QAPISchemaGenIntrospectVisitor(args.unmask_non_abi_names)
 schema.visit(gen)
 fdef.write(gen.defn)
 fdecl.write(gen.decl)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index dc7dd08512..ed05d828bf 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -185,7 +185,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         self._fwdecl = None
         # To avoid header dependency hell, we always generate
         # declarations for built-in types in our header files and
-        # simply guard them.  See also do_builtins (command line
+        # simply guard them.  See also args.builtins (command line
         # option -b).
         self._btin += guardend('QAPI_TYPES_BUILTIN')
         self.decl = self._btin + self.decl
@@ -200,7 +200,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         # TODO use something cleaner than existence of info
         if not info:
             self._btin += gen_enum(name, values, prefix)
-            if do_builtins:
+            if args.builtins:
                 self.defn += gen_enum_lookup(name, values, prefix)
         else:
             self._fwdecl += gen_enum(name, values, prefix)
@@ -211,7 +211,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
             self._btin += gen_fwd_object_or_array(name)
             self._btin += gen_array(name, element_type)
             self._btin += gen_type_cleanup_decl(name)
-            if do_builtins:
+            if args.builtins:
                 self.defn += gen_type_cleanup(name)
         else:
             self._fwdecl += gen_fwd_object_or_array(name)
@@ -239,16 +239,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
 
 # If you link code generated from multiple schemata, you want only one
 # instance of the code for built-in types.  Generate it only when
-# do_builtins, enabled by command line option -b.  See also
+# args.builtins, enabled by command line option -b.  See also
 # QAPISchemaGenTypeVisitor.visit_end().
-do_builtins = False
 
-(input_file, output_dir, prefix, opts) = \
-    parse_command_line('b', ['builtins'])
-
-for o, a in opts:
-    if o in ('-b', '--builtins'):
-        do_builtins = True
+args = common_argument_parser(builtins=True).parse_args()
 
 c_comment = '''
 /*
@@ -280,7 +274,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, prefix,
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
                             'qapi-types.c', 'qapi-types.h',
                             c_comment, h_comment)
 
@@ -290,13 +284,13 @@ fdef.write(mcgen('''
 #include "%(prefix)sqapi-types.h"
 #include "%(prefix)sqapi-visit.h"
 ''',
-                 prefix=prefix))
+                 prefix=args.prefix))
 
 fdecl.write(mcgen('''
 #include "qapi/util.h"
 '''))
 
-schema = QAPISchema(input_file)
+schema = QAPISchema(args.schema)
 gen = QAPISchemaGenTypeVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 9757911d2d..010d68434f 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -276,7 +276,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
     def visit_end(self):
         # To avoid header dependency hell, we always generate
         # declarations for built-in types in our header files and
-        # simply guard them.  See also do_builtins (command line
+        # simply guard them.  See also args.builtins (command line
         # option -b).
         self._btin += guardend('QAPI_VISIT_BUILTIN')
         self.decl = self._btin + self.decl
@@ -287,7 +287,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
         # TODO use something cleaner than existence of info
         if not info:
             self._btin += gen_visit_decl(name, scalar=True)
-            if do_builtins:
+            if args.builtins:
                 self.defn += gen_visit_enum(name)
         else:
             self.decl += gen_visit_decl(name, scalar=True)
@@ -298,7 +298,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
         defn = gen_visit_list(name, element_type)
         if isinstance(element_type, QAPISchemaBuiltinType):
             self._btin += decl
-            if do_builtins:
+            if args.builtins:
                 self.defn += defn
         else:
             self.decl += decl
@@ -323,16 +323,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
 
 # If you link code generated from multiple schemata, you want only one
 # instance of the code for built-in types.  Generate it only when
-# do_builtins, enabled by command line option -b.  See also
+# args.builtins, enabled by command line option -b.  See also
 # QAPISchemaGenVisitVisitor.visit_end().
-do_builtins = False
 
-(input_file, output_dir, prefix, opts) = \
-    parse_command_line('b', ['builtins'])
-
-for o, a in opts:
-    if o in ('-b', '--builtins'):
-        do_builtins = True
+args = common_argument_parser(builtins=True).parse_args()
 
 c_comment = '''
 /*
@@ -363,7 +357,7 @@ h_comment = '''
  */
 '''
 
-(fdef, fdecl) = open_output(output_dir, prefix,
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
                             'qapi-visit.c', 'qapi-visit.h',
                             c_comment, h_comment)
 
@@ -373,7 +367,7 @@ fdef.write(mcgen('''
 #include "qapi/error.h"
 #include "%(prefix)sqapi-visit.h"
 ''',
-                 prefix=prefix))
+                 prefix=args.prefix))
 
 fdecl.write(mcgen('''
 #include "qapi/visitor.h"
@@ -381,9 +375,9 @@ fdecl.write(mcgen('''
 #include "%(prefix)sqapi-types.h"
 
 ''',
-                  prefix=prefix))
+                  prefix=args.prefix))
 
-schema = QAPISchema(input_file)
+schema = QAPISchema(args.schema)
 gen = QAPISchemaGenVisitVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 5434987108..25f6c81b08 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -11,8 +11,8 @@
 # This work is licensed under the terms of the GNU GPL, version 2.
 # See the COPYING file in the top-level directory.
 
+import argparse
 import errno
-import getopt
 import os
 import re
 import string
@@ -1917,43 +1917,27 @@ def build_params(arg_type, boxed, extra):
 # Common command line parsing
 #
 
+def common_argument_parser(builtins=False):
 
-def parse_command_line(extra_options='', extra_long_options=[]):
+    def prefix(string):
+        match = re.match(r'([a-z_.-][a-z0-9_.-]*)?', string, re.I)
+        if match.end() != len(string):
+            raise argparse.ArgumentTypeError("funny character '%s'"
+                                             % string[match.end()])
+        return string
 
-    try:
-        opts, args = getopt.gnu_getopt(sys.argv[1:],
-                                       'chp:o:' + extra_options,
-                                       ['source', 'header', 'prefix=',
-                                        'output-dir='] + extra_long_options)
-    except getopt.GetoptError as err:
-        print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
-        sys.exit(1)
+    parser = argparse.ArgumentParser(conflict_handler='resolve')
+    if builtins:
+        parser.add_argument('-b', '--builtins', action='store_true',
+                            help='generate builtins')
+    parser.add_argument('-o', '--output-dir', default='',
+                        help='output directory')
+    parser.add_argument('-p', '--prefix', default='', type=prefix,
+                        help='prefix to add to output files')
+    parser.add_argument('schema',
+                        help='QAPI schema source file')
+    return parser
 
-    output_dir = ''
-    prefix = ''
-    extra_opts = []
-
-    for oa in opts:
-        o, a = oa
-        if o in ('-p', '--prefix'):
-            match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
-            if match.end() != len(a):
-                print >>sys.stderr, \
-                    "%s: 'funny character '%s' in argument of --prefix" \
-                    % (sys.argv[0], a[match.end()])
-                sys.exit(1)
-            prefix = a
-        elif o in ('-o', '--output-dir'):
-            output_dir = a + '/'
-        else:
-            extra_opts.append(oa)
-
-    if len(args) != 1:
-        print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
-        sys.exit(1)
-    fname = args[0]
-
-    return (fname, output_dir, prefix, extra_opts)
 
 #
 # Generate output files with boilerplate
@@ -1963,8 +1947,8 @@ def parse_command_line(extra_options='', extra_long_options=[]):
 def open_output(output_dir, prefix, c_file, h_file,
                 c_comment, h_comment):
     guard = guardname(prefix + h_file)
-    c_file = output_dir + prefix + c_file
-    h_file = output_dir + prefix + h_file
+    c_file = os.path.join(output_dir, prefix + c_file)
+    h_file = os.path.join(output_dir, prefix + h_file)
 
     if output_dir:
         try:
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index bfd1c676e1..fd90d8953e 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -4,6 +4,8 @@
 # This work is licensed under the terms of the GNU LGPL, version 2+.
 # See the COPYING file in the top-level directory.
 """This script produces the documentation of a qapi schema in texinfo format"""
+
+import argparse
 import re
 import sys
 
@@ -279,11 +281,12 @@ def texi_schema(schema):
 
 def main(argv):
     """Takes schema argument, prints result to stdout"""
-    if len(argv) != 2:
-        print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0]
-        sys.exit(1)
+    parser = argparse.ArgumentParser()
+    parser.add_argument('schema',
+                        help='QAPI schema source file')
+    args = parser.parse_args()
 
-    schema = qapi.QAPISchema(argv[1])
+    schema = qapi.QAPISchema(args.schema)
     if not qapi.doc_required:
         print >>sys.stderr, ("%s: need pragma 'doc-required' "
                              "to generate documentation" % argv[0])
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index fe0ca08d78..a7e21d016f 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -12,8 +12,7 @@
 
 from qapi import *
 from pprint import pprint
-import os
-import sys
+import argparse
 
 
 class QAPISchemaTestVisitor(QAPISchemaVisitor):
@@ -53,7 +52,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
             for v in variants.variants:
                 print '    case %s: %s' % (v.name, v.type.name)
 
-schema = QAPISchema(sys.argv[1])
+parser = argparse.ArgumentParser()
+parser.add_argument('schema',
+                    help='QAPI schema source file')
+args = parser.parse_args()
+
+schema = QAPISchema(args.schema)
 schema.visit(QAPISchemaTestVisitor())
 
 for doc in schema.docs:
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (11 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:18   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types Markus Armbruster
                   ` (18 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

QAPISchema.__init__() opens the schema file.  Since it doesn't bother
to catch exceptions, an invalid schema argument is reported like this:

    Traceback (most recent call last):
      File "../scripts/qapi-commands.py", line 318, in <module>
	schema = QAPISchema(args.schema)
      File "/work/armbru/qemu/scripts/qapi.py", line 1464, in __init__
	parser = QAPISchemaParser(open(fname, 'r'))
    IOError: [Errno 2] No such file or directory: 'nonexistent'

Leave it to argparse, which handles the exception like this:

    usage: qapi-commands.py [-h] [-o OUTPUT_DIR] [-p PREFIX] schema
    qapi-commands.py: error: argument schema: can't open 'nonexistent': [Errno 2] No such file or directory: 'nonexistent'

Too verbose for my taste, but let's not second-guess the standard
library.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py                | 6 +++---
 scripts/qapi2texi.py           | 2 +-
 tests/qapi-schema/test-qapi.py | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 25f6c81b08..a33203e82d 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1450,9 +1450,9 @@ class QAPISchemaEvent(QAPISchemaEntity):
 
 
 class QAPISchema(object):
-    def __init__(self, fname):
+    def __init__(self, file):
         try:
-            parser = QAPISchemaParser(open(fname, 'r'))
+            parser = QAPISchemaParser(file)
             self.exprs = check_exprs(parser.exprs)
             self.docs = parser.docs
             self._entity_dict = {}
@@ -1934,7 +1934,7 @@ def common_argument_parser(builtins=False):
                         help='output directory')
     parser.add_argument('-p', '--prefix', default='', type=prefix,
                         help='prefix to add to output files')
-    parser.add_argument('schema',
+    parser.add_argument('schema', type=argparse.FileType('r'),
                         help='QAPI schema source file')
     return parser
 
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index fd90d8953e..d95d7541a3 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -282,7 +282,7 @@ def texi_schema(schema):
 def main(argv):
     """Takes schema argument, prints result to stdout"""
     parser = argparse.ArgumentParser()
-    parser.add_argument('schema',
+    parser.add_argument('schema', type=argparse.FileType('r'),
                         help='QAPI schema source file')
     args = parser.parse_args()
 
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index a7e21d016f..225417d861 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -53,7 +53,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
                 print '    case %s: %s' % (v.name, v.type.name)
 
 parser = argparse.ArgumentParser()
-parser.add_argument('schema',
+parser.add_argument('schema', type=argparse.FileType('r'),
                     help='QAPI schema source file')
 args = parser.parse_args()
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (12 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:52   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage Markus Armbruster
                   ` (17 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

qapi-types.py and qapi-visit.py generate some C code for built-in
types.  To make this work with multiple schemas, we generate code for
built-ins into .c files only when the user asks for it with -b.  The
user is responsible for linking exactly one set of files generated
with -b per program.  We generate code for built-ins into .h
regardless of -b, but guard it with a preprocessor symbol.

This is cumbersome and inflexible.  Move the code generated for
built-in types into separate files builtin-qapi-{types,visit}.{c,h}.
Run qapi-types.py and qapi-visit.py without a schema argument to
generate them.  Drop their option -b.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 .gitignore                               |  2 ++
 Makefile                                 | 18 ++++++++--
 Makefile.objs                            |  1 +
 docs/devel/qapi-code-gen.txt             | 24 +++++++++++--
 qga/Makefile.objs                        |  1 +
 scripts/qapi-introspect.py               |  4 +--
 scripts/qapi-types.py                    | 54 ++++++++++------------------
 scripts/qapi-visit.py                    | 62 ++++++++++++--------------------
 scripts/qapi.py                          | 57 ++++++++++++++++-------------
 scripts/qapi2texi.py                     |  2 +-
 tests/Makefile.include                   |  4 ++-
 tests/qapi-schema/builtins.err           |  0
 tests/qapi-schema/builtins.exit          |  1 +
 tests/qapi-schema/builtins.json          |  1 +
 tests/qapi-schema/builtins.out           |  3 ++
 tests/qapi-schema/comments.out           |  3 --
 tests/qapi-schema/doc-bad-section.out    |  3 --
 tests/qapi-schema/doc-good.out           |  3 --
 tests/qapi-schema/empty.out              |  3 --
 tests/qapi-schema/event-case.out         |  3 --
 tests/qapi-schema/ident-with-escape.out  |  3 --
 tests/qapi-schema/include-relpath.out    |  3 --
 tests/qapi-schema/include-repetition.out |  3 --
 tests/qapi-schema/include-simple.out     |  3 --
 tests/qapi-schema/indented-expr.out      |  3 --
 tests/qapi-schema/qapi-schema-test.out   |  3 --
 tests/qapi-schema/test-qapi.py           |  4 +--
 27 files changed, 127 insertions(+), 144 deletions(-)
 create mode 100644 tests/qapi-schema/builtins.err
 create mode 100644 tests/qapi-schema/builtins.exit
 create mode 100644 tests/qapi-schema/builtins.json
 create mode 100644 tests/qapi-schema/builtins.out

diff --git a/.gitignore b/.gitignore
index 40acfcb9e2..84a57060ad 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
+/builtin-qapi-types.[ch]
+/builtin-qapi-visit.[ch]
 /config-devices.*
 /config-all-devices.*
 /config-all-disas.*
diff --git a/Makefile b/Makefile
index 784b601247..421e65d833 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,8 @@ endif
 include $(SRC_PATH)/rules.mak
 
 GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
+GENERATED_FILES += builtin-qapi-types.h builtin-qapi-types.c
+GENERATED_FILES += builtin-qapi-visit.h builtin-qapi-visit.c
 GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
 GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
 GENERATED_FILES += qmp-introspect.h
@@ -428,18 +430,30 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
                $(SRC_PATH)/qapi/transaction.json \
                $(SRC_PATH)/qapi/ui.json
 
+.INTERMEDIATE: builtin-qapi-types-gen
+builtin-qapi-types.c builtin-qapi-types.h: builtin-qapi-types-gen ;
+builtin-qapi-types-gen: $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py, \
+		"GEN","$@")
+
+.INTERMEDIATE: builtin-qapi-visit-gen
+builtin-qapi-visit.c builtin-qapi-visit.h: builtin-qapi-visit-gen ;
+builtin-qapi-visit-gen: $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py, \
+		"GEN","$@")
+
 .INTERMEDIATE: qapi-types-gen
 qapi-types.c qapi-types.h: qapi-types-gen ;
 qapi-types-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
-		-b $<, \
+		$<, \
 		"GEN","$@")
 
 .INTERMEDIATE: qapi-visit-gen
 qapi-visit.c qapi-visit.h: qapi-visit-gen ;
 qapi-visit-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
-		-b $<, \
+		$<, \
 		"GEN","$@")
 
 .INTERMEDIATE: qapi-event-gen
diff --git a/Makefile.objs b/Makefile.objs
index cc4f94d77a..c2c62cb462 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -2,6 +2,7 @@
 # Common libraries for tools and emulators
 stub-obj-y = stubs/ crypto/
 util-obj-y = util/ qobject/ qapi/
+util-obj-y += builtin-qapi-types.o builtin-qapi-visit.o
 util-obj-y += qapi-types.o qapi-visit.o qapi-event.o
 
 chardev-obj-y = chardev/
diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 579807f6a5..f5b7659caf 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -937,7 +937,7 @@ supporting code. The following files are created:
 
 $(prefix)qapi-types.h - C types corresponding to types defined in
                         the schema you pass in
-$(prefix)qapi-types.c - Cleanup functions for the above C types
+$(prefix)qapi-types.c - Support code for the above C types
 
 The $(prefix) is an optional parameter used as a namespace to keep the
 generated code from one schema/code-generation separated from others so code
@@ -954,7 +954,7 @@ Example:
     #ifndef EXAMPLE_QAPI_TYPES_H
     #define EXAMPLE_QAPI_TYPES_H
 
-[Built-in types omitted...]
+    #include "builtin-qapi-types.h"
 
     typedef struct UserDefOne UserDefOne;
 
@@ -1011,6 +1011,14 @@ Example:
         visit_free(v);
     }
 
+Type definitions for the built-in types are generated separately, into
+builtin-qapi-types.h and builtin-qapi-types.c.  These are independent
+of the schema.
+
+Example:
+
+    $ python scripts/qapi-types.py --output-dir="qapi-generated"
+
 === scripts/qapi-visit.py ===
 
 Used to generate the visitor functions used to walk through and
@@ -1039,7 +1047,9 @@ Example:
     #ifndef EXAMPLE_QAPI_VISIT_H
     #define EXAMPLE_QAPI_VISIT_H
 
-[Visitors for built-in types omitted...]
+    #include "builtin-qapi-visit.h"
+    #include "example-qapi-types.h"
+
 
     void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp);
     void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp);
@@ -1140,6 +1150,14 @@ Example:
         error_propagate(errp, err);
     }
 
+Visitor functions for the built-in types are generated separately,
+into builtin-qapi-visit.h and builtin-qapi-visit.c.  These are
+independent of the schema.
+
+Example:
+
+    $ python scripts/qapi-visit.py --output-dir="qapi-generated"
+
 === scripts/qapi-commands.py ===
 
 Used to generate the marshaling/dispatch functions for the commands
diff --git a/qga/Makefile.objs b/qga/Makefile.objs
index 1c5986c0bb..1430655fbe 100644
--- a/qga/Makefile.objs
+++ b/qga/Makefile.objs
@@ -2,6 +2,7 @@ qga-obj-y = commands.o guest-agent-command-state.o main.o
 qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o
 qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o
 qga-obj-$(CONFIG_WIN32) += vss-win32.o
+qga-obj-y += ../builtin-qapi-types.o ../builtin-qapi-visit.o
 qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o
 qga-obj-y += qapi-generated/qga-qmp-marshal.o
 
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index ad87fc57e3..cc4ff01cd4 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -60,7 +60,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
         jsons = self._jsons
         self._jsons = []
         for typ in self._used_types:
-            typ.visit(self)
+            typ.visit(self, builtins=True)
         # generate C
         # TODO can generate awfully long lines
         jsons.extend(self._jsons)
@@ -208,7 +208,7 @@ fdef.write(mcgen('''
 
 schema = QAPISchema(args.schema)
 gen = QAPISchemaGenIntrospectVisitor(args.unmask_non_abi_names)
-schema.visit(gen)
+schema.visit(gen, builtins=True)
 fdef.write(gen.defn)
 fdecl.write(gen.decl)
 
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index ed05d828bf..18fd2a98c0 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -170,7 +170,6 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         self.decl = None
         self.defn = None
         self._fwdecl = None
-        self._btin = None
 
     def visit_begin(self, schema):
         # gen_object() is recursive, ensure it doesn't visit the empty type
@@ -178,45 +177,23 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         self.decl = ''
         self.defn = ''
         self._fwdecl = ''
-        self._btin = guardstart('QAPI_TYPES_BUILTIN')
 
     def visit_end(self):
         self.decl = self._fwdecl + self.decl
         self._fwdecl = None
-        # To avoid header dependency hell, we always generate
-        # declarations for built-in types in our header files and
-        # simply guard them.  See also args.builtins (command line
-        # option -b).
-        self._btin += guardend('QAPI_TYPES_BUILTIN')
-        self.decl = self._btin + self.decl
-        self._btin = None
 
     def _gen_type_cleanup(self, name):
         self.decl += gen_type_cleanup_decl(name)
         self.defn += gen_type_cleanup(name)
 
     def visit_enum_type(self, name, info, values, prefix):
-        # Special case for our lone builtin enum type
-        # TODO use something cleaner than existence of info
-        if not info:
-            self._btin += gen_enum(name, values, prefix)
-            if args.builtins:
-                self.defn += gen_enum_lookup(name, values, prefix)
-        else:
-            self._fwdecl += gen_enum(name, values, prefix)
-            self.defn += gen_enum_lookup(name, values, prefix)
+        self._fwdecl += gen_enum(name, values, prefix)
+        self.defn += gen_enum_lookup(name, values, prefix)
 
     def visit_array_type(self, name, info, element_type):
-        if isinstance(element_type, QAPISchemaBuiltinType):
-            self._btin += gen_fwd_object_or_array(name)
-            self._btin += gen_array(name, element_type)
-            self._btin += gen_type_cleanup_decl(name)
-            if args.builtins:
-                self.defn += gen_type_cleanup(name)
-        else:
-            self._fwdecl += gen_fwd_object_or_array(name)
-            self.decl += gen_array(name, element_type)
-            self._gen_type_cleanup(name)
+        self._fwdecl += gen_fwd_object_or_array(name)
+        self.decl += gen_array(name, element_type)
+        self._gen_type_cleanup(name)
 
     def visit_object_type(self, name, info, base, members, variants):
         # Nothing to do for the special empty builtin
@@ -237,12 +214,12 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         self.decl += gen_object(name, None, [variants.tag_member], variants)
         self._gen_type_cleanup(name)
 
-# If you link code generated from multiple schemata, you want only one
-# instance of the code for built-in types.  Generate it only when
-# args.builtins, enabled by command line option -b.  See also
-# QAPISchemaGenTypeVisitor.visit_end().
-
-args = common_argument_parser(builtins=True).parse_args()
+argparser = common_argument_parser(builtins=True)
+args = argparser.parse_args()
+if not args.schema:
+    if args.prefix:
+        argparser.error('schema required with -p')
+    args.prefix = 'builtin-'
 
 c_comment = '''
 /*
@@ -286,13 +263,18 @@ fdef.write(mcgen('''
 ''',
                  prefix=args.prefix))
 
-fdecl.write(mcgen('''
+if args.schema:
+    fdecl.write(mcgen('''
+#include "builtin-qapi-types.h"
+'''))
+else:
+    fdecl.write(mcgen('''
 #include "qapi/util.h"
 '''))
 
 schema = QAPISchema(args.schema)
 gen = QAPISchemaGenTypeVisitor()
-schema.visit(gen)
+schema.visit(gen, builtins=not args.schema)
 fdef.write(gen.defn)
 fdecl.write(gen.decl)
 
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index 010d68434f..e756ef98ee 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -266,43 +266,18 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
     def __init__(self):
         self.decl = None
         self.defn = None
-        self._btin = None
 
     def visit_begin(self, schema):
         self.decl = ''
         self.defn = ''
-        self._btin = guardstart('QAPI_VISIT_BUILTIN')
-
-    def visit_end(self):
-        # To avoid header dependency hell, we always generate
-        # declarations for built-in types in our header files and
-        # simply guard them.  See also args.builtins (command line
-        # option -b).
-        self._btin += guardend('QAPI_VISIT_BUILTIN')
-        self.decl = self._btin + self.decl
-        self._btin = None
 
     def visit_enum_type(self, name, info, values, prefix):
-        # Special case for our lone builtin enum type
-        # TODO use something cleaner than existence of info
-        if not info:
-            self._btin += gen_visit_decl(name, scalar=True)
-            if args.builtins:
-                self.defn += gen_visit_enum(name)
-        else:
-            self.decl += gen_visit_decl(name, scalar=True)
-            self.defn += gen_visit_enum(name)
+        self.decl += gen_visit_decl(name, scalar=True)
+        self.defn += gen_visit_enum(name)
 
     def visit_array_type(self, name, info, element_type):
-        decl = gen_visit_decl(name)
-        defn = gen_visit_list(name, element_type)
-        if isinstance(element_type, QAPISchemaBuiltinType):
-            self._btin += decl
-            if args.builtins:
-                self.defn += defn
-        else:
-            self.decl += decl
-            self.defn += defn
+        self.decl += gen_visit_decl(name)
+        self.defn += gen_visit_list(name, element_type)
 
     def visit_object_type(self, name, info, base, members, variants):
         # Nothing to do for the special empty builtin
@@ -321,12 +296,12 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
         self.decl += gen_visit_decl(name)
         self.defn += gen_visit_alternate(name, variants)
 
-# If you link code generated from multiple schemata, you want only one
-# instance of the code for built-in types.  Generate it only when
-# args.builtins, enabled by command line option -b.  See also
-# QAPISchemaGenVisitVisitor.visit_end().
-
-args = common_argument_parser(builtins=True).parse_args()
+argparser = common_argument_parser(builtins=True)
+args = argparser.parse_args()
+if not args.schema:
+    if args.prefix:
+        argparser.error('schema required with -p')
+    args.prefix = 'builtin-'
 
 c_comment = '''
 /*
@@ -369,17 +344,24 @@ fdef.write(mcgen('''
 ''',
                  prefix=args.prefix))
 
-fdecl.write(mcgen('''
+if args.schema:
+    fdecl.write(mcgen('''
+#include "builtin-qapi-visit.h"
+#include "%(prefix)sqapi-types.h"
+
+''',
+                      prefix=args.prefix))
+else:
+    fdecl.write(mcgen('''
 #include "qapi/visitor.h"
 #include "qapi/qmp/qerror.h"
-#include "%(prefix)sqapi-types.h"
+#include "builtin-qapi-types.h"
 
-''',
-                  prefix=args.prefix))
+'''))
 
 schema = QAPISchema(args.schema)
 gen = QAPISchemaGenVisitVisitor()
-schema.visit(gen)
+schema.visit(gen, builtins=not args.schema)
 fdef.write(gen.defn)
 fdecl.write(gen.decl)
 
diff --git a/scripts/qapi.py b/scripts/qapi.py
index a33203e82d..248d650858 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -983,7 +983,7 @@ class QAPISchemaEntity(object):
     def is_implicit(self):
         return not self.info
 
-    def visit(self, visitor):
+    def visit(self, visitor, builtins):
         pass
 
 
@@ -1084,8 +1084,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def doc_type(self):
         return self.json_type()
 
-    def visit(self, visitor):
-        visitor.visit_builtin_type(self.name, self.info, self.json_type())
+    def visit(self, visitor, builtins):
+        if builtins:
+            visitor.visit_builtin_type(self.name, self.info, self.json_type())
 
 
 class QAPISchemaEnumType(QAPISchemaType):
@@ -1118,9 +1119,11 @@ class QAPISchemaEnumType(QAPISchemaType):
     def json_type(self):
         return 'string'
 
-    def visit(self, visitor):
-        visitor.visit_enum_type(self.name, self.info,
-                                self.member_names(), self.prefix)
+    def visit(self, visitor, builtins):
+        # TODO use something cleaner than existence of info
+        if builtins or self.info:
+            visitor.visit_enum_type(self.name, self.info,
+                                    self.member_names(), self.prefix)
 
 
 class QAPISchemaArrayType(QAPISchemaType):
@@ -1149,8 +1152,10 @@ class QAPISchemaArrayType(QAPISchemaType):
             return None
         return 'array of ' + elt_doc_type
 
-    def visit(self, visitor):
-        visitor.visit_array_type(self.name, self.info, self.element_type)
+    def visit(self, visitor, builtins):
+        if builtins or not isinstance(self.element_type,
+                                      QAPISchemaBuiltinType):
+            visitor.visit_array_type(self.name, self.info, self.element_type)
 
 
 class QAPISchemaObjectType(QAPISchemaType):
@@ -1229,11 +1234,13 @@ class QAPISchemaObjectType(QAPISchemaType):
     def json_type(self):
         return 'object'
 
-    def visit(self, visitor):
-        visitor.visit_object_type(self.name, self.info,
-                                  self.base, self.local_members, self.variants)
-        visitor.visit_object_type_flat(self.name, self.info,
-                                       self.members, self.variants)
+    def visit(self, visitor, builtins):
+        # TODO use something cleaner than existence of info
+        if builtins or self.info:
+            visitor.visit_object_type(self.name, self.info, self.base,
+                                      self.local_members, self.variants)
+            visitor.visit_object_type_flat(self.name, self.info,
+                                           self.members, self.variants)
 
 
 class QAPISchemaMember(object):
@@ -1375,7 +1382,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
     def json_type(self):
         return 'value'
 
-    def visit(self, visitor):
+    def visit(self, visitor, builtins):
         visitor.visit_alternate_type(self.name, self.info, self.variants)
 
     def is_empty(self):
@@ -1415,7 +1422,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
             self.ret_type = schema.lookup_type(self._ret_type_name)
             assert isinstance(self.ret_type, QAPISchemaType)
 
-    def visit(self, visitor):
+    def visit(self, visitor, builtins):
         visitor.visit_command(self.name, self.info,
                               self.arg_type, self.ret_type,
                               self.gen, self.success_response, self.boxed)
@@ -1445,16 +1452,20 @@ class QAPISchemaEvent(QAPISchemaEntity):
         elif self.boxed:
             raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
 
-    def visit(self, visitor):
+    def visit(self, visitor, builtins):
         visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)
 
 
 class QAPISchema(object):
     def __init__(self, file):
         try:
-            parser = QAPISchemaParser(file)
-            self.exprs = check_exprs(parser.exprs)
-            self.docs = parser.docs
+            if file:
+                parser = QAPISchemaParser(file)
+                self.exprs = check_exprs(parser.exprs)
+                self.docs = parser.docs
+            else:
+                self.exprs = []
+                self.docs = []
             self._entity_dict = {}
             self._predefining = True
             self._def_predefineds()
@@ -1668,11 +1679,11 @@ class QAPISchema(object):
         for ent in self._entity_dict.values():
             ent.check(self)
 
-    def visit(self, visitor):
+    def visit(self, visitor, builtins=False):
         visitor.visit_begin(self)
         for (name, entity) in sorted(self._entity_dict.items()):
             if visitor.visit_needed(entity):
-                entity.visit(visitor)
+                entity.visit(visitor, builtins)
         visitor.visit_end()
 
 
@@ -1927,14 +1938,12 @@ def common_argument_parser(builtins=False):
         return string
 
     parser = argparse.ArgumentParser(conflict_handler='resolve')
-    if builtins:
-        parser.add_argument('-b', '--builtins', action='store_true',
-                            help='generate builtins')
     parser.add_argument('-o', '--output-dir', default='',
                         help='output directory')
     parser.add_argument('-p', '--prefix', default='', type=prefix,
                         help='prefix to add to output files')
     parser.add_argument('schema', type=argparse.FileType('r'),
+                        nargs='?' if builtins else None,
                         help='QAPI schema source file')
     return parser
 
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index d95d7541a3..071abc9d5d 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -257,7 +257,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
         if self.out:
             self.out += '\n'
         self.cur_doc = doc
-        entity.visit(self)
+        entity.visit(self, builtins=False)
         self.cur_doc = None
 
     def freeform(self, doc):
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 5d53c58506..2ef5dc51f1 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -371,6 +371,7 @@ check-qtest-s390x-y += tests/drive_del-test$(EXESUF)
 check-qtest-generic-y += tests/qom-test$(EXESUF)
 check-qtest-generic-y += tests/test-hmp$(EXESUF)
 
+qapi-schema += builtins.json
 qapi-schema += alternate-any.json
 qapi-schema += alternate-array.json
 qapi-schema += alternate-base.json
@@ -910,7 +911,8 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF)
 $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
 	$(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \
 		$(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
-		$^ >$*.test.out 2>$*.test.err; \
+		`echo "$^" | sed '/builtins/d'` \
+		>$*.test.out 2>$*.test.err; \
 		echo $$? >$*.test.exit, \
 		"TEST","$*.out")
 	@diff -q $(SRC_PATH)/$*.out $*.test.out
diff --git a/tests/qapi-schema/builtins.err b/tests/qapi-schema/builtins.err
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tests/qapi-schema/builtins.exit b/tests/qapi-schema/builtins.exit
new file mode 100644
index 0000000000..573541ac97
--- /dev/null
+++ b/tests/qapi-schema/builtins.exit
@@ -0,0 +1 @@
+0
diff --git a/tests/qapi-schema/builtins.json b/tests/qapi-schema/builtins.json
new file mode 100644
index 0000000000..c4088f6792
--- /dev/null
+++ b/tests/qapi-schema/builtins.json
@@ -0,0 +1 @@
+# This file exists to simplify make's job, it's not actually read
diff --git a/tests/qapi-schema/builtins.out b/tests/qapi-schema/builtins.out
new file mode 100644
index 0000000000..40b886ddae
--- /dev/null
+++ b/tests/qapi-schema/builtins.out
@@ -0,0 +1,3 @@
+enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
+    prefix QTYPE
+object q_empty
diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
index 17e652535c..6161b90e91 100644
--- a/tests/qapi-schema/comments.out
+++ b/tests/qapi-schema/comments.out
@@ -1,4 +1 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
-object q_empty
diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-bad-section.out
index 089bde1381..a2f0842130 100644
--- a/tests/qapi-schema/doc-bad-section.out
+++ b/tests/qapi-schema/doc-bad-section.out
@@ -1,7 +1,4 @@
 enum Enum ['one', 'two']
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
-object q_empty
 doc symbol=Enum
     body=
 == Produces *invalid* texinfo
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index f0ba51db4b..f609c5d5f5 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -6,8 +6,6 @@ object Object
     tag base1
     case one: Variant1
     case two: Variant2
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 object SugaredUnion
     member type: SugaredUnionKind optional=False
     tag type
@@ -21,7 +19,6 @@ command cmd q_obj_cmd-arg -> Object
    gen=True success_response=True boxed=False
 command cmd-boxed Object -> None
    gen=True success_response=True boxed=True
-object q_empty
 object q_obj_Variant1-wrapper
     member data: Variant1 optional=False
 object q_obj_Variant2-wrapper
diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
index 40b886ddae..e69de29bb2 100644
--- a/tests/qapi-schema/empty.out
+++ b/tests/qapi-schema/empty.out
@@ -1,3 +0,0 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
-object q_empty
diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-case.out
index 313c0fe7be..0c3a3b5ba2 100644
--- a/tests/qapi-schema/event-case.out
+++ b/tests/qapi-schema/event-case.out
@@ -1,5 +1,2 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 event oops None
    boxed=False
-object q_empty
diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/ident-with-escape.out
index b5637cb2e0..89fe61f9e9 100644
--- a/tests/qapi-schema/ident-with-escape.out
+++ b/tests/qapi-schema/ident-with-escape.out
@@ -1,7 +1,4 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 command fooA q_obj_fooA-arg -> None
    gen=True success_response=True boxed=False
-object q_empty
 object q_obj_fooA-arg
     member bar1: str optional=False
diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out
index 17e652535c..6161b90e91 100644
--- a/tests/qapi-schema/include-relpath.out
+++ b/tests/qapi-schema/include-relpath.out
@@ -1,4 +1 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
-object q_empty
diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out
index 17e652535c..6161b90e91 100644
--- a/tests/qapi-schema/include-repetition.out
+++ b/tests/qapi-schema/include-repetition.out
@@ -1,4 +1 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
-object q_empty
diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/include-simple.out
index 17e652535c..6161b90e91 100644
--- a/tests/qapi-schema/include-simple.out
+++ b/tests/qapi-schema/include-simple.out
@@ -1,4 +1 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
-object q_empty
diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indented-expr.out
index 586795f44d..bfdc976854 100644
--- a/tests/qapi-schema/indented-expr.out
+++ b/tests/qapi-schema/indented-expr.out
@@ -1,7 +1,4 @@
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 command eins None -> None
    gen=True success_response=True boxed=False
-object q_empty
 command zwei None -> None
    gen=True success_response=True boxed=False
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 3b1e9082d3..4b42db23b2 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -50,8 +50,6 @@ object NestedEnumsOne
     member enum4: EnumOne optional=True
 enum QEnumTwo ['value1', 'value2']
     prefix QENUM_TWO
-enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
-    prefix QTYPE
 object TestStruct
     member integer: int optional=False
     member boolean: bool optional=False
@@ -162,7 +160,6 @@ command guest-get-time q_obj_guest-get-time-arg -> int
    gen=True success_response=True boxed=False
 command guest-sync q_obj_guest-sync-arg -> any
    gen=True success_response=True boxed=False
-object q_empty
 object q_obj_EVENT_C-arg
     member a: int optional=True
     member b: UserDefOne optional=True
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 225417d861..0294a66619 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -53,12 +53,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
                 print '    case %s: %s' % (v.name, v.type.name)
 
 parser = argparse.ArgumentParser()
-parser.add_argument('schema', type=argparse.FileType('r'),
+parser.add_argument('schema', type=argparse.FileType('r'), nargs='?',
                     help='QAPI schema source file')
 args = parser.parse_args()
 
 schema = QAPISchema(args.schema)
-schema.visit(QAPISchemaTestVisitor())
+schema.visit(QAPISchemaTestVisitor(), builtins=not args.schema)
 
 for doc in schema.docs:
     if doc.symbol:
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (13 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 12:02   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type() Markus Armbruster
                   ` (16 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

This demonstrates a bug in the lowering of simple unions: if more than
one schema uses the same built-in type T for a simple union member,
they all generate the same q_obj_T_wrapper into their qapi-types.h.
They clash when you include more than one schema's qapi-types.h.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/qapi-schema/qapi-schema-test.json |  6 ++++++
 tests/qapi-schema/qapi-schema-test.out  | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index c72dbd8050..c091626635 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -82,6 +82,12 @@
   'base': 'UserDefZero',
   'data': { 'string': 'str', 'enum1': 'EnumOne' } }
 
+{ 'union': 'UserDefSimpleUnion',
+  'data': { 'value1': 'UserDefA',
+# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's
+#           'value2': 'int',
+            'value3': 'UserDefB' } }
+
 # this variant of UserDefFlatUnion defaults to a union that uses members with
 # allocated types to test corner cases in the cleanup/dealloc visitor
 { 'union': 'UserDefFlatUnion2',
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 4b42db23b2..97bb02f2fd 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -108,6 +108,12 @@ object UserDefOptions
     member u16: uint16List optional=True
     member i64x: int optional=True
     member u64x: uint64 optional=True
+object UserDefSimpleUnion
+    member type: UserDefSimpleUnionKind optional=False
+    tag type
+    case value1: q_obj_UserDefA-wrapper
+    case value3: q_obj_UserDefB-wrapper
+enum UserDefSimpleUnionKind ['value1', 'value3']
 object UserDefTwo
     member string0: str optional=False
     member dict1: UserDefTwoDict optional=False
@@ -169,6 +175,10 @@ object q_obj_EVENT_D-arg
     member b: str optional=False
     member c: str optional=True
     member enum3: EnumOne optional=True
+object q_obj_UserDefA-wrapper
+    member data: UserDefA optional=False
+object q_obj_UserDefB-wrapper
+    member data: UserDefB optional=False
 object q_obj_UserDefFlatUnion2-base
     member integer: int optional=True
     member string: str optional=False
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type()
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (14 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 12:00   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas Markus Armbruster
                   ` (15 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 248d650858..4871eb7740 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1552,6 +1552,11 @@ class QAPISchema(object):
                                                   members, None))
         return name
 
+    def _make_implicit_wrapper_type(self, typ, info):
+        return self._make_implicit_object_type(
+            typ, info, None, 'wrapper',
+            [self._make_member('data', typ, info)])
+
     def _def_enum_type(self, expr, info, doc):
         name = expr['enum']
         data = expr['data']
@@ -1588,8 +1593,7 @@ class QAPISchema(object):
         if isinstance(typ, list):
             assert len(typ) == 1
             typ = self._make_array_type(typ[0], info)
-        typ = self._make_implicit_object_type(
-            typ, info, None, 'wrapper', [self._make_member('data', typ, info)])
+        typ = self._make_implicit_wrapper_type(typ, info)
         return QAPISchemaObjectTypeVariant(case, typ)
 
     def _def_union_type(self, expr, info, doc):
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (15 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type() Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 12:04   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax Markus Armbruster
                   ` (14 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

If more than one schema uses the same built-in type T for a simple
union member, they all generate the same q_obj_T_wrapper into their
qapi-types.h.  They clash when you include more than one schema's
qapi-types.h.

Fix by generating them into builtin-qapi-types.h instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-types.py                   | 12 ++++++++----
 scripts/qapi.py                         |  2 ++
 tests/qapi-schema/builtins.out          | 30 ++++++++++++++++++++++++++++++
 tests/qapi-schema/qapi-schema-test.json |  3 +--
 tests/qapi-schema/qapi-schema-test.out  |  5 ++---
 5 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index 18fd2a98c0..c058540e4d 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -53,7 +53,10 @@ def gen_struct_members(members):
     return ret
 
 
-def gen_object(name, base, members, variants):
+def gen_object(name, info, base, members, variants):
+    # TODO use something cleaner than existence of info
+    if not info and args.schema:
+        return ''               # suppress built-in
     if name in objects_seen:
         return ''
     objects_seen.add(name)
@@ -62,7 +65,7 @@ def gen_object(name, base, members, variants):
     if variants:
         for v in variants.variants:
             if isinstance(v.type, QAPISchemaObjectType):
-                ret += gen_object(v.type.name, v.type.base,
+                ret += gen_object(v.type.name, v.type.info, v.type.base,
                                   v.type.local_members, v.type.variants)
 
     ret += mcgen('''
@@ -200,7 +203,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
         if name == 'q_empty':
             return
         self._fwdecl += gen_fwd_object_or_array(name)
-        self.decl += gen_object(name, base, members, variants)
+        self.decl += gen_object(name, info, base, members, variants)
         if base and not base.is_implicit():
             self.decl += gen_upcast(name, base)
         # TODO Worth changing the visitor signature, so we could
@@ -211,7 +214,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
 
     def visit_alternate_type(self, name, info, variants):
         self._fwdecl += gen_fwd_object_or_array(name)
-        self.decl += gen_object(name, None, [variants.tag_member], variants)
+        self.decl += gen_object(name, info, None,
+                                [variants.tag_member], variants)
         self._gen_type_cleanup(name)
 
 argparser = common_argument_parser(builtins=True)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 4871eb7740..477402b7f8 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1499,6 +1499,8 @@ class QAPISchema(object):
         # would be to use lazy instantiation, while figuring out how to
         # avoid compilation issues with multiple qapi-types.h.
         self._make_array_type(name, None)
+        # TODO same for wrapper types
+        self._make_implicit_wrapper_type(name, None)
 
     def _def_predefineds(self):
         for t in [('str',    'string',  'char' + pointer_suffix),
diff --git a/tests/qapi-schema/builtins.out b/tests/qapi-schema/builtins.out
index 40b886ddae..d289bfe919 100644
--- a/tests/qapi-schema/builtins.out
+++ b/tests/qapi-schema/builtins.out
@@ -1,3 +1,33 @@
 enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
     prefix QTYPE
 object q_empty
+object q_obj_any-wrapper
+    member data: any optional=False
+object q_obj_bool-wrapper
+    member data: bool optional=False
+object q_obj_int-wrapper
+    member data: int optional=False
+object q_obj_int16-wrapper
+    member data: int16 optional=False
+object q_obj_int32-wrapper
+    member data: int32 optional=False
+object q_obj_int64-wrapper
+    member data: int64 optional=False
+object q_obj_int8-wrapper
+    member data: int8 optional=False
+object q_obj_null-wrapper
+    member data: null optional=False
+object q_obj_number-wrapper
+    member data: number optional=False
+object q_obj_size-wrapper
+    member data: size optional=False
+object q_obj_str-wrapper
+    member data: str optional=False
+object q_obj_uint16-wrapper
+    member data: uint16 optional=False
+object q_obj_uint32-wrapper
+    member data: uint32 optional=False
+object q_obj_uint64-wrapper
+    member data: uint64 optional=False
+object q_obj_uint8-wrapper
+    member data: uint8 optional=False
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index c091626635..ac8aefc924 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -84,8 +84,7 @@
 
 { 'union': 'UserDefSimpleUnion',
   'data': { 'value1': 'UserDefA',
-# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's
-#           'value2': 'int',
+            'value2': 'int',
             'value3': 'UserDefB' } }
 
 # this variant of UserDefFlatUnion defaults to a union that uses members with
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 97bb02f2fd..fff25e26d0 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -112,8 +112,9 @@ object UserDefSimpleUnion
     member type: UserDefSimpleUnionKind optional=False
     tag type
     case value1: q_obj_UserDefA-wrapper
+    case value2: q_obj_int-wrapper
     case value3: q_obj_UserDefB-wrapper
-enum UserDefSimpleUnionKind ['value1', 'value3']
+enum UserDefSimpleUnionKind ['value1', 'value2', 'value3']
 object UserDefTwo
     member string0: str optional=False
     member dict1: UserDefTwoDict optional=False
@@ -211,8 +212,6 @@ object q_obj_numberList-wrapper
     member data: numberList optional=False
 object q_obj_sizeList-wrapper
     member data: sizeList optional=False
-object q_obj_str-wrapper
-    member data: str optional=False
 object q_obj_strList-wrapper
     member data: strList optional=False
 object q_obj_uint16List-wrapper
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (16 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:59   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings Markus Armbruster
                   ` (13 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Section "QMP/Guest agent schema" is one big paragraph, encumbered with
more detail than necessary.  It also claims JSON null isn't supported,
which is untrue since commit e53188a, v2.4.0.  Rewrite it.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/devel/qapi-code-gen.txt | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index f5b7659caf..3186c36460 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -25,24 +25,24 @@ how the schemas, scripts, and resulting code are used.
 
 == QMP/Guest agent schema ==
 
-A QAPI schema file is designed to be loosely based on JSON
-(http://www.ietf.org/rfc/rfc7159.txt) with changes for quoting style
-and the use of comments; a QAPI schema file is then parsed by a python
-code generation program.  A valid QAPI schema consists of a series of
-top-level expressions, with no commas between them.  Where
-dictionaries (JSON objects) are used, they are parsed as python
-OrderedDicts so that ordering is preserved (for predictable layout of
-generated C structs and parameter lists).  Ordering doesn't matter
-between top-level expressions or the keys within an expression, but
-does matter within dictionary values for 'data' and 'returns' members
-of a single expression.  QAPI schema input is written using 'single
-quotes' instead of JSON's "double quotes" (in contrast, Client JSON
-Protocol uses no comments, and while input accepts 'single quotes' as
-an extension, output is strict JSON using only "double quotes").  As
-in JSON, trailing commas are not permitted in arrays or dictionaries.
-Input must be ASCII (although QMP supports full Unicode strings, the
-QAPI parser does not).  At present, there is no place where a QAPI
-schema requires the use of JSON numbers or null.
+Schema syntax is based on JSON (RFC 7159), with the following
+differences:
+
+* Comments (see below)
+
+* No JSON numbers
+
+* Strings use 'single quotes' instead of "double quotes"
+
+* The input character set is plain ASCII
+
+  Unicode characters need to be escaped.  In contrast, the Client JSON
+  Protocol uses UTF-8.
+
+A QAPI schema consists of a sequence of JSON values (top-level
+expressions), with no commas between them.  The order of top-level
+expressions doesn't matter.  The order of keys in JSON objects is
+generally relevant.
 
 
 === Comments ===
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (17 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 11:58   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 20/32] qapi: Frontend for defining command line options Markus Armbruster
                   ` (12 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

The QAPI schema parser has always accepted only single-quoted strings,
even though JSON strings are double-quoted.  Accept double-quoted
strings as well, so you can write strings containing single quotes
without backslash escapes.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 docs/devel/qapi-code-gen.txt            | 2 +-
 scripts/qapi.py                         | 8 +++++---
 tests/qapi-schema/qapi-schema-test.json | 2 +-
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
index 3186c36460..835c641ea8 100644
--- a/docs/devel/qapi-code-gen.txt
+++ b/docs/devel/qapi-code-gen.txt
@@ -32,7 +32,7 @@ differences:
 
 * No JSON numbers
 
-* Strings use 'single quotes' instead of "double quotes"
+* Strings can use 'single quotes' in addition to "double quotes"
 
 * The input character set is plain ASCII
 
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 477402b7f8..18c8175866 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -382,14 +382,15 @@ class QAPISchemaParser(object):
                     return
             elif self.tok in '{}:,[]':
                 return
-            elif self.tok == "'":
+            elif self.tok == "'" or self.tok == '"':
                 string = ''
                 esc = False
                 while True:
                     ch = self.src[self.cursor]
                     self.cursor += 1
                     if ch == '\n':
-                        raise QAPIParseError(self, 'Missing terminating "\'"')
+                        raise QAPIParseError(
+                            self, 'Missing terminating %r' % self.tok)
                     if esc:
                         if ch == 'b':
                             string += '\b'
@@ -429,8 +430,9 @@ class QAPISchemaParser(object):
                         esc = False
                     elif ch == '\\':
                         esc = True
-                    elif ch == "'":
+                    elif ch == self.tok:
                         self.val = string
+                        self.tok = "'"
                         return
                     else:
                         string += ch
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index ac8aefc924..c74d5632a5 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -11,7 +11,7 @@
         'guest-sync' ] } }
 
 { 'struct': 'TestStruct',
-  'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }
+  'data': { 'integer': 'int', 'boolean': 'bool', 'string': "str" } }
 
 # for testing enums
 { 'struct': 'NestedEnumsOne',
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 20/32] qapi: Frontend for defining command line options
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (18 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 21/32] qapi: Define QAPIOptionKind and QAPIOption automatically Markus Armbruster
                   ` (11 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

TODO explain why
TODO update qapi-code-gen.txt
TODO negative tests

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi.py                         | 91 +++++++++++++++++++++++++++++++++
 tests/qapi-schema/qapi-schema-test.json | 19 +++++++
 tests/qapi-schema/qapi-schema-test.out  | 34 ++++++++++++
 tests/qapi-schema/test-qapi.py          | 10 ++++
 4 files changed, 154 insertions(+)

diff --git a/scripts/qapi.py b/scripts/qapi.py
index 18c8175866..1e03b62943 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -606,6 +606,11 @@ def check_name(info, source, name, meta):
         if meta != 'member-struct':
             raise QAPISemError(info, "%s does not allow optional name '%s'"
                                % (source, name))
+    # Options start with '--'
+    if meta == 'option':
+        if not name.startswith('--'):
+            raise QAPISemError(info, "%s must start with '--'" % source)
+        membername = name[2:]
     # Enum members can start with a digit, because the generated C
     # code always prefixes it with the enum name
     if meta == 'member-enum' and membername[0].isdigit():
@@ -708,6 +713,17 @@ def check_event(expr, info):
                expr.get('data'), allow_dict=not boxed, allow_metas=meta)
 
 
+def check_option(expr, info):
+    name = expr['option']
+    boxed = expr.get('boxed', False)
+
+    meta = ['built-in', 'struct', 'enum']
+    if boxed:
+        meta += ['union', 'alternate']
+    check_type(info, "'data' for option '%s'" % name,
+               expr.get('data'), allow_dict=not boxed, allow_metas=meta)
+
+
 def check_union(expr, info):
     name = expr['union']
     base = expr.get('base')
@@ -912,6 +928,10 @@ def check_exprs(exprs):
         elif 'event' in expr:
             meta = 'event'
             check_keys(expr_elem, 'event', [], ['data', 'boxed'])
+        elif 'option' in expr:
+            meta = 'option'
+            check_keys(expr_elem, 'option', ['help'],
+                       ['data', 'short', 'implied-key', 'boxed'])
         else:
             raise QAPISemError(expr_elem['info'],
                                "Expression is missing metatype")
@@ -951,6 +971,8 @@ def check_exprs(exprs):
             check_command(expr, info)
         elif 'event' in expr:
             check_event(expr, info)
+        elif 'option' in expr:
+            check_option(expr, info)
         else:
             assert False, 'unexpected meta type'
 
@@ -1025,6 +1047,10 @@ class QAPISchemaVisitor(object):
     def visit_event(self, name, info, arg_type, boxed):
         pass
 
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help_):
+        pass
+
 
 class QAPISchemaType(QAPISchemaEntity):
     # Return the C type for common use.
@@ -1458,6 +1484,56 @@ class QAPISchemaEvent(QAPISchemaEntity):
         visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)
 
 
+class QAPISchemaOption(QAPISchemaEntity):
+    def __init__(self, name, info, doc, arg_type, short, implied_key,
+                 boxed, help_):
+        QAPISchemaEntity.__init__(self, name, info, doc)
+        assert not arg_type or isinstance(arg_type, str)
+        self._arg_type_name = arg_type
+        self.arg_type = None
+        self.short = short
+        self.implied_key = implied_key
+        self.boxed = boxed
+        self.help = help_
+
+    def check(self, schema):
+        if self._arg_type_name:
+            self.arg_type = schema.lookup_type(self._arg_type_name)
+            assert (isinstance(self.arg_type, QAPISchemaType)
+                    and not isinstance(self.arg_type, QAPISchemaArrayType))
+            self.arg_type.check(schema)
+            if self.boxed:
+                if self.arg_type.is_empty():
+                    raise QAPISemError(self.info,
+                                       "Cannot use 'boxed' with empty type")
+            else:
+                assert not isinstance(self.arg_type, QAPISchemaAlternateType)
+                assert (not isinstance(self.arg_type, QAPISchemaObjectType)
+                        or not self.arg_type.variants)
+        elif self.boxed:
+            raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
+        if self.short and not (isinstance(self.short, str)
+                               and len(self.short) == 1):
+            raise QAPISemError(self.info,
+                               "Value of 'short' must be a character")
+        if self.implied_key and not isinstance(self.implied_key, str):
+            raise QAPISemError(self.info,
+                               "Value of 'implied-key' must be a string")
+        if self.help is None:
+            self.help = []
+        if not isinstance(self.help, list):
+            self.help = [self.help]
+        if not all([isinstance(elt, str) for elt in self.help]):
+            raise QAPISemError(
+                self.info,
+                "Value of 'help' must be a string or a list of strings")
+
+    def visit(self, visitor, builtins):
+        visitor.visit_option(self.name, self.info, self.arg_type,
+                             self.short, self.implied_key,
+                             self.boxed, self.help)
+
+
 class QAPISchema(object):
     def __init__(self, file):
         try:
@@ -1663,6 +1739,19 @@ class QAPISchema(object):
                 name, info, doc, 'arg', self._make_members(data, info))
         self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed))
 
+    def _def_option(self, expr, info, doc):
+        name = expr['option']
+        data = expr.get('data')
+        short = expr.get('short')
+        implied_key = expr.get('implied-key')
+        boxed = expr.get('boxed', False)
+        help_ = expr.get('help')
+        if isinstance(data, OrderedDict):
+            data = self._make_implicit_object_type(
+                name[2:], info, doc, 'optarg', self._make_members(data, info))
+        self._def_entity(QAPISchemaOption(name, info, doc, data,
+                                          short, implied_key, boxed, help_))
+
     def _def_exprs(self):
         for expr_elem in self.exprs:
             expr = expr_elem['expr']
@@ -1680,6 +1769,8 @@ class QAPISchema(object):
                 self._def_command(expr, info, doc)
             elif 'event' in expr:
                 self._def_event(expr, info, doc)
+            elif 'option' in expr:
+                self._def_option(expr, info, doc)
             else:
                 assert False
 
diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
index c74d5632a5..42b9968c72 100644
--- a/tests/qapi-schema/qapi-schema-test.json
+++ b/tests/qapi-schema/qapi-schema-test.json
@@ -193,3 +193,22 @@
   'data': { 'a': ['__org.qemu_x-Enum'], 'b': ['__org.qemu_x-Struct'],
             'c': '__org.qemu_x-Union2', 'd': '__org.qemu_x-Alt' },
   'returns': '__org.qemu_x-Union1' }
+
+# testing option
+{ 'option': '--help', 'short': 'h',
+  'help': "option without an argument" }
+{ 'option': '--opt-str', 'data': 'str',
+  'help': "option's argument is a string" }
+{ 'option': '--opt-int', 'data': 'int',
+  'help': "option's argument is an integer" }
+{ 'option': '--opt-enum', 'data': 'EnumOne',
+  'help': "option's argument is an enumeration" }
+{ 'option': '--opt-any', 'data': 'any',
+  'help': "--opt-any INT   option's argument is an integer" }
+{ 'option': '--opt-struct', 'data': { 's': 'str', '*i': 'int' },
+  'implied-key': 's',
+  'help': [
+      "an option with a complex argument",
+      "and multi-line help" ] }
+{ 'option': '--opt-boxed', 'data': 'UserDefZero', 'boxed': true,
+  'help': null }
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index fff25e26d0..9ee06539ac 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -1,3 +1,34 @@
+option --help None
+    short=h
+    boxed=False
+    help=
+option without an argument
+option --opt-any any
+    boxed=False
+    help=
+--opt-any INT   option's argument is an integer
+option --opt-boxed UserDefZero
+    boxed=True
+    help=
+
+option --opt-enum EnumOne
+    boxed=False
+    help=
+option's argument is an enumeration
+option --opt-int int
+    boxed=False
+    help=
+option's argument is an integer
+option --opt-str str
+    boxed=False
+    help=
+option's argument is a string
+option --opt-struct q_obj_opt-struct-optarg
+    implied-key=s
+    boxed=False
+    help=
+an option with a complex argument
+and multi-line help
 alternate AltEnumBool
     tag type
     case e: EnumOne
@@ -210,6 +241,9 @@ object q_obj_intList-wrapper
     member data: intList optional=False
 object q_obj_numberList-wrapper
     member data: numberList optional=False
+object q_obj_opt-struct-optarg
+    member s: str optional=False
+    member i: int optional=True
 object q_obj_sizeList-wrapper
     member data: sizeList optional=False
 object q_obj_strList-wrapper
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 0294a66619..2e5e7bfeb1 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -45,6 +45,16 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
         print 'event %s %s' % (name, arg_type and arg_type.name)
         print '   boxed=%s' % boxed
 
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help):
+        print 'option %s %s' % (name, arg_type and arg_type.name)
+        if short:
+            print '    short=%s' % short
+        if implied_key:
+            print '    implied-key=%s' % implied_key
+        print '    boxed=%s' % boxed
+        print '    help=\n%s' % '\n'.join(help)
+
     @staticmethod
     def _print_variants(variants):
         if variants:
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 21/32] qapi: Define QAPIOptionKind and QAPIOption automatically
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (19 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 20/32] qapi: Frontend for defining command line options Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 22/32] qapi: New helper c_string() Markus Armbruster
                   ` (10 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Enumeration type QAPIOptionKind enumerates the command line options.

Flat union QAPIOption captures a single command line option.  Its tag
is QAPIOptionKind, and the variants are the option argument types.

FIXME implement missing clash checking in QAPISchemaObjectType.check_clash()
FIXME potential clash in QAPISchema._def_autos()
FIXME made up info in QAPISchema._def_autos()
TODO can we avoid the wrappers around non-object option argument types?

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-commands.py               |  2 +-
 scripts/qapi-event.py                  |  2 +-
 scripts/qapi-introspect.py             |  2 +-
 scripts/qapi-types.py                  |  2 +-
 scripts/qapi-visit.py                  |  2 +-
 scripts/qapi.py                        | 42 ++++++++++++++++++++++++++++++++--
 scripts/qapi2texi.py                   |  2 +-
 tests/qapi-schema/qapi-schema-test.out | 14 ++++++++++++
 tests/qapi-schema/test-qapi.py         |  2 +-
 9 files changed, 61 insertions(+), 9 deletions(-)

diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
index 76cc9cc8a4..fdd3492f87 100644
--- a/scripts/qapi-commands.py
+++ b/scripts/qapi-commands.py
@@ -315,7 +315,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
                   prefix=args.prefix,
                   c_prefix=c_name(args.prefix, protect=False)))
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, args.prefix)
 gen = QAPISchemaGenCommandVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
index 1c61751bc0..64a4a02757 100644
--- a/scripts/qapi-event.py
+++ b/scripts/qapi-event.py
@@ -226,7 +226,7 @@ fdecl.write(mcgen('''
 
 event_enum_name = c_name(args.prefix + 'QAPIEvent', protect=False)
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, args.prefix)
 gen = QAPISchemaGenEventVisitor()
 schema.visit(gen)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index cc4ff01cd4..89365449b0 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -206,7 +206,7 @@ fdef.write(mcgen('''
 ''',
                  prefix=args.prefix))
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, args.prefix)
 gen = QAPISchemaGenIntrospectVisitor(args.unmask_non_abi_names)
 schema.visit(gen, builtins=True)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
index c058540e4d..5c53c56e45 100644
--- a/scripts/qapi-types.py
+++ b/scripts/qapi-types.py
@@ -276,7 +276,7 @@ else:
 #include "qapi/util.h"
 '''))
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, args.prefix)
 gen = QAPISchemaGenTypeVisitor()
 schema.visit(gen, builtins=not args.schema)
 fdef.write(gen.defn)
diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
index e756ef98ee..3182b860af 100644
--- a/scripts/qapi-visit.py
+++ b/scripts/qapi-visit.py
@@ -359,7 +359,7 @@ else:
 
 '''))
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, args.prefix)
 gen = QAPISchemaGenVisitVisitor()
 schema.visit(gen, builtins=not args.schema)
 fdef.write(gen.defn)
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 1e03b62943..efc128eee0 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1235,7 +1235,12 @@ class QAPISchemaObjectType(QAPISchemaType):
     # and update seen to track the members seen so far. Report any errors
     # on behalf of info, which is not necessarily self.info
     def check_clash(self, info, seen):
-        assert not self.variants       # not implemented
+        # check_union() ensures the following assertion holds, but
+        # QAPIUnion violates it.  Disable it for now, so we can play
+        # with QAPIUnion without having to implement the missing clash
+        # checking first.
+        # FIXME implement missing clash checking
+        # assert not self.variants       # not implemented
         for m in self.members:
             m.check_clash(info, seen)
 
@@ -1535,8 +1540,9 @@ class QAPISchemaOption(QAPISchemaEntity):
 
 
 class QAPISchema(object):
-    def __init__(self, file):
+    def __init__(self, file, prefix):
         try:
+            self.prefix = prefix
             if file:
                 parser = QAPISchemaParser(file)
                 self.exprs = check_exprs(parser.exprs)
@@ -1545,10 +1551,14 @@ class QAPISchema(object):
                 self.exprs = []
                 self.docs = []
             self._entity_dict = {}
+            self._option_arg = {}
             self._predefining = True
             self._def_predefineds()
             self._predefining = False
             self._def_exprs()
+            self._predefining = True
+            self._def_autos()
+            self._predefining = False
             self.check()
         except QAPIError as err:
             print >>sys.stderr, err
@@ -1751,6 +1761,7 @@ class QAPISchema(object):
                 name[2:], info, doc, 'optarg', self._make_members(data, info))
         self._def_entity(QAPISchemaOption(name, info, doc, data,
                                           short, implied_key, boxed, help_))
+        self._option_arg[name[2:]] = data
 
     def _def_exprs(self):
         for expr_elem in self.exprs:
@@ -1774,6 +1785,33 @@ class QAPISchema(object):
             else:
                 assert False
 
+    def _def_autos(self):
+        info = {'file': None, 'line': 0, 'parent': None}  # FIXME
+        if self._option_arg:
+            name = self.prefix + 'QAPIOption'
+            self._make_implicit_enum_type(name, info,
+                                          sorted(self._option_arg.keys()))
+            # FIXME what if these members clash with variant members?
+            members = [
+                QAPISchemaObjectTypeMember('type', name + 'Kind', False),
+                QAPISchemaObjectTypeMember('idx', 'int32', False),
+                QAPISchemaObjectTypeMember('cnt', 'int32', False)]
+            variants = []
+            for (key, value) in sorted(self._option_arg.items()):
+                if not value:
+                    continue
+                typ = self.lookup_type(value)
+                if isinstance(typ, QAPISchemaObjectType):
+                    v = self._make_variant(key, value)
+                else:
+                    # TODO can we avoid the wrapper?
+                    v = self._make_simple_variant(key, value, typ.info)
+                variants.append(v)
+            self._def_entity(QAPISchemaObjectType(
+                name, info, None, None, members,
+                QAPISchemaObjectTypeVariants('type', None, variants)
+                if variants else None))
+
     def check(self):
         for ent in self._entity_dict.values():
             ent.check(self)
diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index 071abc9d5d..0e099ebaa2 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -286,7 +286,7 @@ def main(argv):
                         help='QAPI schema source file')
     args = parser.parse_args()
 
-    schema = qapi.QAPISchema(args.schema)
+    schema = qapi.QAPISchema(args.schema, '')
     if not qapi.doc_required:
         print >>sys.stderr, ("%s: need pragma 'doc-required' "
                              "to generate documentation" % argv[0])
diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
index 9ee06539ac..16dc30dd99 100644
--- a/tests/qapi-schema/qapi-schema-test.out
+++ b/tests/qapi-schema/qapi-schema-test.out
@@ -79,6 +79,18 @@ object NestedEnumsOne
     member enum2: EnumOne optional=True
     member enum3: EnumOne optional=False
     member enum4: EnumOne optional=True
+object QAPIOption
+    member type: QAPIOptionKind optional=False
+    member idx: int32 optional=False
+    member cnt: int32 optional=False
+    tag type
+    case opt-any: q_obj_any-wrapper
+    case opt-boxed: UserDefZero
+    case opt-enum: q_obj_EnumOne-wrapper
+    case opt-int: q_obj_int-wrapper
+    case opt-str: q_obj_str-wrapper
+    case opt-struct: q_obj_opt-struct-optarg
+enum QAPIOptionKind ['help', 'opt-any', 'opt-boxed', 'opt-enum', 'opt-int', 'opt-str', 'opt-struct']
 enum QEnumTwo ['value1', 'value2']
     prefix QENUM_TWO
 object TestStruct
@@ -207,6 +219,8 @@ object q_obj_EVENT_D-arg
     member b: str optional=False
     member c: str optional=True
     member enum3: EnumOne optional=True
+object q_obj_EnumOne-wrapper
+    member data: EnumOne optional=False
 object q_obj_UserDefA-wrapper
     member data: UserDefA optional=False
 object q_obj_UserDefB-wrapper
diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
index 2e5e7bfeb1..7de7d6dc53 100644
--- a/tests/qapi-schema/test-qapi.py
+++ b/tests/qapi-schema/test-qapi.py
@@ -67,7 +67,7 @@ parser.add_argument('schema', type=argparse.FileType('r'), nargs='?',
                     help='QAPI schema source file')
 args = parser.parse_args()
 
-schema = QAPISchema(args.schema)
+schema = QAPISchema(args.schema, '')
 schema.visit(QAPISchemaTestVisitor(), builtins=not args.schema)
 
 for doc in schema.docs:
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 22/32] qapi: New helper c_string()
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (20 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 21/32] qapi: Define QAPIOptionKind and QAPIOption automatically Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 23/32] qapi-options: Command line option backend Markus Armbruster
                   ` (9 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Use new c_string() to replace qapi-introspect's more limited
to_c_string().

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-introspect.py |  8 ++------
 scripts/qapi.py            | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 89365449b0..52404b07ab 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -35,10 +35,6 @@ def to_json(obj, level=0):
     return ret
 
 
-def to_c_string(string):
-    return '"' + string.replace('\\', r'\\').replace('"', r'\"') + '"'
-
-
 class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
     def __init__(self, unmask):
         self._unmask = unmask
@@ -70,12 +66,12 @@ extern const char %(c_name)s[];
 ''',
                           c_name=c_name(name))
         lines = to_json(jsons).split('\n')
-        c_string = '\n    '.join([to_c_string(line) for line in lines])
         self.defn = mcgen('''
 const char %(c_name)s[] = %(c_string)s;
 ''',
                           c_name=c_name(name),
-                          c_string=c_string)
+                          c_string='\n    '.join([c_string(line)
+                                                  for line in lines]))
         self._schema = None
         self._jsons = None
         self._used_types = None
diff --git a/scripts/qapi.py b/scripts/qapi.py
index efc128eee0..958249fbd8 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -1915,6 +1915,21 @@ def c_name(name, protect=True):
         return 'q_' + name
     return name
 
+
+def c_string(string):
+    def escape_ch(match):
+        ch = match.group(0)
+        esc = {'\a': 'a', '\b': 'b', '\f': 'f', '\n': 'n', '\r': 'r',
+               '\t': 't', '\v': 'v', '"': r'"', '\\': '\\'}.get(ch)
+        if not esc:
+            esc = 'x%02x' % ord(ch)
+        return '\\' + esc
+
+    if string is None:
+        return "NULL"
+    return '"' + re.sub(r'[\0-\37"\\\177]', escape_ch, string) + '"'
+
+
 eatspace = '\033EATSPACE.'
 pointer_suffix = ' *' + eatspace
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 23/32] qapi-options: Command line option backend
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (21 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 22/32] qapi: New helper c_string() Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 24/32] qapi-options: Generate help string Markus Armbruster
                   ` (8 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

New qapi generator qapi-options.py generates code for parsing command
line options into an array of QAPIOption.

TODO negative tests

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 Makefile                  |  11 ++-
 Makefile.objs             |   1 +
 scripts/qapi-options.py   | 199 ++++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.include    |  16 +++-
 tests/test-qapi-options.c |  74 +++++++++++++++++
 5 files changed, 297 insertions(+), 4 deletions(-)
 create mode 100644 scripts/qapi-options.py
 create mode 100644 tests/test-qapi-options.c

diff --git a/Makefile b/Makefile
index 421e65d833..5e858f7295 100644
--- a/Makefile
+++ b/Makefile
@@ -56,8 +56,8 @@ GENERATED_FILES += builtin-qapi-types.h builtin-qapi-types.c
 GENERATED_FILES += builtin-qapi-visit.h builtin-qapi-visit.c
 GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
 GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
-GENERATED_FILES += qmp-introspect.h
-GENERATED_FILES += qmp-introspect.c
+GENERATED_FILES += qapi-options.h qmp-introspect.h
+GENERATED_FILES += qapi-options.c qmp-introspect.c
 
 GENERATED_FILES += trace/generated-tcg-tracers.h
 
@@ -470,6 +470,13 @@ qapi-commands-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-p
 		$<, \
 		"GEN","$@")
 
+.INTERMEDIATE: qapi-options-gen
+qapi-options.h qapi-options.c: qapi-options-gen
+qapi-options-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-options.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-options.py \
+		$<, \
+		"GEN","$@")
+
 .INTERMEDIATE: qapi-introspect-gen
 qmp-introspect.h qmp-introspect.c: qapi-introspect-gen
 qapi-introspect-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
diff --git a/Makefile.objs b/Makefile.objs
index c2c62cb462..908ec053fe 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -80,6 +80,7 @@ common-obj-$(CONFIG_FDT) += device_tree.o
 # qapi
 
 common-obj-y += qmp-marshal.o
+common-obj-y += qapi-options.o
 common-obj-y += qmp-introspect.o
 common-obj-y += qmp.o hmp.o
 endif
diff --git a/scripts/qapi-options.py b/scripts/qapi-options.py
new file mode 100644
index 0000000000..240c9021c7
--- /dev/null
+++ b/scripts/qapi-options.py
@@ -0,0 +1,199 @@
+#
+# QAPI option generator
+#
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# Authors:
+#  Markus Armbruster <armbru@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.
+# See the COPYING file in the top-level directory.
+
+from qapi import *
+
+
+class QAPISchemaGenOptionVisitor(QAPISchemaVisitor):
+    def __init__(self):
+        self.decl = None
+        self.defn = None
+        self._shortopts = None
+        self._longopts = None
+        self._cases = None
+
+    def visit_begin(self, schema):
+        self.decl = ''
+        self.defn = ''
+        self._shortopts = ''
+        self._longopts = ''
+        self._cases = ''
+
+    def visit_end(self):
+        if self._cases:
+            c_max = c_enum_const(args.prefix + 'QAPIOptionKind', '_MAX')
+            self.decl += mcgen('''
+%(c_prefix)sQAPIOption *%(c_prefix)sqapi_options_parse(int argc, char *argv[]);
+''',
+                               c_prefix=c_name(args.prefix, protect=False))
+            self.defn += mcgen('''
+%(c_prefix)sQAPIOption *%(c_prefix)sqapi_options_parse(int argc, char *argv[])
+{
+    static const struct option longopts[] = {
+%(longopts)s        {0}
+    };
+    %(c_prefix)sQAPIOption *opt = g_new(%(c_prefix)sQAPIOption, argc);
+    int nopt, longidx, ret;
+    Visitor *v;
+
+    optind = 0;
+
+    for (nopt = 0, opt[nopt].idx = 1;
+         (ret = getopt_long_only(argc, argv, %(c_shortopts)s,
+                                 longopts, &longidx)) >= 0;
+         opt[++nopt].idx = optind) {
+        if (ret > 255) {
+            opt[nopt].type = longopts[longidx].val - 256;
+        }
+        opt[nopt].cnt = optind - opt[nopt].idx;
+        loc_set_cmdline(argv, opt[nopt].idx, opt[nopt].cnt);
+
+        switch(ret) {
+%(cases)s
+        case '?':
+            exit(1);
+        default:
+            abort();
+        }
+    }
+
+    opt[nopt].type = %(c_max)s;
+    opt[nopt].cnt = 0;
+
+    return g_renew(%(c_prefix)sQAPIOption, opt, nopt + 1);
+}
+''',
+                               c_prefix=c_name(args.prefix, protect=False),
+                               c_shortopts=c_string(self._shortopts),
+                               longopts=self._longopts,
+                               cases=self._cases,
+                               c_max=c_max)
+        self._shortopts = None
+        self._longopts = None
+        self._cases = None
+
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help_):
+        name = name[2:]
+        enum_val = c_enum_const(args.prefix + 'QAPIOptionKind', name)
+
+        push_indent(8)
+
+        self._longopts += mcgen('''
+{
+    .name = "%(name)s",
+    .has_arg = %(has_arg)s,
+    .val = %(val)s
+},
+''',
+                                name=name,
+                                has_arg='required_argument'
+                                if arg_type else 'no_argument',
+                                val='256 + ' + enum_val)
+        if short:
+            self._shortopts += short
+            if arg_type:
+                self._shortopts += ':'
+            self._cases += mcgen('''
+case '%(char)s':
+    opt[nopt].type = %(case)s;
+    /* fall through */
+''',
+                                 char=short, case=enum_val)
+
+        self._cases += mcgen('''
+case 256 + %(case)s:
+''',
+                             case=enum_val)
+        if arg_type is None:
+            pass
+        elif isinstance(arg_type, QAPISchemaObjectType):
+            self._cases += mcgen('''
+    v = qobject_input_visitor_new_str(optarg, %(c_implied_key)s, &error_fatal);
+    visit_start_struct(v, NULL, NULL, 0, &error_fatal);
+    visit_type_%(c_type)s_members(v, &opt[nopt].u.%(c_name)s, &error_fatal);
+    visit_check_struct(v, &error_fatal);
+    visit_end_struct(v, NULL);
+    visit_free(v);
+''',
+                                 c_name=c_name(name), c_type=arg_type.c_name(),
+                                 c_implied_key=c_string(implied_key))
+        else:
+            assert isinstance(arg_type,
+                              (QAPISchemaBuiltinType, QAPISchemaEnumType))
+            self._cases += mcgen('''
+    v = qobject_input_visitor_new_keyval(QOBJECT(qstring_from_str(optarg)));
+    visit_type_%(c_type)s(v, NULL, &opt[nopt].u.%(c_name)s.data, &error_fatal);
+    visit_free(v);
+''',
+                                 c_name=c_name(name), c_type=arg_type.c_name())
+        self._cases += mcgen('''
+    break;
+''')
+
+        pop_indent(8)
+
+
+args = common_argument_parser().parse_args()
+
+c_comment = '''
+/*
+ * QAPI command line options
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+'''
+h_comment = '''
+/*
+ * QAPI command line options
+ *
+ * Copyright (C) 2017 Red Hat, Inc.
+ *
+ * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
+ * See the COPYING.LIB file in the top-level directory.
+ *
+ */
+'''
+
+(fdef, fdecl) = open_output(args.output_dir, args.prefix,
+                            'qapi-options.c', 'qapi-options.h',
+                            c_comment, h_comment)
+
+fdef.write(mcgen('''
+#include "qemu/osdep.h"
+#include <getopt.h>
+#include "%(prefix)sqapi-options.h"
+#include "%(prefix)sqapi-visit.h"
+#include "qapi/error.h"
+#include "qapi/qmp/qstring.h"
+#include "qapi/qobject-input-visitor.h"
+#include "qemu/error-report.h"
+
+''',
+                 prefix=args.prefix))
+
+fdecl.write(mcgen('''
+#include "%(prefix)sqapi-types.h"
+
+''',
+                  prefix=args.prefix))
+
+schema = QAPISchema(args.schema, args.prefix)
+gen = QAPISchemaGenOptionVisitor()
+schema.visit(gen)
+fdef.write(gen.defn)
+fdecl.write(gen.decl)
+
+close_output(fdef, fdecl)
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 2ef5dc51f1..442de4e0aa 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -59,6 +59,7 @@ check-unit-y += tests/test-string-output-visitor$(EXESUF)
 gcov-files-test-string-output-visitor-y = qapi/string-output-visitor.c
 check-unit-y += tests/test-qmp-event$(EXESUF)
 gcov-files-test-qmp-event-y += qapi/qmp-event.c
+check-unit-y += tests/test-qapi-options(EXESUF)
 check-unit-y += tests/test-opts-visitor$(EXESUF)
 gcov-files-test-opts-visitor-y = qapi/opts-visitor.c
 check-unit-y += tests/test-coroutine$(EXESUF)
@@ -542,7 +543,7 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, $(qapi-schema))
 
 GENERATED_FILES += tests/test-qapi-types.h tests/test-qapi-visit.h \
 	tests/test-qmp-commands.h tests/test-qapi-event.h \
-	tests/test-qmp-introspect.h
+	tests/test-qapi-options.h tests/test-qmp-introspect.h
 
 test-obj-y = tests/check-qnum.o tests/check-qstring.o tests/check-qdict.o \
 	tests/check-qlist.o tests/check-qnull.o \
@@ -567,7 +568,8 @@ QEMU_CFLAGS += -I$(SRC_PATH)/tests
 test-util-obj-y = libqemuutil.a
 test-qom-obj-y = $(qom-obj-y) $(test-util-obj-y)
 test-qapi-obj-y = tests/test-qapi-visit.o tests/test-qapi-types.o \
-	tests/test-qapi-event.o tests/test-qmp-introspect.o \
+	tests/test-qapi-event.o tests/test-qapi-options.o \
+	tests/test-qmp-introspect.o \
 	$(test-qom-obj-y)
 benchmark-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y)
 test-crypto-obj-y = $(crypto-obj-y) $(test-qom-obj-y)
@@ -651,6 +653,15 @@ $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-com
 		-o tests -p "test-" $<, \
 		"GEN","$@")
 
+.INTERMEDIATE: tests/test-qapi-options-gen
+tests/test-qapi-options.c tests/test-qapi-options.h: tests/test-qapi-options-gen
+tests/test-qapi-options-gen: \
+$(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-options.py $(qapi-py)
+	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-options.py \
+		-o tests -p "test-" $<, \
+		"GEN","$@")
+tests/test-qmp-introspect.c tests/test-qmp-introspect.h :\
+
 .INTERMEDIATE: tests/test-qapi-event-gen
 tests/test-qapi-event.c tests/test-qapi-event.h: tests/test-qapi-event-gen ;
 tests/test-qapi-event-gen: \
@@ -673,6 +684,7 @@ tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.jso
 tests/test-string-output-visitor$(EXESUF): tests/test-string-output-visitor.o $(test-qapi-obj-y)
 tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(test-qapi-obj-y)
 tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y)
+tests/test-qapi-options(EXESUF): tests/test-qapi-options.o $(test-qapi-obj-y)
 tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y)
 tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y)
 tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y) qmp-introspect.o
diff --git a/tests/test-qapi-options.c b/tests/test-qapi-options.c
new file mode 100644
index 0000000000..aa4394abdb
--- /dev/null
+++ b/tests/test-qapi-options.c
@@ -0,0 +1,74 @@
+#include "qemu/osdep.h"
+#include "qapi/qmp/qlit.h"
+#include "test-qapi-options.h"
+
+static void test_qapi_options_parse(void)
+{
+    static const char *argv[] = {
+        "progname",
+        "--help",
+        "-h",
+        "--opt-str", "hello",
+        "--opt-int", "123",
+        "--opt-enum", "value1",
+        "--opt-any", "hello",
+        "--opt-any", "123",
+        "--opt-struct", "sval,i=1",
+        "--opt-boxed", "integer=42",
+        NULL
+    };
+    static QLitObject qlit_hello = QLIT_QSTR("hello");
+    static QLitObject qlit_123 = QLIT_QSTR("123");
+    test_QAPIOption *opt;
+
+    opt = test_qapi_options_parse(ARRAY_SIZE(argv) - 1, (char **)argv);
+    g_assert_cmpint(opt[0].type, ==, TEST_QAPI_OPTION_KIND_HELP);
+    g_assert_cmpint(opt[0].idx, ==, 1);
+    g_assert_cmpint(opt[0].cnt, ==, 1);
+    g_assert_cmpint(opt[1].type, ==, TEST_QAPI_OPTION_KIND_HELP);
+    g_assert_cmpint(opt[1].idx, ==, 2);
+    g_assert_cmpint(opt[1].cnt, ==, 1);
+    g_assert_cmpint(opt[2].type, ==, TEST_QAPI_OPTION_KIND_OPT_STR);
+    g_assert_cmpint(opt[2].idx, ==, 3);
+    g_assert_cmpint(opt[2].cnt, ==, 2);
+    g_assert_cmpstr(opt[2].u.opt_str.data, ==, "hello");
+    g_assert_cmpint(opt[3].type, ==, TEST_QAPI_OPTION_KIND_OPT_INT);
+    g_assert_cmpint(opt[3].idx, ==, 5);
+    g_assert_cmpint(opt[3].cnt, ==, 2);
+    g_assert_cmpint(opt[3].u.opt_int.data, ==, 123);
+    g_assert_cmpint(opt[4].type, ==, TEST_QAPI_OPTION_KIND_OPT_ENUM);
+    g_assert_cmpint(opt[4].idx, ==, 7);
+    g_assert_cmpint(opt[4].cnt, ==, 2);
+    g_assert_cmpint(opt[4].u.opt_enum.data, ==, ENUM_ONE_VALUE1);
+    g_assert_cmpint(opt[5].type, ==, TEST_QAPI_OPTION_KIND_OPT_ANY);
+    g_assert_cmpint(opt[5].idx, ==, 9);
+    g_assert_cmpint(opt[5].cnt, ==, 2);
+    g_assert(qlit_equal_qobject(&qlit_hello, opt[5].u.opt_any.data));
+    g_assert_cmpint(opt[6].type, ==, TEST_QAPI_OPTION_KIND_OPT_ANY);
+    g_assert_cmpint(opt[6].idx, ==, 11);
+    g_assert_cmpint(opt[6].cnt, ==, 2);
+    g_assert(qlit_equal_qobject(&qlit_123, opt[6].u.opt_any.data));
+    g_assert_cmpint(opt[7].type, ==, TEST_QAPI_OPTION_KIND_OPT_STRUCT);
+    g_assert_cmpint(opt[7].idx, ==, 13);
+    g_assert_cmpint(opt[7].cnt, ==, 2);
+    g_assert_cmpstr(opt[7].u.opt_struct.s, ==, "sval");
+    g_assert_cmpint(opt[8].type, ==, TEST_QAPI_OPTION_KIND_OPT_BOXED);
+    g_assert_cmpint(opt[8].idx, ==, 15);
+    g_assert_cmpint(opt[8].cnt, ==, 2);
+    g_assert_cmpint(opt[8].u.opt_boxed.integer, ==, 42);
+    g_assert_cmpint(opt[9].type, ==, TEST_QAPI_OPTION_KIND__MAX);
+    g_assert_cmpint(opt[9].idx, ==, 17);
+    g_assert_cmpint(opt[9].cnt, ==, 0);
+    g_free(opt);
+}
+
+int main(int argc, char **argv)
+{
+    g_test_init(&argc, &argv, NULL);
+
+    g_test_add_func("/qapi/options-parse", test_qapi_options_parse);
+
+    g_test_run();
+
+    return 0;
+}
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 24/32] qapi-options: Generate help string
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (22 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 23/32] qapi-options: Command line option backend Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 25/32] qapi-introspect: Include command line options information Markus Armbruster
                   ` (7 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi-options.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/qapi-options.py b/scripts/qapi-options.py
index 240c9021c7..820d70f71f 100644
--- a/scripts/qapi-options.py
+++ b/scripts/qapi-options.py
@@ -13,12 +13,15 @@ from qapi import *
 
 
 class QAPISchemaGenOptionVisitor(QAPISchemaVisitor):
+    # TODO keep help in source order
+    # TODO generate the part of help that shows syntax
     def __init__(self):
         self.decl = None
         self.defn = None
         self._shortopts = None
         self._longopts = None
         self._cases = None
+        self._help = None
 
     def visit_begin(self, schema):
         self.decl = ''
@@ -26,15 +29,22 @@ class QAPISchemaGenOptionVisitor(QAPISchemaVisitor):
         self._shortopts = ''
         self._longopts = ''
         self._cases = ''
+        self._help = []
 
     def visit_end(self):
         if self._cases:
             c_max = c_enum_const(args.prefix + 'QAPIOptionKind', '_MAX')
+            c_help = '\n    '.join([c_string(h) for h in self._help])
             self.decl += mcgen('''
+extern const char %(c_prefix)sqapi_options_help[];
+
 %(c_prefix)sQAPIOption *%(c_prefix)sqapi_options_parse(int argc, char *argv[]);
 ''',
                                c_prefix=c_name(args.prefix, protect=False))
             self.defn += mcgen('''
+const char %(c_prefix)sqapi_options_help[] =
+    %(c_help)s;
+
 %(c_prefix)sQAPIOption *%(c_prefix)sqapi_options_parse(int argc, char *argv[])
 {
     static const struct option longopts[] = {
@@ -72,6 +82,7 @@ class QAPISchemaGenOptionVisitor(QAPISchemaVisitor):
 }
 ''',
                                c_prefix=c_name(args.prefix, protect=False),
+                               c_help=c_help,
                                c_shortopts=c_string(self._shortopts),
                                longopts=self._longopts,
                                cases=self._cases,
@@ -79,6 +90,7 @@ class QAPISchemaGenOptionVisitor(QAPISchemaVisitor):
         self._shortopts = None
         self._longopts = None
         self._cases = None
+        self._help = None
 
     def visit_option(self, name, info, arg_type, short, implied_key,
                      boxed, help_):
@@ -140,6 +152,7 @@ case 256 + %(case)s:
 ''')
 
         pop_indent(8)
+        self._help += help_
 
 
 args = common_argument_parser().parse_args()
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 25/32] qapi-introspect: Include command line options information
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (23 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 24/32] qapi-options: Generate help string Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 26/32] qapi2texi: " Markus Armbruster
                   ` (6 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Make query-qmp-schema describe command line options in addition to QMP
commands and events.  Simple, but it pushes query-qmp-schema beyond
QMP.  Perhaps options introspection should be separate.  Perhaps not
for the same reason QMP and command line are defined in the same
schema: they share many types.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/introspect.json       | 22 ++++++++++++++++++++--
 scripts/qapi-introspect.py | 10 +++++++++-
 2 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/qapi/introspect.json b/qapi/introspect.json
index 5b3e6e9d78..0b6be5b19c 100644
--- a/qapi/introspect.json
+++ b/qapi/introspect.json
@@ -70,11 +70,13 @@
 #
 # @event: a QMP event
 #
+# @option: a command line option (since 2.11)
+#
 # Since: 2.5
 ##
 { 'enum': 'SchemaMetaType',
   'data': [ 'builtin', 'enum', 'array', 'object', 'alternate',
-            'command', 'event' ] }
+            'command', 'event', 'option' ] }
 
 ##
 # @SchemaInfo:
@@ -103,7 +105,8 @@
       'object': 'SchemaInfoObject',
       'alternate': 'SchemaInfoAlternate',
       'command': 'SchemaInfoCommand',
-      'event': 'SchemaInfoEvent' } }
+      'event': 'SchemaInfoEvent',
+      'option': 'SchemaInfoOption' } }
 
 ##
 # @SchemaInfoBuiltin:
@@ -278,3 +281,18 @@
 ##
 { 'struct': 'SchemaInfoEvent',
   'data': { 'arg-type': 'str' } }
+
+##
+# @SchemaInfoOption:
+#
+# Additional SchemaInfo members for meta-type 'option'.
+#
+# @arg-type: the name of the object type that provides the option's
+#            parameters.
+#
+# @short: the option character, if any.
+#
+# Since: 2.11
+##
+{ 'struct': 'SchemaInfoOption',
+  'data': { 'arg-type': 'str', '*short': 'str' } }
diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
index 52404b07ab..650e5597b0 100644
--- a/scripts/qapi-introspect.py
+++ b/scripts/qapi-introspect.py
@@ -108,7 +108,7 @@ const char %(c_name)s[] = %(c_string)s;
         return self._name(typ.name)
 
     def _gen_json(self, name, mtype, obj):
-        if mtype not in ('command', 'event', 'builtin', 'array'):
+        if mtype not in ('command', 'event', 'option', 'builtin', 'array'):
             name = self._name(name)
         obj['name'] = name
         obj['meta-type'] = mtype
@@ -161,6 +161,14 @@ const char %(c_name)s[] = %(c_string)s;
         arg_type = arg_type or self._schema.the_empty_object_type
         self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)})
 
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help_):
+        arg_type = arg_type or self._schema.the_empty_object_type
+        obj = {'arg-type': self._use_type(arg_type)}
+        if short:
+            obj['short'] = short
+        self._gen_json(name, 'option', obj)
+
 parser = common_argument_parser()
 # Debugging aid: unmask QAPI schema's type names
 # We normally mask them, because they're not QMP wire ABI
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 26/32] qapi2texi: Include command line options information
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (24 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 25/32] qapi-introspect: Include command line options information Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment Markus Armbruster
                   ` (5 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Make generated QEMU QMP reference cover command line options in
addition to QMP commands and events.  Simple, but pushes the QMP
reference beyond QMP.  Perhaps options documentation should be
separate.  Perhaps not for the same reason QMP and command line are
defined in the same schema: they share many types.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 scripts/qapi2texi.py            | 15 ++++++++++++++
 tests/qapi-schema/doc-good.json | 24 ++++++++++++++++++++++
 tests/qapi-schema/doc-good.out  | 45 +++++++++++++++++++++++++++++++++++++++++
 tests/qapi-schema/doc-good.texi | 45 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 129 insertions(+)

diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
index 0e099ebaa2..c638b82631 100755
--- a/scripts/qapi2texi.py
+++ b/scripts/qapi2texi.py
@@ -253,6 +253,21 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
                             name=doc.symbol,
                             body=texi_entity(doc, 'Arguments'))
 
+    def visit_option(self, name, info, arg_type, short, implied_key,
+                     boxed, help):
+        doc = self.cur_doc
+        if self.out:
+            self.out += '\n'
+        if boxed:
+            body = texi_body(doc)
+            body += '\n@b{Arguments:} the members of @code{%s}' % arg_type.name
+            body += texi_sections(doc)
+        else:
+            body = texi_entity(doc, 'Arguments')
+        self.out += MSG_FMT(type='Option',
+                            name=doc.symbol,
+                            body=body)
+
     def symbol(self, doc, entity):
         if self.out:
             self.out += '\n'
diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
index d3ddf828ef..eba8acd50d 100644
--- a/tests/qapi-schema/doc-good.json
+++ b/tests/qapi-schema/doc-good.json
@@ -151,3 +151,27 @@
 ##
 { 'command': 'cmd-boxed', 'boxed': true,
   'data': 'Object' }
+
+##
+# @--help:
+# Display help and exit.
+##
+{ 'option': '--help', 'short': 'h' , 'help': null }
+
+##
+# @--opt-arg-str:
+# TODO support documenting simple option argument
+##
+{ 'option': '--opt-arg-str', 'data': 'str' , 'help': null }
+
+##
+# @--opt-arg-struct:
+# @s: a string
+# @i: an integer
+##
+{ 'option': '--opt-arg-struct', 'data': { 's': 'str', '*i': 'int' } , 'help': null }
+
+##
+# @--opt-arg-boxed:
+##
+{ 'option': '--opt-arg-boxed', 'data': 'Base', 'boxed': true , 'help': null }
diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
index f609c5d5f5..bb4ffa0918 100644
--- a/tests/qapi-schema/doc-good.out
+++ b/tests/qapi-schema/doc-good.out
@@ -1,3 +1,20 @@
+option --help None
+    short=h
+    boxed=False
+    help=
+
+option --opt-arg-boxed Base
+    boxed=True
+    help=
+
+option --opt-arg-str str
+    boxed=False
+    help=
+
+option --opt-arg-struct q_obj_opt-arg-struct-optarg
+    boxed=False
+    help=
+
 object Base
     member base1: Enum optional=False
 enum Enum ['one', 'two']
@@ -6,6 +23,15 @@ object Object
     tag base1
     case one: Variant1
     case two: Variant2
+object QAPIOption
+    member type: QAPIOptionKind optional=False
+    member idx: int32 optional=False
+    member cnt: int32 optional=False
+    tag type
+    case opt-arg-boxed: Base
+    case opt-arg-str: q_obj_str-wrapper
+    case opt-arg-struct: q_obj_opt-arg-struct-optarg
+enum QAPIOptionKind ['help', 'opt-arg-boxed', 'opt-arg-str', 'opt-arg-struct']
 object SugaredUnion
     member type: SugaredUnionKind optional=False
     tag type
@@ -27,6 +53,9 @@ object q_obj_cmd-arg
     member arg1: int optional=False
     member arg2: str optional=True
     member arg3: bool optional=False
+object q_obj_opt-arg-struct-optarg
+    member s: str optional=False
+    member i: int optional=True
 doc freeform
     body=
 = Section
@@ -161,3 +190,19 @@ If you're bored enough to read this, go see a video of boxed cats
 -> in
 
 <- out
+doc symbol=--help
+    body=
+Display help and exit.
+doc symbol=--opt-arg-str
+    body=
+TODO support documenting simple option argument
+doc symbol=--opt-arg-struct
+    body=
+
+    arg=s
+a string
+    arg=i
+an integer
+doc symbol=--opt-arg-boxed
+    body=
+
diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
index 4a9162c2a2..fd46358008 100644
--- a/tests/qapi-schema/doc-good.texi
+++ b/tests/qapi-schema/doc-good.texi
@@ -241,3 +241,48 @@ If you're bored enough to read this, go see a video of boxed cats
 @end deftypefn
 
 
+
+
+@deftypefn Option {} --help
+
+Display help and exit.
+
+@end deftypefn
+
+
+
+
+@deftypefn Option {} --opt-arg-str
+
+TODO support documenting simple option argument
+
+@end deftypefn
+
+
+
+
+@deftypefn Option {} --opt-arg-struct
+
+
+
+@b{Arguments:}
+@table @asis
+@item @code{s: string}
+a string
+@item @code{i: int} (optional)
+an integer
+@end table
+
+@end deftypefn
+
+
+
+
+@deftypefn Option {} --opt-arg-boxed
+
+
+
+@b{Arguments:} the members of @code{Base}
+@end deftypefn
+
+
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (25 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 26/32] qapi2texi: " Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-04 12:10   ` Marc-André Lureau
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 28/32] vl: QAPIfy command line option definition Markus Armbruster
                   ` (4 subsequent siblings)
  31 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Comments explaining why we include a header tend to go bad.  This
one's almost comical: not only doesn't qemu-options.hx use
MAP_POPULATE anymore (since commit ef36fa1, v2.0.0, 2013), even the
include it applies to got moved away in commit 02d0e09 (v2.7.0).

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 os-posix.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/os-posix.c b/os-posix.c
index 92e9d85215..b9c2343b1e 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -25,7 +25,6 @@
 
 #include "qemu/osdep.h"
 #include <sys/wait.h>
-/*needed for MAP_POPULATE before including qemu-options.h */
 #include <pwd.h>
 #include <grp.h>
 #include <libgen.h>
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 28/32] vl: QAPIfy command line option definition
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (26 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 29/32] qapi/options: QAPIfy --echr argument type Markus Armbruster
                   ` (3 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Move options definition from qemu-options.hx to the QAPI schema.

Schema deficiencies:

* TODO rework doc strings into QAPIDoc format
* TODO generate (parts of) 'help' from 'data'?
* FIXME many 'str' option arguments (marked FIXME/TODO) need to be QAPIfied,
  anything that can't be QAPIfied needs to be replaced & deprecated
* FIXME conditionals (marked #if in qapi/options.json)
* TODO move the non-miscellaneous options next to their subsystem's
* schema definitions

qemu-doc breakage:

* FIXME need to include options part of
  docs/interop/qemu-qmp-qapi.texi into qemu-doc
* FIXME several references in qemu-doc

vl.c TODOs:

* Drop conditionals hackery once we have schema conditionals
* Read and write .json config files
* How can we port -set from QemuOpts to QAPI?

The next few commits QAPIfy a few easy 'str' option arguments, to
demonstrate how.  Many more remain, and some of them are going to be
harder.

QAPIfication switches from the QemuOpts parser to keyval_parse(),
which isn't 100% backward compatible.  We need to decide how far to
push reproducing QemuOpts parsing quirks.

QemuOpts also serves as configuration repository.  QAPIfication gets
rid of that.  Code relying on the configuration repository features
will need updates.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 .gitignore             |    2 -
 Makefile               |   18 +-
 include/qemu-common.h  |    2 +-
 os-posix.c             |   26 +-
 os-win32.c             |    3 +-
 qapi-schema.json       |    1 +
 qapi/options.json      | 4574 ++++++++++++++++++++++++++++++++++++++++++++++++
 qemu-doc.texi          |    4 +-
 qemu-options-wrapper.h |   41 -
 qemu-options.h         |   36 -
 qemu-options.hx        | 4256 --------------------------------------------
 scripts/qapi.py        |   15 +-
 vl.c                   |  694 ++++----
 13 files changed, 4961 insertions(+), 4711 deletions(-)
 create mode 100644 qapi/options.json
 delete mode 100644 qemu-options-wrapper.h
 delete mode 100644 qemu-options.h
 delete mode 100644 qemu-options.hx

diff --git a/.gitignore b/.gitignore
index 84a57060ad..8a79affa46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,8 +39,6 @@
 /qemu-doc.txt
 /qemu-img
 /qemu-nbd
-/qemu-options.def
-/qemu-options.texi
 /qemu-img-cmds.texi
 /qemu-img-cmds.h
 /qemu-io
diff --git a/Makefile b/Makefile
index 5e858f7295..fcce2dd5f9 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ endif
 
 include $(SRC_PATH)/rules.mak
 
-GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
+GENERATED_FILES = qemu-version.h config-host.h
 GENERATED_FILES += builtin-qapi-types.h builtin-qapi-types.c
 GENERATED_FILES += builtin-qapi-visit.h builtin-qapi-visit.c
 GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
@@ -314,8 +314,6 @@ qemu-version.h: FORCE
 
 config-host.h: config-host.h-timestamp
 config-host.h-timestamp: config-host.mak
-qemu-options.def: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
-	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -h < $< > $@,"GEN","$@")
 
 SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))
 SOFTMMU_SUBDIR_RULES=$(filter %-softmmu,$(SUBDIR_RULES))
@@ -422,6 +420,7 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
                $(SRC_PATH)/qapi/introspect.json \
                $(SRC_PATH)/qapi/migration.json \
                $(SRC_PATH)/qapi/net.json \
+               $(SRC_PATH)/qapi/options.json \
                $(SRC_PATH)/qapi/rocker.json \
                $(SRC_PATH)/qapi/run-state.json \
                $(SRC_PATH)/qapi/sockets.json \
@@ -529,7 +528,6 @@ module_block.h: $(SRC_PATH)/scripts/modules/module_block.py config-host.mak
 clean:
 # avoid old build problems by removing potentially incorrect old files
 	rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
-	rm -f qemu-options.def
 	rm -f *.msi
 	find . \( -name '*.so' -o -name '*.dll' -o -name '*.mo' -o -name '*.[oda]' \) -type f -exec rm {} +
 	rm -f $(filter-out %.tlb,$(TOOLS)) $(HELPERS-y) qemu-ga TAGS cscope.* *.pod *~ */*~
@@ -544,7 +542,6 @@ clean:
 	rm -rf qga/qapi-generated
 	for d in $(ALL_SUBDIRS); do \
 	if test -d $$d; then $(MAKE) -C $$d $@ || exit 1; fi; \
-	rm -f $$d/qemu-options.def; \
         done
 	rm -f $(SUBDIR_DEVICES_MAK) config-all-devices.mak
 
@@ -556,7 +553,7 @@ qemu-%.tar.bz2:
 	$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
 
 distclean: clean
-	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
+	rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-img-cmds.texi qemu-monitor.texi qemu-monitor-info.texi
 	rm -f config-all-devices.mak config-all-disas.mak config.status
 	rm -f po/*.mo tests/qemu-iotests/common.env
 	rm -f roms/seabios/config.mak roms/vgabios/config.mak
@@ -715,7 +712,7 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
 
 # documentation
 MAKEINFO=makeinfo
-MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D)
+MAKEINFOINCLUDES= -I docs -I $(<D) -I $(@D) -I $(SRC_PATH)
 MAKEINFOFLAGS=--no-split --number-sections $(MAKEINFOINCLUDES)
 TEXI2PODFLAGS=$(MAKEINFOINCLUDES) "-DVERSION=$(VERSION)"
 TEXI2PDFFLAGS=$(if $(V),,--quiet) -I $(SRC_PATH) $(MAKEINFOINCLUDES)
@@ -737,9 +734,6 @@ docs/version.texi: $(SRC_PATH)/VERSION
 %.pdf: %.texi docs/version.texi
 	$(call quiet-command,texi2pdf $(TEXI2PDFFLAGS) $< -o $@,"GEN","$@")
 
-qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
-	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
-
 qemu-monitor.texi: $(SRC_PATH)/hmp-commands.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
 
@@ -757,7 +751,7 @@ docs/interop/qemu-qmp-qapi.texi: $(qapi-modules)
 docs/interop/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@")
 
-qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
+qemu.1: qemu-doc.texi docs/interop/qemu-qmp-ref.texi  qemu-monitor.texi qemu-monitor-info.texi
 qemu.1: qemu-option-trace.texi
 qemu-img.1: qemu-img.texi qemu-option-trace.texi qemu-img-cmds.texi
 fsdev/virtfs-proxy-helper.1: fsdev/virtfs-proxy-helper.texi
@@ -771,7 +765,7 @@ pdf: qemu-doc.pdf docs/interop/qemu-qmp-ref.pdf docs/interop/qemu-ga-ref.pdf
 txt: qemu-doc.txt docs/interop/qemu-qmp-ref.txt docs/interop/qemu-ga-ref.txt
 
 qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
-	qemu-img.texi qemu-nbd.texi qemu-options.texi qemu-option-trace.texi \
+	qemu-img.texi qemu-nbd.texi docs/interop/qemu-qmp-ref.texi  qemu-option-trace.texi \
 	qemu-monitor.texi qemu-img-cmds.texi qemu-ga.texi \
 	qemu-monitor-info.texi docs/qemu-block-drivers.texi
 
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 0456c79df4..871f622d6a 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -139,7 +139,7 @@ char *qemu_find_file(int type, const char *name);
 /* OS specific functions */
 void os_setup_early_signal_handling(void);
 char *os_find_datadir(void);
-void os_parse_cmd_args(int index, const char *optarg);
+void os_parse_cmd_args(const QAPIOption *opt);
 
 #include "qemu/module.h"
 
diff --git a/os-posix.c b/os-posix.c
index b9c2343b1e..4c134c9dc5 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -32,7 +32,6 @@
 /* Needed early for CONFIG_BSD etc. */
 #include "sysemu/sysemu.h"
 #include "net/slirp.h"
-#include "qemu-options.h"
 #include "qemu/error-report.h"
 #include "qemu/log.h"
 #include "qemu/cutils.h"
@@ -131,35 +130,38 @@ void os_set_proc_name(const char *s)
  * Parse OS specific command line options.
  * return 0 if option handled, -1 otherwise
  */
-void os_parse_cmd_args(int index, const char *optarg)
+void os_parse_cmd_args(const QAPIOption *opt)
 {
-    switch (index) {
+    switch (opt->type) {
 #ifdef CONFIG_SLIRP
-    case QEMU_OPTION_smb:
+    case QAPI_OPTION_KIND_SMB:
         error_report("The -smb option is deprecated. "
                      "Please use '-netdev user,smb=...' instead.");
-        if (net_slirp_smb(optarg) < 0)
+        if (net_slirp_smb(opt->u.smb.data) < 0) {
             exit(1);
+        }
         break;
 #endif
-    case QEMU_OPTION_runas:
-        user_pwd = getpwnam(optarg);
+    case QAPI_OPTION_KIND_RUNAS:
+        user_pwd = getpwnam(opt->u.runas.data);
         if (!user_pwd) {
-            fprintf(stderr, "User \"%s\" doesn't exist\n", optarg);
+            fprintf(stderr, "User \"%s\" doesn't exist\n", opt->u.runas.data);
             exit(1);
         }
         break;
-    case QEMU_OPTION_chroot:
-        chroot_dir = optarg;
+    case QAPI_OPTION_KIND_CHROOT:
+        chroot_dir = opt->u.chroot.data;
         break;
-    case QEMU_OPTION_daemonize:
+    case QAPI_OPTION_KIND_DAEMONIZE:
         daemonize = 1;
         break;
 #if defined(CONFIG_LINUX)
-    case QEMU_OPTION_enablefips:
+    case QAPI_OPTION_KIND_ENABLE_FIPS:
         fips_set_state(true);
         break;
 #endif
+    default:
+        ;
     }
 }
 
diff --git a/os-win32.c b/os-win32.c
index 586a7c7d49..7b01cf821f 100644
--- a/os-win32.c
+++ b/os-win32.c
@@ -26,7 +26,6 @@
 #include <windows.h>
 #include <mmsystem.h>
 #include "sysemu/sysemu.h"
-#include "qemu-options.h"
 
 /***********************************************************/
 /* Functions missing in mingw */
@@ -93,7 +92,7 @@ void os_set_line_buffering(void)
  * Parse OS specific command line options.
  * return 0 if option handled, -1 otherwise
  */
-void os_parse_cmd_args(int index, const char *optarg)
+void os_parse_cmd_args(const QEMUOption *opt)
 {
     return;
 }
diff --git a/qapi-schema.json b/qapi-schema.json
index a6ef550fd5..a2a096d172 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -96,6 +96,7 @@
 { 'include': 'qapi/transaction.json' }
 { 'include': 'qapi/trace.json' }
 { 'include': 'qapi/introspect.json' }
+{ 'include': 'qapi/options.json' }
 
 ##
 # = Miscellanea
diff --git a/qapi/options.json b/qapi/options.json
new file mode 100644
index 0000000000..5a8fdc04ad
--- /dev/null
+++ b/qapi/options.json
@@ -0,0 +1,4574 @@
+# -*- Mode: Python -*-
+#
+# Copyright (C) 2017 Red Hat, Inc.
+#
+# Authors:
+#  Markus Armbruster <armbru@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or later.
+# See the COPYING file in the top-level directory.
+
+#
+# TODO rework doc strings into QAPIDoc format
+# TODO generate (parts of) 'help' from 'data'?
+# FIXME many 'str' option arguments (marked FIXME) need to be QAPIfied
+#       anything that can't be QAPIfied needs to be replaced & deprecated
+# FIXME conditionals (marked #if)
+#
+
+##
+# = Miscellaneous command line options
+#
+# TODO move the non-miscellaneous options next to their subsystem's
+# schema definitions
+##
+
+##
+# == Standard options
+##
+
+##
+# @--help:
+# Display help and exit
+##
+{ 'option': '--help', 'short': 'h',
+  'help': '-h or -help     display this help and exit' }
+
+##
+# @--version:
+# Display version information and exit
+##
+{ 'option': '--version',
+  'help': '-version        display version information and exit' }
+
+##
+# @--machine:
+# !texinfo
+# -machine [type=]@var{name}[,prop=@var{value}[,...]]@*
+# Select the emulated machine by @var{name}. Use @code{-machine help} to list
+# available machines.
+#
+# For architectures which aim to support live migration compatibility
+# across releases, each release will introduce a new versioned machine
+# type. For example, the 2.8.0 release introduced machine types
+# ``pc-i440fx-2.8'' and ``pc-q35-2.8'' for the x86_64/i686 architectures.
+#
+# To allow live migration of guests from QEMU version 2.8.0, to QEMU
+# version 2.9.0, the 2.9.0 version must support the ``pc-i440fx-2.8''
+# and ``pc-q35-2.8'' machines too. To allow users live migrating VMs
+# to skip multiple intermediate releases when upgrading, new releases
+# of QEMU will support machine types from many previous versions.
+#
+# Supported machine properties are:
+# @table @option
+# @item accel=@var{accels1}[:@var{accels2}[:...]]
+# This is used to enable an accelerator. Depending on the target architecture,
+# kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
+# more than one accelerator specified, the next one is used if the previous one
+# fails to initialize.
+# @item kernel_irqchip=on|off
+# Controls in-kernel irqchip support for the chosen accelerator when available.
+# @item gfx_passthru=on|off
+# Enables IGD GFX passthrough support for the chosen machine when available.
+# @item vmport=on|off|auto
+# Enables emulation of VMWare IO port, for vmmouse etc. auto says to select the
+# value based on accel. For accel=xen the default is off otherwise the default
+# is on.
+# @item kvm_shadow_mem=size
+# Defines the size of the KVM shadow MMU.
+# @item dump-guest-core=on|off
+# Include guest memory in a core dump. The default is on.
+# @item mem-merge=on|off
+# Enables or disables memory merge support. This feature, when supported by
+# the host, de-duplicates identical memory pages among VMs instances
+# (enabled by default).
+# @item aes-key-wrap=on|off
+# Enables or disables AES key wrapping support on s390-ccw hosts. This feature
+# controls whether AES wrapping keys will be created to allow
+# execution of AES cryptographic functions.  The default is on.
+# @item dea-key-wrap=on|off
+# Enables or disables DEA key wrapping support on s390-ccw hosts. This feature
+# controls whether DEA wrapping keys will be created to allow
+# execution of DEA cryptographic functions.  The default is on.
+# @item nvdimm=on|off
+# Enables or disables NVDIMM support. The default is off.
+# @item s390-squash-mcss=on|off
+# Enables or disables squashing subchannels into the default css.
+# The default is off.
+# @item enforce-config-section=on|off
+# If @option{enforce-config-section} is set to @var{on}, force migration
+# code to send configuration section even if the machine-type sets the
+# @option{migration.send-configuration} property to @var{off}.
+# NOTE: this parameter is deprecated. Please use @option{-global}
+# @option{migration.send-configuration}=@var{on|off} instead.
+# @end table
+# !end texinfo
+##
+{ 'option': '--machine', 'short': 'M',
+  'data': 'str',                # FIXME QAPIfy qemu_machine_opts, machine_parse(), machine_set_property()
+  'help': [
+"-machine [type=]name[,prop[=value][,...]]",
+"                selects emulated machine ('-machine help' for list)",
+"                property accel=accel1[:accel2[:...]] selects accelerator",
+"                supported accelerators are kvm, xen, hax or tcg (default: tcg)",
+"                kernel_irqchip=on|off|split controls accelerated irqchip support (default=off)",
+"                vmport=on|off|auto controls emulation of vmport (default: auto)",
+"                kvm_shadow_mem=size of KVM shadow MMU in bytes",
+"                dump-guest-core=on|off include guest memory in a core dump (default=on)",
+"                mem-merge=on|off controls memory merge support (default: on)",
+"                igd-passthru=on|off controls IGD GFX passthrough support (default=off)",
+"                aes-key-wrap=on|off controls support for AES key wrapping (default=on)",
+"                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)",
+"                suppress-vmdesc=on|off disables self-describing migration (default=off)",
+"                nvdimm=on|off controls NVDIMM support (default=off)",
+"                enforce-config-section=on|off enforce configuration section migration (default=off)",
+"                s390-squash-mcss=on|off controls support for squashing into default css (default=off)"] }
+
+##
+# @--cpu:
+# !texinfo
+# -cpu @var{model}@*
+# Select CPU model (@code{-cpu help} for list and additional feature selection)
+# !end texinfo
+##
+{ 'option': '--cpu',
+  'data': 'str',                # TODO enum
+  'help': "-cpu cpu        select CPU ('-cpu help' for list)" }
+
+##
+# @--accel:
+# !texinfo
+# -accel @var{name}[,prop=@var{value}[,...]]@*
+# This is used to enable an accelerator. Depending on the target architecture,
+# kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
+# more than one accelerator specified, the next one is used if the previous one
+# fails to initialize.
+# @table @option
+# @item thread=single|multi
+# Controls number of TCG threads. When the TCG is multi-threaded there will be one
+# thread per vCPU therefor taking advantage of additional host cores. The default
+# is to enable multi-threading where both the back-end and front-ends support it and
+# no incompatible TCG features have been enabled (e.g. icount/replay).
+# @end table
+# !end texinfo
+##
+{ 'option': '--accel',
+  'data': 'str',                # FIXME enum
+  'help': [
+"-accel [accel=]accelerator[,thread=single|multi]",
+"                select accelerator (kvm, xen, hax or tcg; use 'help' for a list)",
+"                thread=single|multi (enable multi-threaded TCG)"] }
+
+##
+# @--smp:
+# !texinfo
+# -smp [cpus=]@var{n}[,cores=@var{cores}][,threads=@var{threads}][,sockets=@var{sockets}][,maxcpus=@var{maxcpus}]@*
+# Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
+# CPUs are supported. On Sparc32 target, Linux limits the number of usable CPUs
+# to 4.
+# For the PC target, the number of @var{cores} per socket, the number
+# of @var{threads} per cores and the total number of @var{sockets} can be
+# specified. Missing values will be computed. If any on the three values is
+# given, the total number of CPUs @var{n} can be omitted. @var{maxcpus}
+# specifies the maximum number of hotpluggable CPUs.
+# !end texinfo
+##
+{ 'option': '--smp',
+  'data': 'str',                # FIXME QAPIfy qemu_smp_opts
+  'help': [
+"-smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]",
+"                set the number of CPUs to 'n' [default=1]",
+"                maxcpus= maximum number of total cpus, including",
+"                offline CPUs for hotplug, etc",
+"                cores= number of CPU cores on one socket",
+"                threads= number of threads on one CPU core",
+"                sockets= number of discrete sockets in the system"] }
+
+##
+# @--numa:
+# !texinfo
+# -numa node[,mem=@var{size}][,cpus=@var{firstcpu}[-@var{lastcpu}]][,nodeid=@var{node}]@*
+# -numa node[,memdev=@var{id}][,cpus=@var{firstcpu}[-@var{lastcpu}]][,nodeid=@var{node}]@*
+# -numa dist,src=@var{source},dst=@var{destination},val=@var{distance}@*
+# -numa cpu,node-id=@var{node}[,socket-id=@var{x}][,core-id=@var{y}][,thread-id=@var{z}]@*
+# Define a NUMA node and assign RAM and VCPUs to it.
+# Set the NUMA distance from a source node to a destination node.
+#
+# Legacy VCPU assignment uses @samp{cpus} option where
+# @var{firstcpu} and @var{lastcpu} are CPU indexes. Each
+# @samp{cpus} option represent a contiguous range of CPU indexes
+# (or a single VCPU if @var{lastcpu} is omitted). A non-contiguous
+# set of VCPUs can be represented by providing multiple @samp{cpus}
+# options. If @samp{cpus} is omitted on all nodes, VCPUs are automatically
+# split between them.
+#
+# For example, the following option assigns VCPUs 0, 1, 2 and 5 to
+# a NUMA node:
+# @example
+# -numa node,cpus=0-2,cpus=5
+# @end example
+#
+# @samp{cpu} option is a new alternative to @samp{cpus} option
+# which uses @samp{socket-id|core-id|thread-id} properties to assign
+# CPU objects to a @var{node} using topology layout properties of CPU.
+# The set of properties is machine specific, and depends on used
+# machine type/@samp{smp} options. It could be queried with
+# @samp{hotpluggable-cpus} monitor command.
+# @samp{node-id} property specifies @var{node} to which CPU object
+# will be assigned, it's required for @var{node} to be declared
+# with @samp{node} option before it's used with @samp{cpu} option.
+#
+# For example:
+# @example
+# -M pc \
+# -smp 1,sockets=2,maxcpus=2 \
+# -numa node,nodeid=0 -numa node,nodeid=1 \
+# -numa cpu,node-id=0,socket-id=0 -numa cpu,node-id=1,socket-id=1
+# @end example
+#
+# @samp{mem} assigns a given RAM amount to a node. @samp{memdev}
+# assigns RAM from a given memory backend device to a node. If
+# @samp{mem} and @samp{memdev} are omitted in all nodes, RAM is
+# split equally between them.
+#
+# @samp{mem} and @samp{memdev} are mutually exclusive. Furthermore,
+# if one node uses @samp{memdev}, all of them have to use it.
+#
+# @var{source} and @var{destination} are NUMA node IDs.
+# @var{distance} is the NUMA distance from @var{source} to @var{destination}.
+# The distance from a node to itself is always 10. If any pair of nodes is
+# given a distance, then all pairs must be given distances. Although, when
+# distances are only given in one direction for each pair of nodes, then
+# the distances in the opposite directions are assumed to be the same. If,
+# however, an asymmetrical pair of distances is given for even one node
+# pair, then all node pairs must be provided distance values for both
+# directions, even when they are symmetrical. When a node is unreachable
+# from another node, set the pair's distance to 255.
+#
+# Note that the -@option{numa} option doesn't allocate any of the
+# specified resources, it just assigns existing resources to NUMA
+# nodes. This means that one still has to use the @option{-m},
+# @option{-smp} options to allocate RAM and VCPUs respectively.
+# !end texinfo
+##
+{ 'option': '--numa',
+  'data': 'str',                # FIXME QAPIfy qemu_numa_opts: NumaOptions
+  'help': [
+"-numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node]",
+"-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node]",
+"-numa dist,src=source,dst=destination,val=distance"] }
+
+##
+# @--add-fd:
+# !texinfo
+# -add-fd fd=@var{fd},set=@var{set}[,opaque=@var{opaque}]@*
+#
+# Add a file descriptor to an fd set.  Valid options are:
+#
+# @table @option
+# @item fd=@var{fd}
+# This option defines the file descriptor of which a duplicate is added to fd set.
+# The file descriptor cannot be stdin, stdout, or stderr.
+# @item set=@var{set}
+# This option defines the ID of the fd set to add the file descriptor to.
+# @item opaque=@var{opaque}
+# This option defines a free-form string that can be used to describe @var{fd}.
+# @end table
+#
+# You can open an image using pre-opened file descriptors from an fd set:
+# @example
+# qemu-system-i386
+# -add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
+# -add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
+# -drive file=/dev/fdset/2,index=0,media=disk
+# @end example
+# !end texinfo
+##
+{ 'option': '--add-fd',
+  'data': 'str',                # FIXME QAPIfy qemu_add_fd_opts
+  'help': [
+"-add-fd fd=fd,set=set[,opaque=opaque]",
+"                Add 'fd' to fd 'set'"] }
+
+##
+# @--set:
+# !texinfo
+# -set @var{group}.@var{id}.@var{arg}=@var{value}@*
+# Set parameter @var{arg} for item @var{id} of type @var{group}
+# !end texinfo
+##
+{ 'option': '--set',
+  'data': 'str',                # note: ad hoc syntax
+  'help': [
+"-set group.id.arg=value",
+"                set <arg> parameter for item <id> of type <group>",
+"                i.e. -set drive.$id.file=/path/to/image"] }
+
+##
+# @--global:
+# !texinfo
+# -global @var{driver}.@var{prop}=@var{value}@*
+# -global driver=@var{driver},property=@var{property},value=@var{value}@*
+# Set default value of @var{driver}'s property @var{prop} to @var{value}, e.g.:
+#
+# @example
+# qemu-system-i386 -global ide-hd.physical_block_size=4096 disk-image.img
+# @end example
+#
+# In particular, you can use this to set driver properties for devices which are
+# created automatically by the machine model. To create a device which is not
+# created automatically and set properties on it, use -@option{device}.
+#
+# -global @var{driver}.@var{prop}=@var{value} is shorthand for -global
+# driver=@var{driver},property=@var{prop},value=@var{value}.  The
+# longhand syntax works even when @var{driver} contains a dot.
+# !end texinfo
+##
+{ 'option': '--global',
+  'data': 'str',                # note: ad hoc syntax
+  'help': [
+"-global driver.property=value",
+"-global driver=driver,property=property,value=value",
+"                set a global default for a driver property"] }
+
+##
+# @--boot:
+# !texinfo
+# -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off]@*
+# Specify boot order @var{drives} as a string of drive letters. Valid
+# drive letters depend on the target architecture. The x86 PC uses: a, b
+# (floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot
+# from network adapter 1-4), hard disk boot is the default. To apply a
+# particular boot order only on the first startup, specify it via
+# @option{once}. Note that the @option{order} or @option{once} parameter
+# should not be used together with the @option{bootindex} property of
+# devices, since the firmware implementations normally do not support both
+# at the same time.
+#
+# Interactive boot menus/prompts can be enabled via @option{menu=on} as far
+# as firmware/BIOS supports them. The default is non-interactive boot.
+#
+# A splash picture could be passed to bios, enabling user to show it as logo,
+# when option splash=@var{sp_name} is given and menu=on, If firmware/BIOS
+# supports them. Currently Seabios for X86 system support it.
+# limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
+# format(true color). The resolution should be supported by the SVGA mode, so
+# the recommended is 320x240, 640x480, 800x640.
+#
+# A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
+# when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not
+# reboot, qemu passes '-1' to bios by default. Currently Seabios for X86
+# system support it.
+#
+# Do strict boot via @option{strict=on} as far as firmware/BIOS
+# supports it. This only effects when boot priority is changed by
+# bootindex options. The default is non-strict boot.
+#
+# @example
+# # try to boot from network first, then from hard disk
+# qemu-system-i386 -boot order=nc
+# # boot from CD-ROM first, switch back to default order after reboot
+# qemu-system-i386 -boot once=d
+# # boot with a splash picture for 5 seconds.
+# qemu-system-i386 -boot menu=on,splash=/root/boot.bmp,splash-time=5000
+# @end example
+#
+# Note: The legacy format '-boot @var{drives}' is still supported but its
+# use is discouraged as it may be removed from future versions.
+# !end texinfo
+##
+{ 'option': '--boot',
+  'data': 'str',                # FIXME QAPIfy qemu_boot_opts
+  'help': [
+"-boot [order=drives][,once=drives][,menu=on|off]",
+"      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]",
+"                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)",
+"                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on",
+"                'sp_time': the period that splash picture last if menu=on, unit is ms",
+"                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms"] }
+
+##
+# @--mem:
+# !texinfo
+# -m [size=]@var{megs}[,slots=n,maxmem=size]@*
+# Sets guest startup RAM size to @var{megs} megabytes. Default is 128 MiB.
+# Optionally, a suffix of ``M'' or ``G'' can be used to signify a value in
+# megabytes or gigabytes respectively. Optional pair @var{slots}, @var{maxmem}
+# could be used to set amount of hotpluggable memory slots and maximum amount of
+# memory. Note that @var{maxmem} must be aligned to the page size.
+#
+# For example, the following command-line sets the guest startup RAM size to
+# 1GB, creates 3 slots to hotplug additional memory and sets the maximum
+# memory the guest can reach to 4GB:
+#
+# @example
+# qemu-system-x86_64 -m 1G,slots=3,maxmem=4G
+# @end example
+#
+# If @var{slots} and @var{maxmem} are not specified, memory hotplug won't
+# be enabled and the guest startup RAM will never increase.
+# !end texinfo
+##
+{ 'option': '--mem', 'short': 'm',
+  'data': 'str',                # FIXME QAPIfy qemu_mem_opts
+  'help': [
+"-m [size=]megs[,slots=n,maxmem=size]",
+"                configure guest RAM",
+"                size: initial amount of guest memory",
+"                slots: number of hotplug slots (default: none)",
+"                maxmem: maximum amount of guest memory (default: none)",
+"NOTE: Some architectures might enforce a specific granularity"] }
+
+##
+# @--mem-path:
+# !texinfo
+# -mem-path @var{path}@*
+# Allocate guest RAM from a temporarily created file in @var{path}.
+# !end texinfo
+##
+{ 'option': '--mem-path',
+  'data': 'str',
+  'help': "-mem-path FILE  provide backing storage for guest RAM" }
+
+##
+# @--mem-prealloc:
+# !texinfo
+# -mem-prealloc@*
+# Preallocate memory when using -mem-path.
+# !end texinfo
+##
+{ 'option': '--mem-prealloc',
+  'help': "-mem-prealloc   preallocate guest memory (use with -mem-path)" }
+
+##
+# @--keyboard-layout:
+# !texinfo
+# -k @var{language}@*
+# Use keyboard layout @var{language} (for example @code{fr} for
+# French). This option is only needed where it is not easy to get raw PC
+# keycodes (e.g. on Macs, with some X11 servers or with a VNC or curses
+# display). You don't normally need to use it on PC/Linux or PC/Windows
+# hosts.
+#
+# The available layouts are:
+# @example
+# ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
+# da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
+# de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
+# @end example
+#
+# The default is @code{en-us}.
+# !end texinfo
+##
+{ 'option': '--keyboard-layout', 'short': 'k',
+  'data': 'str',                # FIXME enum?
+  'help': "-k language     use keyboard layout (for example 'fr' for French)" }
+
+##
+# @--audio-help:
+# !texinfo
+# -audio-help@*
+# Will show the audio subsystem help: list of drivers, tunable
+# parameters.
+# !end texinfo
+##
+{ 'option': '--audio-help',
+  'help': "-audio-help     print list of audio drivers and their options" }
+
+##
+# @--soundhw:
+# !texinfo
+# -soundhw @var{card1}[,@var{card2},...] or -soundhw all@*
+# Enable audio and selected sound hardware. Use 'help' to print all
+# available sound hardware.
+#
+# @example
+# qemu-system-i386 -soundhw sb16,adlib disk.img
+# qemu-system-i386 -soundhw es1370 disk.img
+# qemu-system-i386 -soundhw ac97 disk.img
+# qemu-system-i386 -soundhw hda disk.img
+# qemu-system-i386 -soundhw all disk.img
+# qemu-system-i386 -soundhw help
+# @end example
+#
+# Note that Linux's i810_audio OSS kernel (for AC97) module might
+# require manually specifying clocking.
+#
+# @example
+# modprobe i810_audio clocking=48000
+# @end example
+# !end texinfo
+##
+{ 'option': '--soundhw',
+  'data': 'str',                # FIXME QAPIfy select_soundhw()
+  'help': [
+"-soundhw c1,... enable audio support",
+"                and only specified sound cards (comma separated list)",
+"                use '-soundhw help' to get the list of supported cards",
+"                use '-soundhw all' to enable all of them"] }
+
+##
+# @--balloon:
+# !texinfo
+# -balloon none@*
+# Disable balloon device.
+# -balloon virtio[,addr=@var{addr}]@*
+# Enable virtio balloon device (default), optionally with PCI address
+# @var{addr}.
+# !end texinfo
+##
+{ 'option': '--balloon',
+  'data': 'str',                # FIXME QAPIfy balloon_parse()
+  'help': [
+"-balloon none   disable balloon device",
+"-balloon virtio[,addr=str]",
+"                enable virtio balloon device (default)"] }
+
+##
+# @--device:
+# !texinfo
+# -device @var{driver}[,@var{prop}[=@var{value}][,...]]@*
+# Add device @var{driver}.  @var{prop}=@var{value} sets driver
+# properties.  Valid properties depend on the driver.  To get help on
+# possible drivers and properties, use @code{-device help} and
+# @code{-device @var{driver},help}.
+#
+# Some drivers are:
+# -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}][,sdrfile=@var{file}][,furareasize=@var{val}][,furdatafile=@var{file}]@*
+#
+# Add an IPMI BMC.  This is a simulation of a hardware management
+# interface processor that normally sits on a system.  It provides
+# a watchdog and the ability to reset and power control the system.
+# You need to connect this to an IPMI interface to make it useful
+#
+# The IPMI slave address to use for the BMC.  The default is 0x20.
+# This address is the BMC's address on the I2C network of management
+# controllers.  If you don't know what this means, it is safe to ignore
+# it.
+#
+# @table @option
+# @item bmc=@var{id}
+# The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
+# @item slave_addr=@var{val}
+# Define slave address to use for the BMC.  The default is 0x20.
+# @item sdrfile=@var{file}
+# file containing raw Sensor Data Records (SDR) data. The default is none.
+# @item fruareasize=@var{val}
+# size of a Field Replaceable Unit (FRU) area.  The default is 1024.
+# @item frudatafile=@var{file}
+# file containing raw Field Replaceable Unit (FRU) inventory data. The default is none.
+# @end table
+#
+# -device ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}]@*
+#
+# Add a connection to an external IPMI BMC simulator.  Instead of
+# locally emulating the BMC like the above item, instead connect
+# to an external entity that provides the IPMI services.
+#
+# A connection is made to an external BMC simulator.  If you do this, it
+# is strongly recommended that you use the "reconnect=" chardev option
+# to reconnect to the simulator if the connection is lost.  Note that if
+# this is not used carefully, it can be a security issue, as the
+# interface has the ability to send resets, NMIs, and power off the VM.
+# It's best if QEMU makes a connection to an external simulator running
+# on a secure port on localhost, so neither the simulator nor QEMU is
+# exposed to any outside network.
+#
+# See the "lanserv/README.vm" file in the OpenIPMI library for more
+# details on the external interface.
+#
+# -device isa-ipmi-kcs,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]@*
+#
+# Add a KCS IPMI interafce on the ISA bus.  This also adds a
+# corresponding ACPI and SMBIOS entries, if appropriate.
+#
+# @table @option
+# @item bmc=@var{id}
+# The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
+# @item ioport=@var{val}
+# Define the I/O address of the interface.  The default is 0xca0 for KCS.
+# @item irq=@var{val}
+# Define the interrupt to use.  The default is 5.  To disable interrupts,
+# set this to 0.
+# @end table
+#
+# -device isa-ipmi-bt,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]@*
+#
+# Like the KCS interface, but defines a BT interface.  The default port is
+# 0xe4 and the default interrupt is 5.
+# !end texinfo
+##
+{ 'option': '--device',
+  'data': 'str',                # FIXME QAPIfy qemu_device_opts: device_add
+  'help': [
+"-device driver[,prop[=value][,...]]",
+"                add device (based on driver)",
+"                prop=value,... sets driver properties",
+"                use '-device help' to print all possible drivers",
+"                use '-device driver,help' to print all possible properties"] }
+
+##
+# @--name:
+# !texinfo
+# -name @var{name}@*
+# Sets the @var{name} of the guest.
+# This name will be displayed in the SDL window caption.
+# The @var{name} will also be used for the VNC server.
+# Also optionally set the top visible process name in Linux.
+# Naming of individual threads can also be enabled on Linux to aid debugging.
+# !end texinfo
+##
+# FIXME document the additional parameters
+{ 'option': '--name',
+  'data': 'str',                # FIXME QAPIfy qemu_name_opts
+  'help': [
+"-name string1[,process=string2][,debug-threads=on|off]",
+"                set the name of the guest",
+"                string1 sets the window title and string2 the process name (on Linux)",
+"                When debug-threads is enabled, individual threads are given a separate name (on Linux)",
+"                NOTE: The thread names are for debugging and not a stable API."] }
+
+##
+# @--uuid:
+# !texinfo
+# -uuid @var{uuid}@*
+# Set system UUID.
+# !end texinfo
+##
+{ 'option': '--uuid',
+  'data': 'str',                # FIXME uuid?
+  'help': [
+"-uuid %08x-%04x-%04x-%04x-%012x",
+"                specify machine UUID"] }
+
+##
+# == Block device options
+##
+
+##
+# @--fda:
+# !texinfo
+# -fda @var{file}@*
+# -fdb @var{file}@*
+# Use @var{file} as floppy disk 0/1 image (FIXME @@pxref@{disk_images@}).
+# !end texinfo
+##
+{ 'option': '--fda',
+  'data': 'str',
+  'help': "-fda/-fdb file  use 'file' as floppy disk 0/1 image" }
+# FIXME
+
+##
+# @--fdb:
+##
+{ 'option': '--fdb',
+  'data': 'str',
+  'help': null }                # FIXME
+
+##
+# @--hda:
+# !texinfo
+# -hda @var{file}@*
+# -hdb @var{file}@*
+# -hdc @var{file}@*
+# -hdd @var{file}@*
+# Use @var{file} as hard disk 0, 1, 2 or 3 image (FIXME @@pxref@{disk_images@}).
+# !end texinfo
+##
+{ 'option': '--hda',
+  'data': 'str',
+  'help': "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image" }
+# FIXME
+
+##
+# @--hdb:
+##
+{ 'option': '--hdb',
+  'data': 'str',
+  'help': null }                # FIXME
+
+##
+# @--hdc:
+##
+{ 'option': '--hdc',
+  'data': 'str',
+  'help': "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image" }
+# FIXME
+
+##
+# @--hdd:
+##
+{ 'option': '--hdd',
+  'data': 'str',
+  'help': null }                # FIXME
+
+##
+# @--cdrom:
+# !texinfo
+# -cdrom @var{file}@*
+# Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
+# @option{-cdrom} at the same time). You can use the host CD-ROM by
+# using @file{/dev/cdrom} as filename (FIXME @@pxref@{host_drives@}).
+# !end texinfo
+##
+{ 'option': '--cdrom',
+  'data': 'str',
+  'help': "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)" }
+
+##
+# @--blockdev:
+# !texinfo
+# -blockdev @var{option}[,@var{option}[,@var{option}[,...]]]@*
+#
+# Define a new block driver node. Some of the options apply to all block drivers,
+# other options are only accepted for a specific block driver. See below for a
+# list of generic options and options for the most common block drivers.
+#
+# Options that expect a reference to another node (e.g. @code{file}) can be
+# given in two ways. Either you specify the node name of an already existing node
+# (file=@var{node-name}), or you define a new node inline, adding options
+# for the referenced node after a dot (file.filename=@var{path},file.aio=native).
+#
+# A block driver node created with @option{-blockdev} can be used for a guest
+# device by specifying its node name for the @code{drive} property in a
+# @option{-device} argument that defines a block device.
+#
+# @table @option
+# @item Valid options for any block driver node:
+#
+# @table @code
+# @item driver
+# Specifies the block driver to use for the given node.
+# @item node-name
+# This defines the name of the block driver node by which it will be referenced
+# later. The name must be unique, i.e. it must not match the name of a different
+# block driver node, or (if you use @option{-drive} as well) the ID of a drive.
+#
+# If no node name is specified, it is automatically generated. The generated node
+# name is not intended to be predictable and changes between QEMU invocations.
+# For the top level, an explicit node name must be specified.
+# @item read-only
+# Open the node read-only. Guest write attempts will fail.
+# @item cache.direct
+# The host page cache can be avoided with @option{cache.direct=on}. This will
+# attempt to do disk IO directly to the guest's memory. QEMU may still perform an
+# internal copy of the data.
+# @item cache.no-flush
+# In case you don't care about data integrity over host failures, you can use
+# @option{cache.no-flush=on}. This option tells QEMU that it never needs to write
+# any data to the disk but can instead keep things in cache. If anything goes
+# wrong, like your host losing power, the disk storage getting disconnected
+# accidentally, etc. your image will most probably be rendered unusable.
+# @item discard=@var{discard}
+# @var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and controls
+# whether @code{discard} (also known as @code{trim} or @code{unmap}) requests are
+# ignored or passed to the filesystem. Some machine types may not support
+# discard requests.
+# @item detect-zeroes=@var{detect-zeroes}
+# @var{detect-zeroes} is "off", "on" or "unmap" and enables the automatic
+# conversion of plain zero writes by the OS to driver specific optimized
+# zero write commands. You may even choose "unmap" if @var{discard} is set
+# to "unmap" to allow a zero write to be converted to an @code{unmap} operation.
+# @end table
+#
+# @item Driver-specific options for @code{file}
+#
+# This is the protocol-level block driver for accessing regular files.
+#
+# @table @code
+# @item filename
+# The path to the image file in the local filesystem
+# @item aio
+# Specifies the AIO backend (threads/native, default: threads)
+# @end table
+# Example:
+# @example
+# -blockdev driver=file,node-name=disk,filename=disk.img
+# @end example
+#
+# @item Driver-specific options for @code{raw}
+#
+# This is the image format block driver for raw images. It is usually
+# stacked on top of a protocol level block driver such as @code{file}.
+#
+# @table @code
+# @item file
+# Reference to or definition of the data source block driver node
+# (e.g. a @code{file} driver node)
+# @end table
+# Example 1:
+# @example
+# -blockdev driver=file,node-name=disk_file,filename=disk.img
+# -blockdev driver=raw,node-name=disk,file=disk_file
+# @end example
+# Example 2:
+# @example
+# -blockdev driver=raw,node-name=disk,file.driver=file,file.filename=disk.img
+# @end example
+#
+# @item Driver-specific options for @code{qcow2}
+#
+# This is the image format block driver for qcow2 images. It is usually
+# stacked on top of a protocol level block driver such as @code{file}.
+#
+# @table @code
+# @item file
+# Reference to or definition of the data source block driver node
+# (e.g. a @code{file} driver node)
+#
+# @item backing
+# Reference to or definition of the backing file block device (default is taken
+# from the image file). It is allowed to pass an empty string here in order to
+# disable the default backing file.
+#
+# @item lazy-refcounts
+# Whether to enable the lazy refcounts feature (on/off; default is taken from the
+# image file)
+#
+# @item cache-size
+# The maximum total size of the L2 table and refcount block caches in bytes
+# (default: 1048576 bytes or 8 clusters, whichever is larger)
+#
+# @item l2-cache-size
+# The maximum size of the L2 table cache in bytes
+# (default: 4/5 of the total cache size)
+#
+# @item refcount-cache-size
+# The maximum size of the refcount block cache in bytes
+# (default: 1/5 of the total cache size)
+#
+# @item cache-clean-interval
+# Clean unused entries in the L2 and refcount caches. The interval is in seconds.
+# The default value is 0 and it disables this feature.
+#
+# @item pass-discard-request
+# Whether discard requests to the qcow2 device should be forwarded to the data
+# source (on/off; default: on if discard=unmap is specified, off otherwise)
+#
+# @item pass-discard-snapshot
+# Whether discard requests for the data source should be issued when a snapshot
+# operation (e.g. deleting a snapshot) frees clusters in the qcow2 file (on/off;
+# default: on)
+#
+# @item pass-discard-other
+# Whether discard requests for the data source should be issued on other
+# occasions where a cluster gets freed (on/off; default: off)
+#
+# @item overlap-check
+# Which overlap checks to perform for writes to the image
+# (none/constant/cached/all; default: cached). For details or finer
+# granularity control refer to the QAPI documentation of @code{blockdev-add}.
+# @end table
+#
+# Example 1:
+# @example
+# -blockdev driver=file,node-name=my_file,filename=/tmp/disk.qcow2
+# -blockdev driver=qcow2,node-name=hda,file=my_file,overlap-check=none,cache-size=16777216
+# @end example
+# Example 2:
+# @example
+# -blockdev driver=qcow2,node-name=disk,file.driver=http,file.filename=http://example.com/image.qcow2
+# @end example
+#
+# @item Driver-specific options for other drivers
+# Please refer to the QAPI documentation of the @code{blockdev-add} QMP command.
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--blockdev',
+  'data': 'str',                # FIXME BlockdevOptions
+  'help': [
+"-blockdev [driver=]driver[,node-name=N][,discard=ignore|unmap]",
+"          [,cache.direct=on|off][,cache.no-flush=on|off]",
+"          [,read-only=on|off][,detect-zeroes=on|off|unmap]",
+"          [,driver specific parameters...]",
+"                configure a block backend"] }
+
+##
+# @--drive:
+# !texinfo
+# -drive @var{option}[,@var{option}[,@var{option}[,...]]]@*
+#
+# Define a new drive. This includes creating a block driver node (the backend) as
+# well as a guest device, and is mostly a shortcut for defining the corresponding
+# @option{-blockdev} and @option{-device} options.
+#
+# @option{-drive} accepts all options that are accepted by @option{-blockdev}. In
+# addition, it knows the following options:
+#
+# @table @option
+# @item file=@var{file}
+# This option defines which disk image (FIXME @@pxref@{disk_images@}) to use with
+# this drive. If the filename contains comma, you must double it
+# (for instance, "file=my,,file" to use file "my,file").
+#
+# Special files such as iSCSI devices can be specified using protocol
+# specific URLs. See the section for "Device URL Syntax" for more information.
+# @item if=@var{interface}
+# This option defines on which type on interface the drive is connected.
+# Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio, none.
+# @item bus=@var{bus},unit=@var{unit}
+# These options define where is connected the drive by defining the bus number and
+# the unit id.
+# @item index=@var{index}
+# This option defines where is connected the drive by using an index in the list
+# of available connectors of a given interface type.
+# @item media=@var{media}
+# This option defines the type of the media: disk or cdrom.
+# @item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
+# These options have the same definition as they have in @option{-hdachs}.
+# These parameters are deprecated, use the corresponding parameters
+# of @code{-device} instead.
+# @item snapshot=@var{snapshot}
+# @var{snapshot} is "on" or "off" and controls snapshot mode for the given drive
+# (see @option{-snapshot}).
+# @item cache=@var{cache}
+# @var{cache} is "none", "writeback", "unsafe", "directsync" or "writethrough"
+# and controls how the host cache is used to access block data. This is a
+# shortcut that sets the @option{cache.direct} and @option{cache.no-flush}
+# options (as in @option{-blockdev}), and additionally @option{cache.writeback},
+# which provides a default for the @option{write-cache} option of block guest
+# devices (as in @option{-device}). The modes correspond to the following
+# settings:
+#
+# @c Our texi2pod.pl script doesn't support @multitable, so fall back to using
+# @c plain ASCII art (well, UTF-8 art really). This looks okay both in the manpage
+# @c and the HTML output.
+# @example
+#              | cache.writeback   cache.direct   cache.no-flush
+# -------------+------------------------------------------------
+# writeback    | on                off            off
+# none         | on                on             off
+# writethrough | off               off            off
+# directsync   | off               on             off
+# unsafe       | on                off            on
+# @end example
+#
+# The default mode is @option{cache=writeback}.
+#
+# @item aio=@var{aio}
+# @var{aio} is "threads", or "native" and selects between pthread based disk I/O and native Linux AIO.
+# @item format=@var{format}
+# Specify which disk @var{format} will be used rather than detecting
+# the format.  Can be used to specify format=raw to avoid interpreting
+# an untrusted format header.
+# @item serial=@var{serial}
+# This option specifies the serial number to assign to the device. This
+# parameter is deprecated, use the corresponding parameter of @code{-device}
+# instead.
+# @item addr=@var{addr}
+# Specify the controller's PCI address (if=virtio only). This parameter is
+# deprecated, use the corresponding parameter of @code{-device} instead.
+# @item werror=@var{action},rerror=@var{action}
+# Specify which @var{action} to take on write and read errors. Valid actions are:
+# "ignore" (ignore the error and try to continue), "stop" (pause QEMU),
+# "report" (report the error to the guest), "enospc" (pause QEMU only if the
+# host disk is full; report the error to the guest otherwise).
+# The default setting is @option{werror=enospc} and @option{rerror=report}.
+# @item copy-on-read=@var{copy-on-read}
+# @var{copy-on-read} is "on" or "off" and enables whether to copy read backing
+# file sectors into the image file.
+# @item bps=@var{b},bps_rd=@var{r},bps_wr=@var{w}
+# Specify bandwidth throttling limits in bytes per second, either for all request
+# types or for reads or writes only.  Small values can lead to timeouts or hangs
+# inside the guest.  A safe minimum for disks is 2 MB/s.
+# @item bps_max=@var{bm},bps_rd_max=@var{rm},bps_wr_max=@var{wm}
+# Specify bursts in bytes per second, either for all request types or for reads
+# or writes only.  Bursts allow the guest I/O to spike above the limit
+# temporarily.
+# @item iops=@var{i},iops_rd=@var{r},iops_wr=@var{w}
+# Specify request rate limits in requests per second, either for all request
+# types or for reads or writes only.
+# @item iops_max=@var{bm},iops_rd_max=@var{rm},iops_wr_max=@var{wm}
+# Specify bursts in requests per second, either for all request types or for reads
+# or writes only.  Bursts allow the guest I/O to spike above the limit
+# temporarily.
+# @item iops_size=@var{is}
+# Let every @var{is} bytes of a request count as a new request for iops
+# throttling purposes.  Use this option to prevent guests from circumventing iops
+# limits by sending fewer but larger requests.
+# @item group=@var{g}
+# Join a throttling quota group with given name @var{g}.  All drives that are
+# members of the same group are accounted for together.  Use this option to
+# prevent guests from circumventing throttling limits by using many small disks
+# instead of a single larger disk.
+# @end table
+#
+# By default, the @option{cache.writeback=on} mode is used. It will report data
+# writes as completed as soon as the data is present in the host page cache.
+# This is safe as long as your guest OS makes sure to correctly flush disk caches
+# where needed. If your guest OS does not handle volatile disk write caches
+# correctly and your host crashes or loses power, then the guest may experience
+# data corruption.
+#
+# For such guests, you should consider using @option{cache.writeback=off}. This
+# means that the host page cache will be used to read and write data, but write
+# notification will be sent to the guest only after QEMU has made sure to flush
+# each write to the disk. Be aware that this has a major impact on performance.
+#
+# When using the @option{-snapshot} option, unsafe caching is always used.
+#
+# Copy-on-read avoids accessing the same backing file sectors repeatedly and is
+# useful when the backing file is over a slow network.  By default copy-on-read
+# is off.
+#
+# Instead of @option{-cdrom} you can use:
+# @example
+# qemu-system-i386 -drive file=file,index=2,media=cdrom
+# @end example
+#
+# Instead of @option{-hda}, @option{-hdb}, @option{-hdc}, @option{-hdd}, you can
+# use:
+# @example
+# qemu-system-i386 -drive file=file,index=0,media=disk
+# qemu-system-i386 -drive file=file,index=1,media=disk
+# qemu-system-i386 -drive file=file,index=2,media=disk
+# qemu-system-i386 -drive file=file,index=3,media=disk
+# @end example
+#
+# You can open an image using pre-opened file descriptors from an fd set:
+# @example
+# qemu-system-i386
+# -add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
+# -add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
+# -drive file=/dev/fdset/2,index=0,media=disk
+# @end example
+#
+# You can connect a CDROM to the slave of ide0:
+# @example
+# qemu-system-i386 -drive file=file,if=ide,index=1,media=cdrom
+# @end example
+#
+# If you don't specify the "file=" argument, you define an empty drive:
+# @example
+# qemu-system-i386 -drive if=ide,index=1,media=cdrom
+# @end example
+#
+# Instead of @option{-fda}, @option{-fdb}, you can use:
+# @example
+# qemu-system-i386 -drive file=file,index=0,if=floppy
+# qemu-system-i386 -drive file=file,index=1,if=floppy
+# @end example
+#
+# By default, @var{interface} is "ide" and @var{index} is automatically
+# incremented:
+# @example
+# qemu-system-i386 -drive file=a -drive file=b"
+# @end example
+# is interpreted like:
+# @example
+# qemu-system-i386 -hda a -hdb b
+# @end example
+# !end texinfo
+##
+{ 'option': '--drive',
+  'data': 'str',                # FIXME
+  'help': [
+"-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]",
+"       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]",
+"       [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]",
+"       [,serial=s][,addr=A][,rerror=ignore|stop|report]",
+"       [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]",
+"       [,readonly=on|off][,copy-on-read=on|off]",
+"       [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]",
+"       [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]",
+"       [[,iops=i]|[[,iops_rd=r][,iops_wr=w]]]",
+"       [[,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]]",
+"       [[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm]]]",
+"       [[,iops_size=is]]",
+"       [[,group=g]]",
+"                use 'file' as a drive image"] }
+
+##
+# @--mtdblock:
+# !texinfo
+# -mtdblock @var{file}@*
+# Use @var{file} as on-board Flash memory image.
+# !end texinfo
+##
+{ 'option': '--mtdblock',
+  'data': 'str',
+  'help': "-mtdblock file  use 'file' as on-board Flash memory image" }
+
+##
+# @--sd:
+# !texinfo
+# -sd @var{file}@*
+# Use @var{file} as SecureDigital card image.
+# !end texinfo
+##
+{ 'option': '--sd',
+  'data': 'str',
+  'help': "-sd file        use 'file' as SecureDigital card image" }
+
+##
+# @--pflash:
+# !texinfo
+# -pflash @var{file}@*
+# Use @var{file} as a parallel flash image.
+# !end texinfo
+##
+{ 'option': '--pflash',
+  'data': 'str',
+  'help': "-pflash file    use 'file' as a parallel flash image" }
+
+##
+# @--snapshot:
+# !texinfo
+
+# -snapshot@*
+# Write to temporary files instead of disk image files. In this case,
+# the raw disk image you use is not written back. You can however force
+# the write back by pressing @key{C-a s} (FIXME @@pxref@{disk_images@}).
+# !end texinfo
+##
+{ 'option': '--snapshot',
+  'help': "-snapshot       write to temporary files instead of disk image files" }
+
+##
+# @--hdachs:
+# !texinfo
+# -hdachs @var{c},@var{h},@var{s},[,@var{t}]@*
+# Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
+# @var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
+# translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
+# all those parameters. This option is deprecated, please use
+# @code{-device ide-hd,cyls=c,heads=h,secs=s,...} instead.
+# !end texinfo
+##
+# TODO deprecate
+{ 'option': '--hdachs',
+  'data': 'str',                # note: ad hoc syntax
+  'help': [
+"-hdachs c,h,s[,t]",
+"                force hard disk 0 physical geometry and the optional BIOS",
+"                translation (t=none or lba) (usually QEMU can guess them)"] }
+
+##
+# @--fsdev:
+# !texinfo
+#
+# -fsdev @var{fsdriver},id=@var{id},path=@var{path},[security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}]@*
+# Define a new file system device. Valid options are:
+# @table @option
+# @item @var{fsdriver}
+# This option specifies the fs driver backend to use.
+# Currently "local", "handle" and "proxy" file system drivers are supported.
+# @item id=@var{id}
+# Specifies identifier for this device
+# @item path=@var{path}
+# Specifies the export path for the file system device. Files under
+# this path will be available to the 9p client on the guest.
+# @item security_model=@var{security_model}
+# Specifies the security model to be used for this export path.
+# Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
+# In "passthrough" security model, files are stored using the same
+# credentials as they are created on the guest. This requires QEMU
+# to run as root. In "mapped-xattr" security model, some of the file
+# attributes like uid, gid, mode bits and link target are stored as
+# file attributes. For "mapped-file" these attributes are stored in the
+# hidden .virtfs_metadata directory. Directories exported by this security model cannot
+# interact with other unix tools. "none" security model is same as
+# passthrough except the sever won't report failures if it fails to
+# set file attributes like ownership. Security model is mandatory
+# only for local fsdriver. Other fsdrivers (like handle, proxy) don't take
+# security model as a parameter.
+# @item writeout=@var{writeout}
+# This is an optional argument. The only supported value is "immediate".
+# This means that host page cache will be used to read and write data but
+# write notification will be sent to the guest only when the data has been
+# reported as written by the storage subsystem.
+# @item readonly
+# Enables exporting 9p share as a readonly mount for guests. By default
+# read-write access is given.
+# @item socket=@var{socket}
+# Enables proxy filesystem driver to use passed socket file for communicating
+# with virtfs-proxy-helper
+# @item sock_fd=@var{sock_fd}
+# Enables proxy filesystem driver to use passed socket descriptor for
+# communicating with virtfs-proxy-helper. Usually a helper like libvirt
+# will create socketpair and pass one of the fds as sock_fd
+# @item fmode=@var{fmode}
+# Specifies the default mode for newly created files on the host. Works only
+# with security models "mapped-xattr" and "mapped-file".
+# @item dmode=@var{dmode}
+# Specifies the default mode for newly created directories on the host. Works
+# only with security models "mapped-xattr" and "mapped-file".
+# @end table
+#
+# -fsdev option is used along with -device driver "virtio-9p-pci".
+# -device virtio-9p-pci,fsdev=@var{id},mount_tag=@var{mount_tag}@*
+# Options for virtio-9p-pci driver are:
+# @table @option
+# @item fsdev=@var{id}
+# Specifies the id value specified along with -fsdev option
+# @item mount_tag=@var{mount_tag}
+# Specifies the tag name to be used by the guest to mount this export point
+# @end table
+# !end texinfo
+##
+{ 'option': '--fsdev',
+  'data': 'str',                # FIXME QAPIfy qemu_fsdev_opts
+  'help': [
+"-fsdev fsdriver,id=id[,path=path,][security_model={mapped-xattr|mapped-file|passthrough|none}]",
+" [,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]",
+" [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]]",
+" [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]]",
+" [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]]",
+" [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]]",
+" [[,throttling.iops-size=is]]"] }
+
+##
+# @--virtfs:
+# !texinfo
+#
+# -virtfs @var{fsdriver}[,path=@var{path}],mount_tag=@var{mount_tag}[,security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}]@*
+#
+# The general form of a Virtual File system pass-through options are:
+# @table @option
+# @item @var{fsdriver}
+# This option specifies the fs driver backend to use.
+# Currently "local", "handle" and "proxy" file system drivers are supported.
+# @item id=@var{id}
+# Specifies identifier for this device
+# @item path=@var{path}
+# Specifies the export path for the file system device. Files under
+# this path will be available to the 9p client on the guest.
+# @item security_model=@var{security_model}
+# Specifies the security model to be used for this export path.
+# Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
+# In "passthrough" security model, files are stored using the same
+# credentials as they are created on the guest. This requires QEMU
+# to run as root. In "mapped-xattr" security model, some of the file
+# attributes like uid, gid, mode bits and link target are stored as
+# file attributes. For "mapped-file" these attributes are stored in the
+# hidden .virtfs_metadata directory. Directories exported by this security model cannot
+# interact with other unix tools. "none" security model is same as
+# passthrough except the sever won't report failures if it fails to
+# set file attributes like ownership. Security model is mandatory only
+# for local fsdriver. Other fsdrivers (like handle, proxy) don't take security
+# model as a parameter.
+# @item writeout=@var{writeout}
+# This is an optional argument. The only supported value is "immediate".
+# This means that host page cache will be used to read and write data but
+# write notification will be sent to the guest only when the data has been
+# reported as written by the storage subsystem.
+# @item readonly
+# Enables exporting 9p share as a readonly mount for guests. By default
+# read-write access is given.
+# @item socket=@var{socket}
+# Enables proxy filesystem driver to use passed socket file for
+# communicating with virtfs-proxy-helper. Usually a helper like libvirt
+# will create socketpair and pass one of the fds as sock_fd
+# @item sock_fd
+# Enables proxy filesystem driver to use passed 'sock_fd' as the socket
+# descriptor for interfacing with virtfs-proxy-helper
+# @item fmode=@var{fmode}
+# Specifies the default mode for newly created files on the host. Works only
+# with security models "mapped-xattr" and "mapped-file".
+# @item dmode=@var{dmode}
+# Specifies the default mode for newly created directories on the host. Works
+# only with security models "mapped-xattr" and "mapped-file".
+# @end table
+# !end texinfo
+##
+{ 'option': '--virtfs',
+  'data': 'str',                # FIXME QAPIfy qemu_virtfs_opts
+  'help': [
+"-virtfs local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]",
+"        [,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]"] }
+
+##
+# @--virtfs_synth:
+# !texinfo
+# -virtfs_synth@*
+# Create synthetic file system image
+# !end texinfo
+##
+{ 'option': '--virtfs_synth',
+  'help': "-virtfs_synth Create synthetic file system image" }
+
+##
+# @--iscsi:
+# Configure iSCSI session parameters.
+##
+{ 'option': '--iscsi',
+  'data': 'str',                # FIXME QAPIfy qemu_iscsi_opts
+  'help': [
+"-iscsi [user=user][,password=password]",
+"       [,header-digest=CRC32C|CR32C-NONE|NONE-CRC32C|NONE",
+"       [,initiator-name=initiator-iqn][,id=target-iqn]",
+"       [,timeout=timeout]",
+"                iSCSI session parameters"] }
+
+##
+# == USB options
+##
+
+##
+# @--usb:
+# !texinfo
+# -usb@*
+# Enable the USB driver (if it is not used by default yet).
+# !end texinfo
+##
+{ 'option': '--usb',
+  'help': "-usb            enable the USB driver (if it is not used by default yet)" }
+
+##
+# @--usbdevice:
+# !texinfo
+#
+# -usbdevice @var{devname}@*
+# Add the USB device @var{devname}. Note that this option is deprecated,
+# please use @code{-device usb-...} instead. FIXME @@xref@{usb_devices@}.
+#
+# @table @option
+#
+# @item mouse
+# Virtual Mouse. This will override the PS/2 mouse emulation when activated.
+#
+# @item tablet
+# Pointer device that uses absolute coordinates (like a touchscreen). This
+# means QEMU is able to report the mouse position without having to grab the
+# mouse. Also overrides the PS/2 mouse emulation when activated.
+#
+# @item disk:[format=@var{format}]:@var{file}
+# Mass storage device based on file. The optional @var{format} argument
+# will be used rather than detecting the format. Can be used to specify
+# @code{format=raw} to avoid interpreting an untrusted format header.
+#
+# @item host:@var{bus}.@var{addr}
+# Pass through the host device identified by @var{bus}.@var{addr} (Linux only).
+#
+# @item host:@var{vendor_id}:@var{product_id}
+# Pass through the host device identified by @var{vendor_id}:@var{product_id}
+# (Linux only).
+#
+# @item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
+# Serial converter to host character device @var{dev}, see @code{-serial} for the
+# available devices.
+#
+# @item braille
+# Braille device.  This will use BrlAPI to display the braille output on a real
+# or fake device.
+#
+# @item net:@var{options}
+# Network adapter that supports CDC ethernet and RNDIS protocols.
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--usbdevice',
+  'data': 'str',                # FIXME QAPIfy usb_parse()
+  'help': "-usbdevice name add the host or guest USB device 'name'" }
+
+##
+# == Display options
+##
+
+##
+# @--display:
+# !texinfo
+# -display @var{type}@*
+# Select type of display to use. This option is a replacement for the
+# old style -sdl/-curses/... options. Valid values for @var{type} are
+# @table @option
+# @item sdl
+# Display video output via SDL (usually in a separate graphics
+# window; see the SDL documentation for other possibilities).
+# @item curses
+# Display video output via curses. For graphics device models which
+# support a text mode, QEMU can display this output using a
+# curses/ncurses interface. Nothing is displayed when the graphics
+# device is in graphical mode or if the graphics device does not support
+# a text mode. Generally only the VGA device models support text mode.
+# @item none
+# Do not display video output. The guest will still see an emulated
+# graphics card, but its output will not be displayed to the QEMU
+# user. This option differs from the -nographic option in that it
+# only affects what is done with video output; -nographic also changes
+# the destination of the serial and parallel port data.
+# @item gtk
+# Display video output in a GTK window. This interface provides drop-down
+# menus and other UI elements to configure and control the VM during
+# runtime.
+# @item vnc
+# Start a VNC server on display <arg>
+# @end table
+# !end texinfo
+##
+{ 'option': '--display',
+  'data': 'str',                # FIXME QAPIfy select_display()
+  'help': [
+"-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]",
+"            [,window_close=on|off][,gl=on|off]",
+"-display gtk[,grab_on_hover=on|off][,gl=on|off]|",
+"-display vnc=<display>[,<optargs>]",
+"-display curses",
+"-display none",
+"                select display type",
+"The default display is equivalent to",
+"        '-display FIXME'"] }
+
+##
+# @--nographic:
+# !texinfo
+# -nographic@*
+# Normally, if QEMU is compiled with graphical window support, it displays
+# output such as guest graphics, guest console, and the QEMU monitor in a
+# window. With this option, you can totally disable graphical output so
+# that QEMU is a simple command line application. The emulated serial port
+# is redirected on the console and muxed with the monitor (unless
+# redirected elsewhere explicitly). Therefore, you can still use QEMU to
+# debug a Linux kernel with a serial console. Use @key{C-a h} for help on
+# switching between the console and monitor.
+# !end texinfo
+##
+# TODO deprecate
+{ 'option': '--nographic',
+  'help': "-nographic      disable graphical output and redirect serial I/Os to console" }
+
+##
+# @--curses:
+# !texinfo
+# -curses@*
+# Normally, if QEMU is compiled with graphical window support, it displays
+# output such as guest graphics, guest console, and the QEMU monitor in a
+# window. With this option, QEMU can display the VGA output when in text
+# mode using a curses/ncurses interface. Nothing is displayed in graphical
+# mode.
+# !end texinfo
+##
+{ 'option': '--curses',
+  'help': "-curses         shorthand for -display curses" }
+
+##
+# @--no-frame:
+# !texinfo
+# -no-frame@*
+# Do not use decorations for SDL windows and start them using the whole
+# available screen space. This makes the using QEMU in a dedicated desktop
+# workspace more convenient.
+# !end texinfo
+##
+{ 'option': '--no-frame',
+  'help': "-no-frame       open SDL window without a frame and window decorations" }
+
+##
+# @--alt-grab:
+# !texinfo
+# -alt-grab@*
+# Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt). Note that this also
+# affects the special keys (for fullscreen, monitor-mode switching, etc).
+# !end texinfo
+##
+{ 'option': '--alt-grab',
+  'help': "-alt-grab       use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)" }
+
+##
+# @--ctrl-grab:
+# !texinfo
+# -ctrl-grab@*
+# Use Right-Ctrl to grab mouse (instead of Ctrl-Alt). Note that this also
+# affects the special keys (for fullscreen, monitor-mode switching, etc).
+# !end texinfo
+##
+{ 'option': '--ctrl-grab',
+  'help': "-ctrl-grab      use Right-Ctrl to grab mouse (instead of Ctrl-Alt)" }
+
+##
+# @--no-quit:
+# !texinfo
+# -no-quit@*
+# Disable SDL window close capability.
+# !end texinfo
+##
+{ 'option': '--no-quit',
+  'help': "-no-quit        disable SDL window close capability" }
+
+##
+# @--sdl:
+# !texinfo
+# -sdl@*
+# Enable SDL.
+# !end texinfo
+##
+{ 'option': '--sdl',
+  'help': "-sdl            shorthand for -display sdl" }
+
+##
+# @--spice:
+# !texinfo
+# -spice @var{option}[,@var{option}[,...]]@*
+# Enable the spice remote desktop protocol. Valid options are
+#
+# @table @option
+#
+# @item port=<nr>
+# Set the TCP port spice is listening on for plaintext channels.
+#
+# @item addr=<addr>
+# Set the IP address spice is listening on.  Default is any address.
+#
+# @item ipv4
+# @itemx ipv6
+# @itemx unix
+# Force using the specified IP version.
+#
+# @item password=<secret>
+# Set the password you need to authenticate.
+#
+# @item sasl
+# Require that the client use SASL to authenticate with the spice.
+# The exact choice of authentication method used is controlled from the
+# system / user's SASL configuration file for the 'qemu' service. This
+# is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
+# unprivileged user, an environment variable SASL_CONF_PATH can be used
+# to make it search alternate locations for the service config.
+# While some SASL auth methods can also provide data encryption (eg GSSAPI),
+# it is recommended that SASL always be combined with the 'tls' and
+# 'x509' settings to enable use of SSL and server certificates. This
+# ensures a data encryption preventing compromise of authentication
+# credentials.
+#
+# @item disable-ticketing
+# Allow client connects without authentication.
+#
+# @item disable-copy-paste
+# Disable copy paste between the client and the guest.
+#
+# @item disable-agent-file-xfer
+# Disable spice-vdagent based file-xfer between the client and the guest.
+#
+# @item tls-port=<nr>
+# Set the TCP port spice is listening on for encrypted channels.
+#
+# @item x509-dir=<dir>
+# Set the x509 file directory. Expects same filenames as -vnc $display,x509=$dir
+#
+# @item x509-key-file=<file>
+# @itemx x509-key-password=<file>
+# @itemx x509-cert-file=<file>
+# @itemx x509-cacert-file=<file>
+# @itemx x509-dh-key-file=<file>
+# The x509 file names can also be configured individually.
+#
+# @item tls-ciphers=<list>
+# Specify which ciphers to use.
+#
+# @item tls-channel=[main|display|cursor|inputs|record|playback]
+# @itemx plaintext-channel=[main|display|cursor|inputs|record|playback]
+# Force specific channel to be used with or without TLS encryption.  The
+# options can be specified multiple times to configure multiple
+# channels.  The special name "default" can be used to set the default
+# mode.  For channels which are not explicitly forced into one mode the
+# spice client is allowed to pick tls/plaintext as he pleases.
+#
+# @item image-compression=[auto_glz|auto_lz|quic|glz|lz|off]
+# Configure image compression (lossless).
+# Default is auto_glz.
+#
+# @item jpeg-wan-compression=[auto|never|always]
+# @itemx zlib-glz-wan-compression=[auto|never|always]
+# Configure wan image compression (lossy for slow links).
+# Default is auto.
+#
+# @item streaming-video=[off|all|filter]
+# Configure video stream detection.  Default is off.
+#
+# @item agent-mouse=[on|off]
+# Enable/disable passing mouse events via vdagent.  Default is on.
+#
+# @item playback-compression=[on|off]
+# Enable/disable audio stream compression (using celt 0.5.1).  Default is on.
+#
+# @item seamless-migration=[on|off]
+# Enable/disable spice seamless migration. Default is off.
+#
+# @item gl=[on|off]
+# Enable/disable OpenGL context. Default is off.
+#
+# @item rendernode=<file>
+# DRM render node for OpenGL rendering. If not specified, it will pick
+# the first available. (Since 2.9)
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--spice',
+  'data': 'str',                # FIXME QAPIfy qemu_spice_opts
+  'help': [
+"-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]",
+"       [,x509-key-file=<file>][,x509-key-password=<file>]",
+"       [,x509-cert-file=<file>][,x509-cacert-file=<file>]",
+"       [,x509-dh-key-file=<file>][,addr=addr][,ipv4|ipv6|unix]",
+"       [,tls-ciphers=<list>]",
+"       [,tls-channel=[main|display|cursor|inputs|record|playback]]",
+"       [,plaintext-channel=[main|display|cursor|inputs|record|playback]]",
+"       [,sasl][,password=<secret>][,disable-ticketing]",
+"       [,image-compression=[auto_glz|auto_lz|quic|glz|lz|off]]",
+"       [,jpeg-wan-compression=[auto|never|always]]",
+"       [,zlib-glz-wan-compression=[auto|never|always]]",
+"       [,streaming-video=[off|all|filter]][,disable-copy-paste]",
+"       [,disable-agent-file-xfer][,agent-mouse=[on|off]]",
+"       [,playback-compression=[on|off]][,seamless-migration=[on|off]]",
+"       [,gl=[on|off]][,rendernode=<file>]",
+"   enable spice",
+"   at least one of {port, tls-port} is mandatory"] }
+
+##
+# @--portrait:
+# !texinfo
+# -portrait@*
+# Rotate graphical output 90 deg left (only PXA LCD).
+# !end texinfo
+##
+{ 'option': '--portrait',
+  'help': "-portrait       rotate graphical output 90 deg left (only PXA LCD)" }
+
+##
+# @--rotate:
+# !texinfo
+# -rotate @var{deg}@*
+# Rotate graphical output some deg left (only PXA LCD).
+# !end texinfo
+##
+{ 'option': '--rotate',
+  'data': 'str',                # FIXME int or enum
+  'help': "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)" }
+
+##
+# @--vga:
+# !texinfo
+# -vga @var{type}@*
+# Select type of VGA card to emulate. Valid values for @var{type} are
+# @table @option
+# @item cirrus
+# Cirrus Logic GD5446 Video card. All Windows versions starting from
+# Windows 95 should recognize and use this graphic card. For optimal
+# performances, use 16 bit color depth in the guest and the host OS.
+# (This card was the default before QEMU 2.2)
+# @item std
+# Standard VGA card with Bochs VBE extensions.  If your guest OS
+# supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want
+# to use high resolution modes (>= 1280x1024x16) then you should use
+# this option. (This card is the default since QEMU 2.2)
+# @item vmware
+# VMWare SVGA-II compatible adapter. Use it if you have sufficiently
+# recent XFree86/XOrg server or Windows guest with a driver for this
+# card.
+# @item qxl
+# QXL paravirtual graphic card.  It is VGA compatible (including VESA
+# 2.0 VBE support).  Works best with qxl guest drivers installed though.
+# Recommended choice when using the spice protocol.
+# @item tcx
+# (sun4m only) Sun TCX framebuffer. This is the default framebuffer for
+# sun4m machines and offers both 8-bit and 24-bit colour depths at a
+# fixed resolution of 1024x768.
+# @item cg3
+# (sun4m only) Sun cgthree framebuffer. This is a simple 8-bit framebuffer
+# for sun4m machines available in both 1024x768 (OpenBIOS) and 1152x900 (OBP)
+# resolutions aimed at people wishing to run older Solaris versions.
+# @item virtio
+# Virtio VGA card.
+# @item none
+# Disable VGA card.
+# @end table
+# !end texinfo
+##
+# TODO either document retrace=..., or kill it
+{ 'option': '--vga',
+  'data': 'str',                # FIXME QAPIfy select_vgahw()
+  'help': [
+"-vga [std|cirrus|vmware|qxl|xenfb|tcx|cg3|virtio|none]",
+"                select video card type"] }
+
+##
+# @--full-screen:
+# !texinfo
+# -full-screen@*
+# Start in full screen.
+# !end texinfo
+##
+{ 'option': '--full-screen',
+  'help': "-full-screen    start in full screen" }
+
+##
+# @--graphical-resolution:
+# !texinfo
+# -g @var{width}x@var{height}[x@var{depth}]@*
+# Set the initial graphical resolution and depth (PPC, SPARC only).
+# !end texinfo
+##
+{ 'option': '--graphical-resolution', 'short': 'g',
+  'data': 'str',                # FIXME QAPIfy case QAPI_OPTION_KIND_GRAPHICAL_RESOLUTION
+  'help': "-g WxH[xDEPTH]  Set the initial graphical resolution and depth" }
+
+##
+# @--vnc:
+# !texinfo
+# -vnc @var{display}[,@var{option}[,@var{option}[,...]]]@*
+# Normally, if QEMU is compiled with graphical window support, it displays
+# output such as guest graphics, guest console, and the QEMU monitor in a
+# window. With this option, you can have QEMU listen on VNC display
+# @var{display} and redirect the VGA display over the VNC session. It is
+# very useful to enable the usb tablet device when using this option
+# (option @option{-device usb-tablet}). When using the VNC display, you
+# must use the @option{-k} parameter to set the keyboard layout if you are
+# not using en-us. Valid syntax for the @var{display} is
+#
+# @table @option
+#
+# @item to=@var{L}
+#
+# With this option, QEMU will try next available VNC @var{display}s, until the
+# number @var{L}, if the origianlly defined "-vnc @var{display}" is not
+# available, e.g. port 5900+@var{display} is already used by another
+# application. By default, to=0.
+#
+# @item @var{host}:@var{d}
+#
+# TCP connections will only be allowed from @var{host} on display @var{d}.
+# By convention the TCP port is 5900+@var{d}. Optionally, @var{host} can
+# be omitted in which case the server will accept connections from any host.
+#
+# @item unix:@var{path}
+#
+# Connections will be allowed over UNIX domain sockets where @var{path} is the
+# location of a unix socket to listen for connections on.
+#
+# @item none
+#
+# VNC is initialized but not started. The monitor @code{change} command
+# can be used to later start the VNC server.
+#
+# @end table
+#
+# Following the @var{display} value there may be one or more @var{option} flags
+# separated by commas. Valid options are
+#
+# @table @option
+#
+# @item reverse
+#
+# Connect to a listening VNC client via a ``reverse'' connection. The
+# client is specified by the @var{display}. For reverse network
+# connections (@var{host}:@var{d},@code{reverse}), the @var{d} argument
+# is a TCP port number, not a display number.
+#
+# @item websocket
+#
+# Opens an additional TCP listening port dedicated to VNC Websocket connections.
+# If a bare @var{websocket} option is given, the Websocket port is
+# 5700+@var{display}. An alternative port can be specified with the
+# syntax @code{websocket}=@var{port}.
+#
+# If @var{host} is specified connections will only be allowed from this host.
+# It is possible to control the websocket listen address independently, using
+# the syntax @code{websocket}=@var{host}:@var{port}.
+#
+# If no TLS credentials are provided, the websocket connection runs in
+# unencrypted mode. If TLS credentials are provided, the websocket connection
+# requires encrypted client connections.
+#
+# @item password
+#
+# Require that password based authentication is used for client connections.
+#
+# The password must be set separately using the @code{set_password} command in
+# the FIXME @@ref@{pcsys_monitor@}. The syntax to change your password is:
+# @code{set_password <protocol> <password>} where <protocol> could be either
+# "vnc" or "spice".
+#
+# If you would like to change <protocol> password expiration, you should use
+# @code{expire_password <protocol> <expiration-time>} where expiration time could
+# be one of the following options: now, never, +seconds or UNIX time of
+# expiration, e.g. +60 to make password expire in 60 seconds, or 1335196800
+# to make password expire on "Mon Apr 23 12:00:00 EDT 2012" (UNIX time for this
+# date and time).
+#
+# You can also use keywords "now" or "never" for the expiration time to
+# allow <protocol> password to expire immediately or never expire.
+#
+# @item tls-creds=@var{ID}
+#
+# Provides the ID of a set of TLS credentials to use to secure the
+# VNC server. They will apply to both the normal VNC server socket
+# and the websocket socket (if enabled). Setting TLS credentials
+# will cause the VNC server socket to enable the VeNCrypt auth
+# mechanism.  The credentials should have been previously created
+# using the @option{-object tls-creds} argument.
+#
+# The @option{tls-creds} parameter obsoletes the @option{tls},
+# @option{x509}, and @option{x509verify} options, and as such
+# it is not permitted to set both new and old type options at
+# the same time.
+#
+# @item tls
+#
+# Require that client use TLS when communicating with the VNC server. This
+# uses anonymous TLS credentials so is susceptible to a man-in-the-middle
+# attack. It is recommended that this option be combined with either the
+# @option{x509} or @option{x509verify} options.
+#
+# This option is now deprecated in favor of using the @option{tls-creds}
+# argument.
+#
+# @item x509=@var{/path/to/certificate/dir}
+#
+# Valid if @option{tls} is specified. Require that x509 credentials are used
+# for negotiating the TLS session. The server will send its x509 certificate
+# to the client. It is recommended that a password be set on the VNC server
+# to provide authentication of the client when this is used. The path following
+# this option specifies where the x509 certificates are to be loaded from.
+# See the FIXME @@ref@{vnc_security@} section for details on generating certificates.
+#
+# This option is now deprecated in favour of using the @option{tls-creds}
+# argument.
+#
+# @item x509verify=@var{/path/to/certificate/dir}
+#
+# Valid if @option{tls} is specified. Require that x509 credentials are used
+# for negotiating the TLS session. The server will send its x509 certificate
+# to the client, and request that the client send its own x509 certificate.
+# The server will validate the client's certificate against the CA certificate,
+# and reject clients when validation fails. If the certificate authority is
+# trusted, this is a sufficient authentication mechanism. You may still wish
+# to set a password on the VNC server as a second authentication layer. The
+# path following this option specifies where the x509 certificates are to
+# be loaded from. See the FIXME @@ref@{vnc_security@} section for details on generating
+# certificates.
+#
+# This option is now deprecated in favour of using the @option{tls-creds}
+# argument.
+#
+# @item sasl
+#
+# Require that the client use SASL to authenticate with the VNC server.
+# The exact choice of authentication method used is controlled from the
+# system / user's SASL configuration file for the 'qemu' service. This
+# is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
+# unprivileged user, an environment variable SASL_CONF_PATH can be used
+# to make it search alternate locations for the service config.
+# While some SASL auth methods can also provide data encryption (eg GSSAPI),
+# it is recommended that SASL always be combined with the 'tls' and
+# 'x509' settings to enable use of SSL and server certificates. This
+# ensures a data encryption preventing compromise of authentication
+# credentials. See the FIXME @@ref@{vnc_security@} section for details on using
+# SASL authentication.
+#
+# @item acl
+#
+# Turn on access control lists for checking of the x509 client certificate
+# and SASL party. For x509 certs, the ACL check is made against the
+# certificate's distinguished name. This is something that looks like
+# @code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
+# made against the username, which depending on the SASL plugin, may
+# include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
+# When the @option{acl} flag is set, the initial access list will be
+# empty, with a @code{deny} policy. Thus no one will be allowed to
+# use the VNC server until the ACLs have been loaded. This can be
+# achieved using the @code{acl} monitor command.
+#
+# @item lossy
+#
+# Enable lossy compression methods (gradient, JPEG, ...). If this
+# option is set, VNC client may receive lossy framebuffer updates
+# depending on its encoding settings. Enabling this option can save
+# a lot of bandwidth at the expense of quality.
+#
+# @item non-adaptive
+#
+# Disable adaptive encodings. Adaptive encodings are enabled by default.
+# An adaptive encoding will try to detect frequently updated screen regions,
+# and send updates in these regions using a lossy encoding (like JPEG).
+# This can be really helpful to save bandwidth when playing videos. Disabling
+# adaptive encodings restores the original static behavior of encodings
+# like Tight.
+#
+# @item share=[allow-exclusive|force-shared|ignore]
+#
+# Set display sharing policy.  'allow-exclusive' allows clients to ask
+# for exclusive access.  As suggested by the rfb spec this is
+# implemented by dropping other connections.  Connecting multiple
+# clients in parallel requires all clients asking for a shared session
+# (vncviewer: -shared switch).  This is the default.  'force-shared'
+# disables exclusive client access.  Useful for shared desktop sessions,
+# where you don't want someone forgetting specify -shared disconnect
+# everybody else.  'ignore' completely ignores the shared flag and
+# allows everybody connect unconditionally.  Doesn't conform to the rfb
+# spec but is traditional QEMU behavior.
+#
+# @item key-delay-ms
+#
+# Set keyboard delay, for key down and key up events, in milliseconds.
+# Default is 10.  Keyboards are low-bandwidth devices, so this slowdown
+# can help the device and guest to keep up and not lose events in case
+# events are arriving in bulk.  Possible causes for the latter are flaky
+# network connections, or scripts for automated testing.
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--vnc',
+  'data': 'str',                # FIXME QAPIfy qemu_vnc_opts, vnc_parse()
+  'help': "-vnc <display>  shorthand for -display vnc=<display>" }
+
+##
+# == i386 target only
+# TODO make conditional
+##
+
+##
+# @--win2k-hack:
+# !texinfo
+# -win2k-hack@*
+# Use it when installing Windows 2000 to avoid a disk full bug. After
+# Windows 2000 is installed, you no longer need this option (this option
+# slows down the IDE transfers).
+# !end texinfo
+##
+{ 'option': '--win2k-hack',
+  'help': "-win2k-hack     use it when installing Windows 2000 to avoid a disk full bug" }
+
+##
+# @--rtc-td-hack:
+##
+# TODO deprecate
+{ 'option': '--rtc-td-hack',
+  'help': null }
+
+##
+# @--no-fd-bootchk:
+# !texinfo
+# -no-fd-bootchk@*
+# Disable boot signature checking for floppy disks in BIOS. May
+# be needed to boot from old floppy disks.
+# !end texinfo
+##
+{ 'option': '--no-fd-bootchk',
+  'help': "-no-fd-bootchk  disable boot signature checking for floppy disks" }
+
+##
+# @--no-acpi:
+# !texinfo
+# -no-acpi@*
+# Disable ACPI (Advanced Configuration and Power Interface) support. Use
+# it if your guest OS complains about ACPI problems (PC target machine
+# only).
+# !end texinfo
+##
+{ 'option': '--no-acpi',
+  'help': "-no-acpi        disable ACPI" }
+
+##
+# @--no-hpet:
+# !texinfo
+# -no-hpet@*
+# Disable HPET support.
+# !end texinfo
+##
+{ 'option': '--no-hpet',
+  'help': "-no-hpet        disable HPET" }
+
+##
+# @--acpitable:
+# !texinfo
+# -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]@*
+# Add ACPI table with specified header fields and context from specified files.
+# For file=, take whole ACPI table from the specified files, including all
+# ACPI headers (possible overridden by other options).
+# For data=, only data
+# portion of the table is used, all header information is specified in the
+# command line.
+# If a SLIC table is supplied to QEMU, then the SLIC's oem_id and oem_table_id
+# fields will override the same in the RSDT and the FADT (a.k.a. FACP), in order
+# to ensure the field matches required by the Microsoft SLIC spec and the ACPI
+# spec.
+# !end texinfo
+##
+{ 'option': '--acpitable',
+  'data': 'str',                # FIXME QAPIfy qemu_acpi_opts: AcpiTableOptions
+  'help': [
+"-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,{data|file}=file1[:file2]...]",
+"                ACPI table description"] }
+
+##
+# @--smbios:
+# !texinfo
+# -smbios file=@var{binary}@*
+# Load SMBIOS entry from binary file.
+#
+# -smbios type=0[,vendor=@var{str}][,version=@var{str}][,date=@var{str}][,release=@var{%d.%d}][,uefi=on|off]@*
+# Specify SMBIOS type 0 fields
+#
+# -smbios type=1[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,uuid=@var{uuid}][,sku=@var{str}][,family=@var{str}]@*
+# Specify SMBIOS type 1 fields
+#
+# -smbios type=2[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,location=@var{str}][,family=@var{str}]@*
+# Specify SMBIOS type 2 fields
+#
+# -smbios type=3[,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,sku=@var{str}]@*
+# Specify SMBIOS type 3 fields
+#
+# -smbios type=4[,sock_pfx=@var{str}][,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}]@*
+# Specify SMBIOS type 4 fields
+#
+# -smbios type=17[,loc_pfx=@var{str}][,bank=@var{str}][,manufacturer=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}][,speed=@var{%d}]@*
+# Specify SMBIOS type 17 fields
+# !end texinfo
+##
+{ 'option': '--smbios',
+  'data': 'str',                # FIXME QAPIfy qemu_smbios_opts
+  'help': [
+"-smbios file=binary",
+"                load SMBIOS entry from binary file",
+"-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]",
+"              [,uefi=on|off]",
+"                specify SMBIOS type 0 fields",
+"-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]",
+"              [,uuid=uuid][,sku=str][,family=str]",
+"                specify SMBIOS type 1 fields",
+"-smbios type=2[,manufacturer=str][,product=str][,version=str][,serial=str]",
+"              [,asset=str][,location=str]",
+"                specify SMBIOS type 2 fields",
+"-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str]",
+"              [,sku=str]",
+"                specify SMBIOS type 3 fields",
+"-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]",
+"              [,asset=str][,part=str]",
+"                specify SMBIOS type 4 fields",
+"-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]",
+"               [,asset=str][,part=str][,speed=%d]",
+"                specify SMBIOS type 17 fields"] }
+
+##
+# == Network options
+##
+
+##
+# @--tftp:
+##
+# TODO deprecate
+{ 'option': '--tftp',
+  'data': 'str',
+  'help': null }
+
+##
+# @--bootp:
+##
+# TODO deprecate
+{ 'option': '--bootp',
+  'data': 'str',
+  'help': null }
+
+##
+# @--redir:
+##
+# TODO deprecate
+{ 'option': '--redir',
+  'data': 'str',                # FIXME QAPIfy slirp_hostfwd()
+  'help': null }
+
+##
+# @--smb:
+##
+# TODO deprecate
+{ 'option': '--smb',
+  'data': 'str',
+  'help': null }
+
+##
+# @--netdev:
+##
+{ 'option': '--netdev',
+  'data': 'str',                # FIXME QAPIfy qemu_netdev_opts
+  'help': [
+#ifdef CONFIG_SLIRP
+"-netdev user,id=str[,ipv4[=on|off]][,net=addr[/mask]][,host=addr]",
+"         [,ipv6[=on|off]][,ipv6-net=addr[/int]][,ipv6-host=addr]",
+"         [,restrict=on|off][,hostname=host][,dhcpstart=addr]",
+"         [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,tftp=dir]",
+"         [,bootfile=f][,hostfwd=rule][,guestfwd=rule]",
+#ifndef _WIN32
+#"         [,smb=dir[,smbserver=addr]]",
+#endif
+"                configure a user mode network backend with ID 'str',",
+"                its DHCP server and optional services",
+#endif
+#ifdef _WIN32
+#"-netdev tap,id=str,ifname=name",
+#"                configure a host TAP network backend with ID 'str'",
+#else
+"-netdev tap,id=str[,fd=h][,fds=x:y:...:z][,ifname=name][,script=file][,downscript=dfile]",
+"         [,br=bridge][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off]",
+"         [,vhostfd=h][,vhostfds=x:y:...:z][,vhostforce=on|off][,queues=n]",
+"         [,poll-us=n]",
+"                configure a host TAP network backend with ID 'str'",
+"                connected to a bridge (default=FIXME)",
+"                use network scripts 'file' (default=FIXME)",
+"                to configure it and 'dfile' (default=FIXME)",
+"                to deconfigure it",
+"                use '[down]script=no' to disable script execution",
+"                use network helper 'helper' (default=FIXME) to",
+"                configure it",
+"                use 'fd=h' to connect to an already opened TAP interface",
+"                use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces",
+"                use 'sndbuf=nbytes' to limit the size of the send buffer (the",
+"                default is disabled 'sndbuf=0' to enable flow control set 'sndbuf=1048576')",
+"                use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag",
+"                use vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition",
+"                use vhost=on to enable experimental in kernel accelerator",
+"                    (only has effect for virtio guests which use MSIX)",
+"                use vhostforce=on to force vhost on for non-MSIX virtio guests",
+"                use 'vhostfd=h' to connect to an already opened vhost net device",
+"                use 'vhostfds=x:y:...:z to connect to multiple already opened vhost net devices",
+"                use 'queues=n' to specify the number of queues to be created for multiqueue TAP",
+"                use 'poll-us=n' to speciy the maximum number of microseconds that could be",
+"                spent on busy polling for vhost net",
+"-netdev bridge,id=str[,br=bridge][,helper=helper]",
+"                configure a host TAP network backend with ID 'str' that is",
+"                connected to a bridge (default=FIXME)",
+"                using the program 'helper (default=FIXME)",
+#endif
+#ifdef __linux__
+"-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]",
+"         [,rxsession=rxsession],txsession=txsession[,ipv6=on/off][,udp=on/off]",
+"         [,cookie64=on/off][,counter][,pincounter][,txcookie=txcookie]",
+"         [,rxcookie=rxcookie][,offset=offset]",
+"                configure a network backend with ID 'str' connected to",
+"                an Ethernet over L2TPv3 pseudowire.",
+"                Linux kernel 3.3+ as well as most routers can talk",
+"                L2TPv3. This transport allows connecting a VM to a VM,",
+"                VM to a router and even VM to Host. It is a nearly-universal",
+"                standard (RFC3391). Note - this implementation uses static",
+"                pre-configured tunnels (same as the Linux kernel).",
+"                use 'src=' to specify source address",
+"                use 'dst=' to specify destination address",
+"                use 'udp=on' to specify udp encapsulation",
+"                use 'srcport=' to specify source udp port",
+"                use 'dstport=' to specify destination udp port",
+"                use 'ipv6=on' to force v6",
+"                L2TPv3 uses cookies to prevent misconfiguration as",
+"                well as a weak security measure",
+"                use 'rxcookie=0x012345678' to specify a rxcookie",
+"                use 'txcookie=0x012345678' to specify a txcookie",
+"                use 'cookie64=on' to set cookie size to 64 bit, otherwise 32",
+"                use 'counter=off' to force a 'cut-down' L2TPv3 with no counter",
+"                use 'pincounter=on' to work around broken counter handling in peer",
+"                use 'offset=X' to add an extra offset between header and data",
+#endif
+"-netdev socket,id=str[,fd=h][,listen=[host]:port][,connect=host:port]",
+"                configure a network backend to connect to another network",
+"                using a socket connection",
+"-netdev socket,id=str[,fd=h][,mcast=maddr:port[,localaddr=addr]]",
+"                configure a network backend to connect to a multicast maddr and port",
+"                use 'localaddr=addr' to specify the host address to send packets from",
+"-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]",
+"                configure a network backend to connect to another network",
+"                using an UDP tunnel",
+#ifdef CONFIG_VDE
+"-netdev vde,id=str[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]",
+"                configure a network backend to connect to port 'n' of a vde switch",
+"                running on host and listening for incoming connections on 'socketpath'.",
+"                Use group 'groupname' and mode 'octalmode' to change default",
+"                ownership and permissions for communication port.",
+#endif
+#ifdef CONFIG_NETMAP
+"-netdev netmap,id=str,ifname=name[,devname=nmname]",
+"                attach to the existing netmap-enabled network interface 'name', or to a",
+"                VALE port (created on the fly) called 'name' ('nmname' is name of the ",
+"                netmap device, defaults to '/dev/netmap')",
+#endif
+"-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]",
+"                configure a vhost-user network, backed by a chardev 'dev'",
+"-netdev hubport,id=str,hubid=n",
+"                configure a hub port on QEMU VLAN 'n'"] }
+
+##
+# @--net:
+# !texinfo
+# -net nic[,vlan=@var{n}][,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}]@*
+# Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
+# = 0 is the default). The NIC is an e1000 by default on the PC
+# target. Optionally, the MAC address can be changed to @var{mac}, the
+# device address set to @var{addr} (PCI cards only),
+# and a @var{name} can be assigned for use in monitor commands.
+# Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vectors
+# that the card should have; this option currently only affects virtio cards; set
+# @var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single
+# NIC is created.  QEMU can emulate several different models of network card.
+# Valid values for @var{type} are
+# @code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er},
+# @code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
+# @code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
+# Not all devices are supported on all targets.  Use @code{-net nic,model=help}
+# for a list of available devices for your target.
+#
+# -netdev user,id=@var{id}[,@var{option}][,@var{option}][,...]@*
+# -net user[,@var{option}][,@var{option}][,...]@*
+# Use the user mode network stack which requires no administrator
+# privilege to run. Valid options are:
+#
+# @table @option
+# @item vlan=@var{n}
+# Connect user mode stack to VLAN @var{n} (@var{n} = 0 is the default).
+#
+# @item id=@var{id}
+# @itemx name=@var{name}
+# Assign symbolic name for use in monitor commands.
+#
+# @option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must
+# be enabled.  If neither is specified both protocols are enabled.
+#
+# @item net=@var{addr}[/@var{mask}]
+# Set IP network address the guest will see. Optionally specify the netmask,
+# either in the form a.b.c.d or as number of valid top-most bits. Default is
+# 10.0.2.0/24.
+#
+# @item host=@var{addr}
+# Specify the guest-visible address of the host. Default is the 2nd IP in the
+# guest network, i.e. x.x.x.2.
+#
+# @item ipv6-net=@var{addr}[/@var{int}]
+# Set IPv6 network address the guest will see (default is fec0::/64). The
+# network prefix is given in the usual hexadecimal IPv6 address
+# notation. The prefix size is optional, and is given as the number of
+# valid top-most bits (default is 64).
+#
+# @item ipv6-host=@var{addr}
+# Specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 in
+# the guest network, i.e. xxxx::2.
+#
+# @item restrict=on|off
+# If this option is enabled, the guest will be isolated, i.e. it will not be
+# able to contact the host and no guest IP packets will be routed over the host
+# to the outside. This option does not affect any explicitly set forwarding rules.
+#
+# @item hostname=@var{name}
+# Specifies the client hostname reported by the built-in DHCP server.
+#
+# @item dhcpstart=@var{addr}
+# Specify the first of the 16 IPs the built-in DHCP server can assign. Default
+# is the 15th to 31st IP in the guest network, i.e. x.x.x.15 to x.x.x.31.
+#
+# @item dns=@var{addr}
+# Specify the guest-visible address of the virtual nameserver. The address must
+# be different from the host address. Default is the 3rd IP in the guest network,
+# i.e. x.x.x.3.
+#
+# @item ipv6-dns=@var{addr}
+# Specify the guest-visible address of the IPv6 virtual nameserver. The address
+# must be different from the host address. Default is the 3rd IP in the guest
+# network, i.e. xxxx::3.
+#
+# @item dnssearch=@var{domain}
+# Provides an entry for the domain-search list sent by the built-in
+# DHCP server. More than one domain suffix can be transmitted by specifying
+# this option multiple times. If supported, this will cause the guest to
+# automatically try to append the given domain suffix(es) in case a domain name
+# can not be resolved.
+#
+# Example:
+# @example
+# qemu -net user,dnssearch=mgmt.example.org,dnssearch=example.org [...]
+# @end example
+#
+# @item tftp=@var{dir}
+# When using the user mode network stack, activate a built-in TFTP
+# server. The files in @var{dir} will be exposed as the root of a TFTP server.
+# The TFTP client on the guest must be configured in binary mode (use the command
+# @code{bin} of the Unix TFTP client).
+#
+# @item bootfile=@var{file}
+# When using the user mode network stack, broadcast @var{file} as the BOOTP
+# filename. In conjunction with @option{tftp}, this can be used to network boot
+# a guest from a local directory.
+#
+# Example (using pxelinux):
+# @example
+# qemu-system-i386 -hda linux.img -boot n -net user,tftp=/path/to/tftp/files,bootfile=/pxelinux.0
+# @end example
+#
+# @item smb=@var{dir}[,smbserver=@var{addr}]
+# When using the user mode network stack, activate a built-in SMB
+# server so that Windows OSes can access to the host files in @file{@var{dir}}
+# transparently. The IP address of the SMB server can be set to @var{addr}. By
+# default the 4th IP in the guest network is used, i.e. x.x.x.4.
+#
+# In the guest Windows OS, the line:
+# @example
+# 10.0.2.4 smbserver
+# @end example
+# must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
+# or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
+#
+# Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}.
+#
+# Note that a SAMBA server must be installed on the host OS.
+# QEMU was tested successfully with smbd versions from Red Hat 9,
+# Fedora Core 3 and OpenSUSE 11.x.
+#
+# @item hostfwd=[tcp|udp]:[@var{hostaddr}]:@var{hostport}-[@var{guestaddr}]:@var{guestport}
+# Redirect incoming TCP or UDP connections to the host port @var{hostport} to
+# the guest IP address @var{guestaddr} on guest port @var{guestport}. If
+# @var{guestaddr} is not specified, its value is x.x.x.15 (default first address
+# given by the built-in DHCP server). By specifying @var{hostaddr}, the rule can
+# be bound to a specific host interface. If no connection type is set, TCP is
+# used. This option can be given multiple times.
+#
+# For example, to redirect host X11 connection from screen 1 to guest
+# screen 0, use the following:
+#
+# @example
+# # on the host
+# qemu-system-i386 -net user,hostfwd=tcp:127.0.0.1:6001-:6000 [...]
+# # this host xterm should open in the guest X11 server
+# xterm -display :1
+# @end example
+#
+# To redirect telnet connections from host port 5555 to telnet port on
+# the guest, use the following:
+#
+# @example
+# # on the host
+# qemu-system-i386 -net user,hostfwd=tcp::5555-:23 [...]
+# telnet localhost 5555
+# @end example
+#
+# Then when you use on the host @code{telnet localhost 5555}, you
+# connect to the guest telnet server.
+#
+# @item guestfwd=[tcp]:@var{server}:@var{port}-@var{dev}
+# @itemx guestfwd=[tcp]:@var{server}:@var{port}-@var{cmd:command}
+# Forward guest TCP connections to the IP address @var{server} on port @var{port}
+# to the character device @var{dev} or to a program executed by @var{cmd:command}
+# which gets spawned for each connection. This option can be given multiple times.
+#
+# You can either use a chardev directly and have that one used throughout QEMU's
+# lifetime, like in the following example:
+#
+# @example
+# # open 10.10.1.1:4321 on bootup, connect 10.0.2.100:1234 to it whenever
+# # the guest accesses it
+# qemu -net user,guestfwd=tcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...]
+# @end example
+#
+# Or you can execute a command on every TCP connection established by the guest,
+# so that QEMU behaves similar to an inetd process for that virtual server:
+#
+# @example
+# # call "netcat 10.10.1.1 4321" on every TCP connection to 10.0.2.100:1234
+# # and connect the TCP stream to its stdin/stdout
+# qemu -net 'user,guestfwd=tcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321'
+# @end example
+#
+# @end table
+#
+# Note: Legacy stand-alone options -tftp, -bootp, -smb and -redir are still
+# processed and applied to -net user. Mixing them with the new configuration
+# syntax gives undefined results. Their use for new applications is discouraged
+# as they will be removed from future versions.
+#
+# -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}]@*
+# -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}]@*
+# Connect the host TAP network interface @var{name} to VLAN @var{n}.
+#
+# Use the network script @var{file} to configure it and the network script
+# @var{dfile} to deconfigure it. If @var{name} is not provided, the OS
+# automatically provides one. The default network configure script is
+# @file{/etc/qemu-ifup} and the default network deconfigure script is
+# @file{/etc/qemu-ifdown}. Use @option{script=no} or @option{downscript=no}
+# to disable script execution.
+#
+# If running QEMU as an unprivileged user, use the network helper
+# @var{helper} to configure the TAP interface and attach it to the bridge.
+# The default network helper executable is @file{/path/to/qemu-bridge-helper}
+# and the default bridge device is @file{br0}.
+#
+# @option{fd}=@var{h} can be used to specify the handle of an already
+# opened host TAP interface.
+#
+# Examples:
+#
+# @example
+# #launch a QEMU instance with the default network script
+# qemu-system-i386 linux.img -net nic -net tap
+# @end example
+#
+# @example
+# #launch a QEMU instance with two NICs, each one connected
+# #to a TAP device
+# qemu-system-i386 linux.img \
+#                  -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
+#                  -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
+# @end example
+#
+# @example
+# #launch a QEMU instance with the default network helper to
+# #connect a TAP device to bridge br0
+# qemu-system-i386 linux.img \
+#                  -net nic -net tap,"helper=/path/to/qemu-bridge-helper"
+# @end example
+#
+# -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}]@*
+# -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}]@*
+# Connect a host TAP network interface to a host bridge device.
+#
+# Use the network helper @var{helper} to configure the TAP interface and
+# attach it to the bridge. The default network helper executable is
+# @file{/path/to/qemu-bridge-helper} and the default bridge
+# device is @file{br0}.
+#
+# Examples:
+#
+# @example
+# #launch a QEMU instance with the default network helper to
+# #connect a TAP device to bridge br0
+# qemu-system-i386 linux.img -net bridge -net nic,model=virtio
+# @end example
+#
+# @example
+# #launch a QEMU instance with the default network helper to
+# #connect a TAP device to bridge qemubr0
+# qemu-system-i386 linux.img -net bridge,br=qemubr0 -net nic,model=virtio
+# @end example
+#
+# -netdev socket,id=@var{id}[,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]@*
+# -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]@*
+#
+# Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
+# machine using a TCP socket connection. If @option{listen} is
+# specified, QEMU waits for incoming connections on @var{port}
+# (@var{host} is optional). @option{connect} is used to connect to
+# another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
+# specifies an already opened TCP socket.
+#
+# Example:
+# @example
+# # launch a first QEMU instance
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:56 \
+#                  -net socket,listen=:1234
+# # connect the VLAN 0 of this instance to the VLAN 0
+# # of the first instance
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:57 \
+#                  -net socket,connect=127.0.0.1:1234
+# @end example
+#
+# -netdev socket,id=@var{id}[,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]@*
+# -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]@*
+#
+# Create a VLAN @var{n} shared with another QEMU virtual
+# machines using a UDP multicast socket, effectively making a bus for
+# every QEMU with same multicast address @var{maddr} and @var{port}.
+# NOTES:
+# @enumerate
+# @item
+# Several QEMU can be running on different hosts and share same bus (assuming
+# correct multicast setup for these hosts).
+# @item
+# mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
+# @url{http://user-mode-linux.sf.net}.
+# @item
+# Use @option{fd=h} to specify an already opened UDP multicast socket.
+# @end enumerate
+#
+# Example:
+# @example
+# # launch one QEMU instance
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:56 \
+#                  -net socket,mcast=230.0.0.1:1234
+# # launch another QEMU instance on same "bus"
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:57 \
+#                  -net socket,mcast=230.0.0.1:1234
+# # launch yet another QEMU instance on same "bus"
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:58 \
+#                  -net socket,mcast=230.0.0.1:1234
+# @end example
+#
+# Example (User Mode Linux compat.):
+# @example
+# # launch QEMU instance (note mcast address selected
+# # is UML's default)
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:56 \
+#                  -net socket,mcast=239.192.168.1:1102
+# # launch UML
+# /path/to/linux ubd0=/path/to/root_fs eth0=mcast
+# @end example
+#
+# Example (send packets from host's 1.2.3.4):
+# @example
+# qemu-system-i386 linux.img \
+#                  -net nic,macaddr=52:54:00:12:34:56 \
+#                  -net socket,mcast=239.192.168.1:1102,localaddr=1.2.3.4
+# @end example
+#
+# -netdev l2tpv3,id=@var{id},src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]@*
+# -net l2tpv3[,vlan=@var{n}][,name=@var{name}],src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]@*
+# Connect VLAN @var{n} to L2TPv3 pseudowire. L2TPv3 (RFC3391) is a popular
+# protocol to transport Ethernet (and other Layer 2) data frames between
+# two systems. It is present in routers, firewalls and the Linux kernel
+# (from version 3.3 onwards).
+#
+# This transport allows a VM to communicate to another VM, router or firewall directly.
+#
+# @table @option
+# @item src=@var{srcaddr}
+#     source address (mandatory)
+# @item dst=@var{dstaddr}
+#     destination address (mandatory)
+# @item udp
+#     select udp encapsulation (default is ip).
+# @item srcport=@var{srcport}
+#     source udp port.
+# @item dstport=@var{dstport}
+#     destination udp port.
+# @item ipv6
+#     force v6, otherwise defaults to v4.
+# @item rxcookie=@var{rxcookie}
+# @itemx txcookie=@var{txcookie}
+#     Cookies are a weak form of security in the l2tpv3 specification.
+# Their function is mostly to prevent misconfiguration. By default they are 32
+# bit.
+# @item cookie64
+#     Set cookie size to 64 bit instead of the default 32
+# @item counter=off
+#     Force a 'cut-down' L2TPv3 with no counter as in
+# draft-mkonstan-l2tpext-keyed-ipv6-tunnel-00
+# @item pincounter=on
+#     Work around broken counter handling in peer. This may also help on
+# networks which have packet reorder.
+# @item offset=@var{offset}
+#     Add an extra offset between header and data
+# @end table
+#
+# For example, to attach a VM running on host 4.3.2.1 via L2TPv3 to the bridge br-lan
+# on the remote Linux host 1.2.3.4:
+# @example
+# # Setup tunnel on linux host using raw ip as encapsulation
+# # on 1.2.3.4
+# ip l2tp add tunnel remote 4.3.2.1 local 1.2.3.4 tunnel_id 1 peer_tunnel_id 1 \
+#     encap udp udp_sport 16384 udp_dport 16384
+# ip l2tp add session tunnel_id 1 name vmtunnel0 session_id \
+#     0xFFFFFFFF peer_session_id 0xFFFFFFFF
+# ifconfig vmtunnel0 mtu 1500
+# ifconfig vmtunnel0 up
+# brctl addif br-lan vmtunnel0
+#
+#
+# # on 4.3.2.1
+# # launch QEMU instance - if your network has reorder or is very lossy add ,pincounter
+#
+# qemu-system-i386 linux.img -net nic -net l2tpv3,src=4.2.3.1,dst=1.2.3.4,udp,srcport=16384,dstport=16384,rxsession=0xffffffff,txsession=0xffffffff,counter
+#
+#
+# @end example
+#
+# -netdev vde,id=@var{id}[,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]@*
+# -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]@*
+# Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
+# listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
+# and MODE @var{octalmode} to change default ownership and permissions for
+# communication port. This option is only available if QEMU has been compiled
+# with vde support enabled.
+#
+# Example:
+# @example
+# # launch vde switch
+# vde_switch -F -sock /tmp/myswitch
+# # launch QEMU instance
+# qemu-system-i386 linux.img -net nic -net vde,sock=/tmp/myswitch
+# @end example
+#
+# -netdev hubport,id=@var{id},hubid=@var{hubid}@*
+#
+# Create a hub port on QEMU "vlan" @var{hubid}.
+#
+# The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a single
+# netdev.  @code{-net} and @code{-device} with parameter @option{vlan} create the
+# required hub automatically.
+#
+# -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n]@*
+#
+# Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev should
+# be a unix domain socket backed one. The vhost-user uses a specifically defined
+# protocol to pass vhost ioctl replacement messages to an application on the other
+# end of the socket. On non-MSIX guests, the feature can be forced with
+# @var{vhostforce}. Use 'queues=@var{n}' to specify the number of queues to
+# be created for multiqueue vhost-user.
+#
+# Example:
+# @example
+# qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,share=on \
+#      -numa node,memdev=mem \
+#      -chardev socket,id=chr0,path=/path/to/socket \
+#      -netdev type=vhost-user,id=net0,chardev=chr0 \
+#      -device virtio-net-pci,netdev=net0
+# @end example
+#
+# -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]@*
+# Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
+# At most @var{len} bytes (64k by default) per packet are stored. The file format is
+# libpcap, so it can be analyzed with tools such as tcpdump or Wireshark.
+# Note: For devices created with '-netdev', use '-object filter-dump,...' instead.
+#
+# -net none@*
+# Indicate that no network devices should be configured. It is used to
+# override the default configuration (@option{-net nic -net user}) which
+# is activated if no @option{-net} options are provided.
+# !end texinfo
+##
+{ 'option': '--net',
+  'data': 'str',                # FIXME QAPIfy
+  'help': [
+"-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]",
+"                old way to create a new NIC and connect it to VLAN 'n'",
+"                (use the '-device devtype,netdev=str' option if possible instead)",
+"-net dump[,vlan=n][,file=f][,len=n]",
+"                dump traffic on vlan 'n' to file 'f' (max n bytes per packet)",
+"-net none       use it alone to have zero network devices. If no -net option",
+"                is provided, the default is '-net nic -net user'",
+"-net [user|tap|bridge|vde|netmap|socket][,vlan=n][,option][,option][,...]",
+# FIXME conditionals ^^^
+"                old way to initialize a host network interface",
+"                (use the -netdev option if possible instead)" ] }
+
+##
+# == Character device options
+##
+
+##
+# @--chardev:
+# !texinfo
+# The general form of a character device option is:
+# -chardev @var{backend} ,id=@var{id} [,mux=on|off] [,@var{options}]@*
+# Backend is one of:
+# @option{null},
+# @option{socket},
+# @option{udp},
+# @option{msmouse},
+# @option{vc},
+# @option{ringbuf},
+# @option{file},
+# @option{pipe},
+# @option{console},
+# @option{serial},
+# @option{pty},
+# @option{stdio},
+# @option{braille},
+# @option{tty},
+# @option{parallel},
+# @option{parport},
+# @option{spicevmc}.
+# @option{spiceport}.
+# The specific backend will determine the applicable options.
+#
+# Use @code{-chardev help} to print all available chardev backend types.
+#
+# All devices must have an id, which can be any string up to 127 characters long.
+# It is used to uniquely identify this device in other command line directives.
+#
+# A character device may be used in multiplexing mode by multiple front-ends.
+# Specify @option{mux=on} to enable this mode.
+# A multiplexer is a "1:N" device, and here the "1" end is your specified chardev
+# backend, and the "N" end is the various parts of QEMU that can talk to a chardev.
+# If you create a chardev with @option{id=myid} and @option{mux=on}, QEMU will
+# create a multiplexer with your specified ID, and you can then configure multiple
+# front ends to use that chardev ID for their input/output. Up to four different
+# front ends can be connected to a single multiplexed chardev. (Without
+# multiplexing enabled, a chardev can only be used by a single front end.)
+# For instance you could use this to allow a single stdio chardev to be used by
+# two serial ports and the QEMU monitor:
+#
+# @example
+# -chardev stdio,mux=on,id=char0 \
+# -mon chardev=char0,mode=readline \
+# -serial chardev:char0 \
+# -serial chardev:char0
+# @end example
+#
+# You can have more than one multiplexer in a system configuration; for instance
+# you could have a TCP port multiplexed between UART 0 and UART 1, and stdio
+# multiplexed between the QEMU monitor and a parallel port:
+#
+# @example
+# -chardev stdio,mux=on,id=char0 \
+# -mon chardev=char0,mode=readline \
+# -parallel chardev:char0 \
+# -chardev tcp,...,mux=on,id=char1 \
+# -serial chardev:char1 \
+# -serial chardev:char1
+# @end example
+#
+# When you're using a multiplexed character device, some escape sequences are
+# interpreted in the input. FIXME @@xref@{mux_keys, Keys in the character backend
+# multiplexer@}.
+#
+# Note that some other command line options may implicitly create multiplexed
+# character backends; for instance @option{-serial mon:stdio} creates a
+# multiplexed stdio backend connected to the serial port and the QEMU monitor,
+# and @option{-nographic} also multiplexes the console and the monitor to
+# stdio.
+#
+# There is currently no support for multiplexing in the other direction
+# (where a single QEMU front end takes input and output from multiple chardevs).
+#
+# Every backend supports the @option{logfile} option, which supplies the path
+# to a file to record all data transmitted via the backend. The @option{logappend}
+# option controls whether the log file will be truncated or appended to when
+# opened.
+#
+# The available backends are:
+#
+# @table @option
+# @item -chardev null ,id=@var{id}
+# A void device. This device will not emit any data, and will drop any data it
+# receives. The null backend does not take any options.
+#
+# @item -chardev socket ,id=@var{id} [@var{TCP options} or @var{unix options}] [,server] [,nowait] [,telnet] [,reconnect=@var{seconds}] [,tls-creds=@var{id}]
+#
+# Create a two-way stream socket, which can be either a TCP or a unix socket. A
+# unix socket will be created if @option{path} is specified. Behaviour is
+# undefined if TCP options are specified for a unix socket.
+#
+# @option{server} specifies that the socket shall be a listening socket.
+#
+# @option{nowait} specifies that QEMU should not block waiting for a client to
+# connect to a listening socket.
+#
+# @option{telnet} specifies that traffic on the socket should interpret telnet
+# escape sequences.
+#
+# @option{reconnect} sets the timeout for reconnecting on non-server sockets when
+# the remote end goes away.  qemu will delay this many seconds and then attempt
+# to reconnect.  Zero disables reconnecting, and is the default.
+#
+# @option{tls-creds} requests enablement of the TLS protocol for encryption,
+# and specifies the id of the TLS credentials to use for the handshake. The
+# credentials must be previously created with the @option{-object tls-creds}
+# argument.
+#
+# TCP and unix socket options are given below:
+#
+# @table @option
+#
+# @item TCP options: port=@var{port} [,host=@var{host}] [,to=@var{to}] [,ipv4] [,ipv6] [,nodelay]
+#
+# @option{host} for a listening socket specifies the local address to be bound.
+# For a connecting socket species the remote host to connect to. @option{host} is
+# optional for listening sockets. If not specified it defaults to @code{0.0.0.0}.
+#
+# @option{port} for a listening socket specifies the local port to be bound. For a
+# connecting socket specifies the port on the remote host to connect to.
+# @option{port} can be given as either a port number or a service name.
+# @option{port} is required.
+#
+# @option{to} is only relevant to listening sockets. If it is specified, and
+# @option{port} cannot be bound, QEMU will attempt to bind to subsequent ports up
+# to and including @option{to} until it succeeds. @option{to} must be specified
+# as a port number.
+#
+# @option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must be used.
+# If neither is specified the socket may use either protocol.
+#
+# @option{nodelay} disables the Nagle algorithm.
+#
+# @item unix options: path=@var{path}
+#
+# @option{path} specifies the local path of the unix socket. @option{path} is
+# required.
+#
+# @end table
+#
+# @item -chardev udp ,id=@var{id} [,host=@var{host}] ,port=@var{port} [,localaddr=@var{localaddr}] [,localport=@var{localport}] [,ipv4] [,ipv6]
+#
+# Sends all traffic from the guest to a remote host over UDP.
+#
+# @option{host} specifies the remote host to connect to. If not specified it
+# defaults to @code{localhost}.
+#
+# @option{port} specifies the port on the remote host to connect to. @option{port}
+# is required.
+#
+# @option{localaddr} specifies the local address to bind to. If not specified it
+# defaults to @code{0.0.0.0}.
+#
+# @option{localport} specifies the local port to bind to. If not specified any
+# available local port will be used.
+#
+# @option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must be used.
+# If neither is specified the device may use either protocol.
+#
+# @item -chardev msmouse ,id=@var{id}
+#
+# Forward QEMU's emulated msmouse events to the guest. @option{msmouse} does not
+# take any options.
+#
+# @item -chardev vc ,id=@var{id} [[,width=@var{width}] [,height=@var{height}]] [[,cols=@var{cols}] [,rows=@var{rows}]]
+#
+# Connect to a QEMU text console. @option{vc} may optionally be given a specific
+# size.
+#
+# @option{width} and @option{height} specify the width and height respectively of
+# the console, in pixels.
+#
+# @option{cols} and @option{rows} specify that the console be sized to fit a text
+# console with the given dimensions.
+#
+# @item -chardev ringbuf ,id=@var{id} [,size=@var{size}]
+#
+# Create a ring buffer with fixed size @option{size}.
+# @var{size} must be a power of two and defaults to @code{64K}.
+#
+# @item -chardev file ,id=@var{id} ,path=@var{path}
+#
+# Log all traffic received from the guest to a file.
+#
+# @option{path} specifies the path of the file to be opened. This file will be
+# created if it does not already exist, and overwritten if it does. @option{path}
+# is required.
+#
+# @item -chardev pipe ,id=@var{id} ,path=@var{path}
+#
+# Create a two-way connection to the guest. The behaviour differs slightly between
+# Windows hosts and other hosts:
+#
+# On Windows, a single duplex pipe will be created at
+# @file{\\.pipe\@option{path}}.
+#
+# On other hosts, 2 pipes will be created called @file{@option{path}.in} and
+# @file{@option{path}.out}. Data written to @file{@option{path}.in} will be
+# received by the guest. Data written by the guest can be read from
+# @file{@option{path}.out}. QEMU will not create these fifos, and requires them to
+# be present.
+#
+# @option{path} forms part of the pipe path as described above. @option{path} is
+# required.
+#
+# @item -chardev console ,id=@var{id}
+#
+# Send traffic from the guest to QEMU's standard output. @option{console} does not
+# take any options.
+#
+# @option{console} is only available on Windows hosts.
+#
+# @item -chardev serial ,id=@var{id} ,path=@option{path}
+#
+# Send traffic from the guest to a serial device on the host.
+#
+# On Unix hosts serial will actually accept any tty device,
+# not only serial lines.
+#
+# @option{path} specifies the name of the serial device to open.
+#
+# @item -chardev pty ,id=@var{id}
+#
+# Create a new pseudo-terminal on the host and connect to it. @option{pty} does
+# not take any options.
+#
+# @option{pty} is not available on Windows hosts.
+#
+# @item -chardev stdio ,id=@var{id} [,signal=on|off]
+# Connect to standard input and standard output of the QEMU process.
+#
+# @option{signal} controls if signals are enabled on the terminal, that includes
+# exiting QEMU with the key sequence @key{Control-c}. This option is enabled by
+# default, use @option{signal=off} to disable it.
+#
+# @item -chardev braille ,id=@var{id}
+#
+# Connect to a local BrlAPI server. @option{braille} does not take any options.
+#
+# @item -chardev tty ,id=@var{id} ,path=@var{path}
+#
+# @option{tty} is only available on Linux, Sun, FreeBSD, NetBSD, OpenBSD and
+# DragonFlyBSD hosts.  It is an alias for @option{serial}.
+#
+# @option{path} specifies the path to the tty. @option{path} is required.
+#
+# @item -chardev parallel ,id=@var{id} ,path=@var{path}
+# @itemx -chardev parport ,id=@var{id} ,path=@var{path}
+#
+# @option{parallel} is only available on Linux, FreeBSD and DragonFlyBSD hosts.
+#
+# Connect to a local parallel port.
+#
+# @option{path} specifies the path to the parallel port device. @option{path} is
+# required.
+#
+# @item -chardev spicevmc ,id=@var{id} ,debug=@var{debug}, name=@var{name}
+#
+# @option{spicevmc} is only available when spice support is built in.
+#
+# @option{debug} debug level for spicevmc
+#
+# @option{name} name of spice channel to connect to
+#
+# Connect to a spice virtual machine channel, such as vdiport.
+#
+# @item -chardev spiceport ,id=@var{id} ,debug=@var{debug}, name=@var{name}
+#
+# @option{spiceport} is only available when spice support is built in.
+#
+# @option{debug} debug level for spicevmc
+#
+# @option{name} name of spice port to connect to
+#
+# Connect to a spice port, allowing a Spice client to handle the traffic
+# identified by a name (preferably a fqdn).
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--chardev',
+  'data': 'str',                # FIXME QAPIfy qemu_chardev_opts: ChardevBackend
+  'help': [
+"-chardev help",
+"-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]",
+"         [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]",
+"         [,logfile=PATH][,logappend=on|off][,tls-creds=ID] (tcp)",
+"-chardev socket,id=id,path=path[,server][,nowait][,telnet][,reconnect=seconds]",
+"         [,mux=on|off][,logfile=PATH][,logappend=on|off] (unix)",
+"-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]",
+"         [,localport=localport][,ipv4][,ipv6][,mux=on|off]",
+"         [,logfile=PATH][,logappend=on|off]",
+"-chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]",
+"         [,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]",
+"-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#ifdef _WIN32
+#    "-chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#    "-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#else
+"-chardev pty,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev stdio,id=id[,mux=on|off][,signal=on|off][,logfile=PATH][,logappend=on|off]",
+#endif
+#ifdef CONFIG_BRLAPI
+"-chardev braille,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#endif
+#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
+#    || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+"-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev tty,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#endif
+#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
+"-chardev parallel,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+"-chardev parport,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]",
+#endif
+#if defined(CONFIG_SPICE)
+"-chardev spicevmc,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]",
+"-chardev spiceport,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]"
+#endif
+] }
+
+##
+# == Bluetooth(R) options
+##
+
+##
+# @--bt:
+# !texinfo
+# -bt hci[...]@*
+# Defines the function of the corresponding Bluetooth HCI.  -bt options
+# are matched with the HCIs present in the chosen machine type.  For
+# example when emulating a machine with only one HCI built into it, only
+# the first @code{-bt hci[...]} option is valid and defines the HCI's
+# logic.  The Transport Layer is decided by the machine type.  Currently
+# the machines @code{n800} and @code{n810} have one HCI and all other
+# machines have none.
+#
+# @anchor{bt-hcis}
+# The following three types are recognized:
+#
+# @table @option
+# @item -bt hci,null@*
+# (default) The corresponding Bluetooth HCI assumes no internal logic
+# and will not respond to any HCI commands or emit events.
+#
+# @item -bt hci,host[:@var{id}]@*
+# (@code{bluez} only) The corresponding HCI passes commands / events
+# to / from the physical HCI identified by the name @var{id} (default:
+# @code{hci0}) on the computer running QEMU.  Only available on @code{bluez}
+# capable systems like Linux.
+#
+# @item -bt hci[,vlan=@var{n}]@*
+# Add a virtual, standard HCI that will participate in the Bluetooth
+# scatternet @var{n} (default @code{0}).  Similarly to @option{-net}
+# VLANs, devices inside a bluetooth network @var{n} can only communicate
+# with other devices in the same network (scatternet).
+# @end table
+#
+# -bt vhci[,vlan=@var{n}]@*
+# (Linux-host only) Create a HCI in scatternet @var{n} (default 0) attached
+# to the host bluetooth stack instead of to the emulated target.  This
+# allows the host and target machines to participate in a common scatternet
+# and communicate.  Requires the Linux @code{vhci} driver installed.  Can
+# be used as following:
+#
+# @example
+# qemu-system-i386 [...OPTIONS...] -bt hci,vlan=5 -bt vhci,vlan=5
+# @end example
+#
+# -bt device:@var{dev}[,vlan=@var{n}]@*
+# Emulate a bluetooth device @var{dev} and place it in network @var{n}
+# (default @code{0}).  QEMU can only emulate one type of bluetooth devices
+# currently:
+#
+# @table @option
+# @item keyboard
+# Virtual wireless keyboard implementing the HIDP bluetooth profile.
+# @end table
+# !end texinfo
+##
+{ 'option': '--bt',
+  'data': 'str',                # FIXME QAPIfy bt_parse()
+  'help': [
+"-bt hci,null    dumb bluetooth HCI - doesn't respond to commands",
+"-bt hci,host[:id]",
+"                use host's HCI with the given name",
+"-bt hci[,vlan=n]",
+"                emulate a standard HCI in virtual scatternet 'n'",
+"-bt vhci[,vlan=n]",
+"                add host computer to virtual scatternet 'n' using VHCI",
+"-bt device:dev[,vlan=n]",
+"                emulate a bluetooth device 'dev' in scatternet 'n'"] }
+
+##
+# == TPM device options
+##
+
+##
+# @--tpmdev:
+# !texinfo
+# The general form of a TPM device option is:
+# -tpmdev @var{backend} ,id=@var{id} [,@var{options}]\@
+#
+# The specific backend type will determine the applicable options.
+# The @code{-tpmdev} option creates the TPM backend and requires a
+# @code{-device} option that specifies the TPM frontend interface model.
+#
+# Use @code{-tpmdev help} to print all available TPM backend types.
+#
+# The available backends are:
+#
+# @table @option
+#
+# @item -tpmdev passthrough, id=@var{id}, path=@var{path}, cancel-path=@var{cancel-path}
+#
+# (Linux-host only) Enable access to the host's TPM using the passthrough
+# driver.
+#
+# @option{path} specifies the path to the host's TPM device, i.e., on
+# a Linux host this would be @code{/dev/tpm0}.
+# @option{path} is optional and by default @code{/dev/tpm0} is used.
+#
+# @option{cancel-path} specifies the path to the host TPM device's sysfs
+# entry allowing for cancellation of an ongoing TPM command.
+# @option{cancel-path} is optional and by default QEMU will search for the
+# sysfs entry to use.
+#
+# Some notes about using the host's TPM with the passthrough driver:
+#
+# The TPM device accessed by the passthrough driver must not be
+# used by any other application on the host.
+#
+# Since the host's firmware (BIOS/UEFI) has already initialized the TPM,
+# the VM's firmware (BIOS/UEFI) will not be able to initialize the
+# TPM again and may therefore not show a TPM-specific menu that would
+# otherwise allow the user to configure the TPM, e.g., allow the user to
+# enable/disable or activate/deactivate the TPM.
+# Further, if TPM ownership is released from within a VM then the host's TPM
+# will get disabled and deactivated. To enable and activate the
+# TPM again afterwards, the host has to be rebooted and the user is
+# required to enter the firmware's menu to enable and activate the TPM.
+# If the TPM is left disabled and/or deactivated most TPM commands will fail.
+#
+# To create a passthrough TPM use the following two options:
+# @example
+# -tpmdev passthrough,id=tpm0 -device tpm-tis,tpmdev=tpm0
+# @end example
+# Note that the @code{-tpmdev} id is @code{tpm0} and is referenced by
+# @code{tpmdev=tpm0} in the device option.
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--tpmdev',
+  'data': 'str',                # FIXME QAPIfy qemu_tpmdev_opts, tpm_passthrough_handle_device_opts()
+  'help': [
+"-tpmdev passthrough,id=id[,path=path][,cancel-path=path]",
+"                use path to provide path to a character device; default is /dev/tpm0",
+"                use cancel-path to provide path to TPM's cancel sysfs entry; if",
+"                not provided it will be searched for in /sys/class/misc/tpm?/device"] }
+
+##
+# == Linux/Multiboot boot specific
+#
+# When using these options, you can use a given Linux or Multiboot
+# kernel without installing it in the disk image. It can be useful
+# for easier testing of various kernels.
+##
+
+##
+# @--kernel:
+# !texinfo
+# -kernel @var{bzImage}@*
+# Use @var{bzImage} as kernel image. The kernel can be either a Linux kernel
+# or in multiboot format.
+# !end texinfo
+##
+{ 'option': '--kernel',
+  'data': 'str',
+  'help': "-kernel bzImage use 'bzImage' as kernel image" }
+
+##
+# @--append:
+# !texinfo
+# -append @var{cmdline}@*
+# Use @var{cmdline} as kernel command line
+# !end texinfo
+##
+{ 'option': '--append',
+  'data': 'str',
+  'help': "-append cmdline use 'cmdline' as kernel command line" }
+
+##
+# @--initrd:
+# !texinfo
+# -initrd @var{file}@*
+# Use @var{file} as initial ram disk.
+#
+# -initrd "@var{file1} arg=foo,@var{file2}"@*
+#
+# This syntax is only available with multiboot.
+#
+# Use @var{file1} and @var{file2} as modules and pass arg=foo as parameter to the
+# first module.
+# !end texinfo
+##
+{ 'option': '--initrd',
+  'data': 'str',
+  'help': "-initrd file    use 'file' as initial ram disk" }
+
+##
+# @--dtb:
+# !texinfo
+# -dtb @var{file}@*
+# Use @var{file} as a device tree binary (dtb) image and pass it to the kernel
+# on boot.
+# !end texinfo
+##
+{ 'option': '--dtb',
+  'data': 'str',
+  'help': "-dtb    file    use 'file' as device tree image" }
+
+##
+# == Debug/Expert options
+##
+
+##
+# @--fw_cfg:
+# !texinfo
+#
+# -fw_cfg [name=]@var{name},file=@var{file}@*
+# Add named fw_cfg entry with contents from file @var{file}.
+#
+# -fw_cfg [name=]@var{name},string=@var{str}@*
+# Add named fw_cfg entry with contents from string @var{str}.
+#
+# The terminating NUL character of the contents of @var{str} will not be
+# included as part of the fw_cfg item data. To insert contents with
+# embedded NUL characters, you have to use the @var{file} parameter.
+#
+# The fw_cfg entries are passed by QEMU through to the guest.
+#
+# Example:
+# @example
+#     -fw_cfg name=opt/com.mycompany/blob,file=./my_blob.bin
+# @end example
+# creates an fw_cfg entry named opt/com.mycompany/blob with contents
+# from ./my_blob.bin.
+# !end texinfo
+##
+{ 'option': '--fw_cfg',
+  'data': 'str',                # FIXME QAPIfy qemu_fw_cfg_opts
+  'help': [
+"-fw_cfg [name=]<name>,file=<file>",
+"                add named fw_cfg entry with contents from file",
+"-fw_cfg [name=]<name>,string=<str>",
+"                add named fw_cfg entry with contents from string"] }
+
+##
+# @--serial:
+# !texinfo
+# -serial @var{dev}@*
+# Redirect the virtual serial port to host character device
+# @var{dev}. The default device is @code{vc} in graphical mode and
+# @code{stdio} in non graphical mode.
+#
+# This option can be used several times to simulate up to 4 serial
+# ports.
+#
+# Use @code{-serial none} to disable all serial ports.
+#
+# Available character devices are:
+# @table @option
+# @item vc[:@var{W}x@var{H}]
+# Virtual console. Optionally, a width and height can be given in pixel with
+# @example
+# vc:800x600
+# @end example
+# It is also possible to specify width or height in characters:
+# @example
+# vc:80Cx24C
+# @end example
+# @item pty
+# [Linux only] Pseudo TTY (a new PTY is automatically allocated)
+# @item none
+# No device is allocated.
+# @item null
+# void device
+# @item chardev:@var{id}
+# Use a named character device defined with the @code{-chardev} option.
+# @item /dev/XXX
+# [Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
+# parameters are set according to the emulated ones.
+# @item /dev/parport@var{N}
+# [Linux only, parallel port only] Use host parallel port
+# @var{N}. Currently SPP and EPP parallel port features can be used.
+# @item file:@var{filename}
+# Write output to @var{filename}. No character can be read.
+# @item stdio
+# [Unix only] standard input/output
+# @item pipe:@var{filename}
+# name pipe @var{filename}
+# @item COM@var{n}
+# [Windows only] Use host serial port @var{n}
+# @item udp:[@var{remote_host}]:@var{remote_port}[@@[@var{src_ip}]:@var{src_port}]
+# This implements UDP Net Console.
+# When @var{remote_host} or @var{src_ip} are not specified
+# they default to @code{0.0.0.0}.
+# When not using a specified @var{src_port} a random port is automatically chosen.
+#
+# If you just want a simple readonly console you can use @code{netcat} or
+# @code{nc}, by starting QEMU with: @code{-serial udp::4555} and nc as:
+# @code{nc -u -l -p 4555}. Any time QEMU writes something to that port it
+# will appear in the netconsole session.
+#
+# If you plan to send characters back via netconsole or you want to stop
+# and start QEMU a lot of times, you should have QEMU use the same
+# source port each time by using something like @code{-serial
+# udp::4555@@:4556} to QEMU. Another approach is to use a patched
+# version of netcat which can listen to a TCP port and send and receive
+# characters via udp.  If you have a patched version of netcat which
+# activates telnet remote echo and single char transfer, then you can
+# use the following options to set up a netcat redirector to allow
+# telnet on port 5555 to access the QEMU port.
+# @table @code
+# @item QEMU Options:
+# -serial udp::4555@@:4556
+# @item netcat options:
+# -u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
+# @item telnet options:
+# localhost 5555
+# @end table
+#
+# @item tcp:[@var{host}]:@var{port}[,@var{server}][,nowait][,nodelay][,reconnect=@var{seconds}]
+# The TCP Net Console has two modes of operation.  It can send the serial
+# I/O to a location or wait for a connection from a location.  By default
+# the TCP Net Console is sent to @var{host} at the @var{port}.  If you use
+# the @var{server} option QEMU will wait for a client socket application
+# to connect to the port before continuing, unless the @code{nowait}
+# option was specified.  The @code{nodelay} option disables the Nagle buffering
+# algorithm.  The @code{reconnect} option only applies if @var{noserver} is
+# set, if the connection goes down it will attempt to reconnect at the
+# given interval.  If @var{host} is omitted, 0.0.0.0 is assumed. Only
+# one TCP connection at a time is accepted. You can use @code{telnet} to
+# connect to the corresponding character device.
+# @table @code
+# @item Example to send tcp console to 192.168.0.2 port 4444
+# -serial tcp:192.168.0.2:4444
+# @item Example to listen and wait on port 4444 for connection
+# -serial tcp::4444,server
+# @item Example to not wait and listen on ip 192.168.0.100 port 4444
+# -serial tcp:192.168.0.100:4444,server,nowait
+# @end table
+#
+# @item telnet:@var{host}:@var{port}[,server][,nowait][,nodelay]
+# The telnet protocol is used instead of raw tcp sockets.  The options
+# work the same as if you had specified @code{-serial tcp}.  The
+# difference is that the port acts like a telnet server or client using
+# telnet option negotiation.  This will also allow you to send the
+# MAGIC_SYSRQ sequence if you use a telnet that supports sending the break
+# sequence.  Typically in unix telnet you do it with Control-] and then
+# type "send break" followed by pressing the enter key.
+#
+# @item unix:@var{path}[,server][,nowait][,reconnect=@var{seconds}]
+# A unix domain socket is used instead of a tcp socket.  The option works the
+# same as if you had specified @code{-serial tcp} except the unix domain socket
+# @var{path} is used for connections.
+#
+# @item mon:@var{dev_string}
+# This is a special option to allow the monitor to be multiplexed onto
+# another serial port.  The monitor is accessed with key sequence of
+# @key{Control-a} and then pressing @key{c}.
+# @var{dev_string} should be any one of the serial devices specified
+# above.  An example to multiplex the monitor onto a telnet server
+# listening on port 4444 would be:
+# @table @code
+# @item -serial mon:telnet::4444,server,nowait@*
+# @end table
+# When the monitor is multiplexed to stdio in this way, Ctrl+C will not terminate
+# QEMU any more but will be passed to the guest instead.
+#
+# @item braille
+# Braille device.  This will use BrlAPI to display the braille output on a real
+# or fake device.
+#
+# @item msmouse
+# Three button serial mouse. Configure the guest to use Microsoft protocol.
+# @end table
+# !end texinfo
+##
+{ 'option': '--serial',
+  'data': 'str',                # FIXME QAPIfy serial_parse()
+  'help': "-serial dev     redirect the serial port to char device 'dev'" }
+
+##
+# @--parallel:
+# !texinfo
+# -parallel @var{dev}@*
+# Redirect the virtual parallel port to host device @var{dev} (same
+# devices as the serial port). On Linux hosts, @file{/dev/parportN} can
+# be used to use hardware devices connected on the corresponding host
+# parallel port.
+#
+# This option can be used several times to simulate up to 3 parallel
+# ports.
+#
+# Use @code{-parallel none} to disable all parallel ports.
+# !end texinfo
+##
+{ 'option': '--parallel',
+  'data': 'str',                # FIXME QAPIfy parallel_parse()
+  'help': "-parallel dev   redirect the parallel port to char device 'dev'" }
+
+##
+# @--monitor:
+# !texinfo
+# -monitor @var{dev}@*
+# Redirect the monitor to host device @var{dev} (same devices as the
+# serial port).
+# The default device is @code{vc} in graphical mode and @code{stdio} in
+# non graphical mode.
+# Use @code{-monitor none} to disable the default monitor.
+# !end texinfo
+##
+{ 'option': '--monitor',
+  'data': 'str',                # FIXME QAPIfy monitor_parse()
+  'help': "-monitor dev    redirect the monitor to char device 'dev'" }
+
+##
+# @--qmp:
+# !texinfo
+# -qmp @var{dev}@*
+# Like -monitor but opens in 'control' mode.
+# !end texinfo
+##
+{ 'option': '--qmp',
+  'data': 'str',                # FIXME QAPIfy monitor_parse()
+  'help': "-qmp dev        like -monitor but opens in 'control' mode" }
+
+##
+# @--qmp-pretty:
+# !texinfo
+# -qmp-pretty @var{dev}@*
+# Like -qmp but uses pretty JSON formatting.
+# !end texinfo
+##
+{ 'option': '--qmp-pretty',
+  'data': 'str',                # FIXME
+  'help': "-qmp-pretty dev like -qmp but uses pretty JSON formatting" }
+
+##
+# @--mon:
+# !texinfo
+# -mon [chardev=]name[,mode=readline|control]@*
+# Setup monitor on chardev @var{name}.
+# !end texinfo
+##
+{ 'option': '--mon',
+  'data': 'str',                # FIXME QAPIfy qemu_mon_opts
+  'help': "-mon [chardev=]name[,mode=readline|control]" }
+
+##
+# @--debugcon:
+# !texinfo
+# -debugcon @var{dev}@*
+# Redirect the debug console to host device @var{dev} (same devices as the
+# serial port).  The debug console is an I/O port which is typically port
+# 0xe9; writing to that I/O port sends output to this device.
+# The default device is @code{vc} in graphical mode and @code{stdio} in
+# non graphical mode.
+# !end texinfo
+##
+{ 'option': '--debugcon',
+  'data': 'str',                # FIXME QAPIfy debugcon_parse()
+  'help': "-debugcon dev   redirect the debug console to char device 'dev'" }
+
+##
+# @--pidfile:
+# !texinfo
+# -pidfile @var{file}@*
+# Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
+# from a script.
+# !end texinfo
+##
+{ 'option': '--pidfile',
+  'data': 'str',
+  'help': "-pidfile file   write PID to 'file'" }
+
+##
+# @--singlestep:
+# !texinfo
+# -singlestep@*
+# Run the emulation in single step mode.
+# !end texinfo
+##
+{ 'option': '--singlestep',
+  'help': "-singlestep     always run in singlestep mode" }
+
+##
+# @--stopped:
+# !texinfo
+# -S@*
+# Do not start CPU at startup (you must type 'c' in the monitor).
+# !end texinfo
+##
+{ 'option': '--stopped', 'short': 'S',
+  'help': "-S              freeze CPU at startup (use 'c' to start execution)" }
+
+##
+# @--realtime:
+# !texinfo
+# -realtime mlock=on|off@*
+# Run qemu with realtime features.
+# mlocking qemu and guest memory can be enabled via @option{mlock=on}
+# (enabled by default).
+# !end texinfo
+##
+{ 'option': '--realtime',
+  'data': 'str',                # FIXME QAPIfy qemu_realtime_opts
+  'help': [
+"-realtime [mlock=on|off]",
+"                run qemu with realtime features",
+"                mlock=on|off controls mlock support (default: on)"] }
+
+##
+# @--gdb:
+# !texinfo
+# -gdb @var{dev}@*
+# Wait for gdb connection on device @var{dev} (FIXME @@pxref@{gdb_usage@}). Typical
+# connections will likely be TCP-based, but also UDP, pseudo TTY, or even
+# stdio are reasonable use case. The latter is allowing to start QEMU from
+# within gdb and establish the connection via a pipe:
+# @example
+# (gdb) target remote | exec qemu-system-i386 -gdb stdio ...
+# @end example
+# !end texinfo
+##
+{ 'option': '--gdb',
+  'data': 'str',                # FIXME QAPIfy gdbserver_start()
+  'help': "-gdb dev        wait for gdb connection on 'dev'" }
+
+##
+# @--gdb-default:
+# !texinfo
+# -s@*
+# Shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port 1234
+# (FIXME @@pxref@{gdb_usage@}).
+# !end texinfo
+##
+{ 'option': '--gdb-default', 'short': 's',
+  'help': "-s              shorthand for -gdb tcp::FIXME" }
+
+##
+# @--debug-enable:
+# !texinfo
+# -d @var{item1}[,...]@*
+# Enable logging of specified items. Use '-d help' for a list of log items.
+# !end texinfo
+##
+{ 'option': '--debug-enable', 'short': 'd',
+  'data': 'str',                # FIXME QAPIfy qemu_str_to_log_mask()
+  'help': "-d item1,...    enable logging of specified items (use '-d help' for a list of log items)" }
+
+##
+# @--debug-log:
+# !texinfo
+# -D @var{logfile}@*
+# Output log in @var{logfile} instead of to stderr
+# !end texinfo
+##
+# TODO either document the %d feature, or kill it
+{ 'option': '--debug-log', 'short': 'D',
+  'data': 'str',
+  'help': "-D logfile      output log to logfile (default stderr)" }
+
+##
+# @--dfilter:
+# !texinfo
+# -dfilter @var{range1}[,...]@*
+# Filter debug output to that relevant to a range of target addresses. The filter
+# spec can be either @var{start}+@var{size}, @var{start}-@var{size} or
+# @var{start}..@var{end} where @var{start} @var{end} and @var{size} are the
+# addresses and sizes required. For example:
+# @example
+#     -dfilter 0x8000..0x8fff,0xffffffc000080000+0x200,0xffffffc000060000-0x1000
+# @end example
+# Will dump output for any code in the 0x1000 sized block starting at 0x8000 and
+# the 0x200 sized block starting at 0xffffffc000080000 and another 0x1000 sized
+# block starting at 0xffffffc00005f000.
+# !end texinfo
+##
+{ 'option': '--dfilter',
+  'data': 'str',                # FIXME QAPIfy qemu_set_dfilter_ranges()
+  'help': "-dfilter range,..  filter debug output to range of addresses (useful for -d cpu,exec,etc..)" }
+
+##
+# @--load-path:
+# !texinfo
+# -L  @var{path}@*
+# Set the directory for the BIOS, VGA BIOS and keymaps.
+#
+# To list all the data directories, use @code{-L help}.
+# !end texinfo
+##
+{ 'option': '--load-path', 'short': 'L',
+  'data': 'str',
+  'help': "-L path         set the directory for the BIOS, VGA BIOS and keymaps" }
+
+##
+# @--bios:
+# !texinfo
+# -bios @var{file}@*
+# Set the filename for the BIOS.
+# !end texinfo
+##
+{ 'option': '--bios',
+  'data': 'str',
+  'help': "-bios file      set the filename for the BIOS" }
+
+##
+# @--enable-kvm:
+# !texinfo
+# -enable-kvm@*
+# Enable KVM full virtualization support. This option is only available
+# if KVM support is enabled when compiling.
+# !end texinfo
+##
+{ 'option': '--enable-kvm',
+  'help': "-enable-kvm     enable KVM full virtualization support" }
+
+##
+# @--enable-hax:
+# !texinfo
+# -enable-hax@*
+# Enable HAX (Hardware-based Acceleration eXecution) support. This option
+# is only available if HAX support is enabled when compiling. HAX is only
+# applicable to MAC and Windows platform, and thus does not conflict with
+# KVM.
+# !end texinfo
+##
+{ 'option': '--enable-hax',
+  'help': "-enable-hax     enable HAX virtualization support" }
+
+##
+# @--xen-domid:
+# !texinfo
+# -xen-domid @var{id}@*
+# Specify xen guest domain @var{id} (XEN only).
+# !end texinfo
+##
+{ 'option': '--xen-domid',
+  'data': 'str',                # FIXME int32
+  'help': "-xen-domid id   specify xen guest domain id" }
+
+##
+# @--xen-create:
+# !texinfo
+# -xen-create@*
+# Create domain using xen hypercalls, bypassing xend.
+# Warning: should not be used when xend is in use (XEN only).
+# !end texinfo
+##
+{ 'option': '--xen-create',
+  'help': [
+"-xen-create     create domain using xen hypercalls, bypassing xend",
+"                warning: should not be used when xend is in use"] }
+
+##
+# @--xen-attach:
+# !texinfo
+# -xen-attach@*
+# Attach to existing xen domain.
+# xend will use this when starting QEMU (XEN only).
+# !end texinfo
+##
+{ 'option': '--xen-attach',
+  'help': [
+"-xen-attach     attach to existing xen domain",
+"                xend will use this when starting QEMU"] }
+
+##
+# @--xen-domid-restrict:
+# !texinfo
+# Restrict set of available xen operations to specified domain id (XEN only).
+# !end texinfo
+##
+{ 'option': '--xen-domid-restrict',
+  'help': [
+"-xen-domid-restrict     restrict set of available xen operations",
+"                        to specified domain id. (Does not affect",
+"                        xenpv machine type)."] }
+
+##
+# @--no-reboot:
+# !texinfo
+# -no-reboot@*
+# Exit instead of rebooting.
+# !end texinfo
+##
+{ 'option': '--no-reboot',
+  'help': "-no-reboot      exit instead of rebooting" }
+
+##
+# @--no-shutdown:
+# !texinfo
+# -no-shutdown@*
+# Don't exit QEMU on guest shutdown, but instead only stop the emulation.
+# This allows for instance switching to monitor to commit changes to the
+# disk image.
+# !end texinfo
+##
+{ 'option': '--no-shutdown',
+  'help': "-no-shutdown    stop before shutdown" }
+
+##
+# @--loadvm:
+# !texinfo
+# -loadvm @var{file}@*
+# Start right away with a saved state (@code{loadvm} in monitor)
+# !end texinfo
+##
+# FIXME @var{file} is bogus
+{ 'option': '--loadvm',
+  'data': 'str',
+  'help': [
+"-loadvm [tag|id]",
+"                start right away with a saved state (loadvm in monitor)"] }
+
+##
+# @--daemonize:
+# !texinfo
+# -daemonize@*
+# Daemonize the QEMU process after initialization.  QEMU will not detach from
+# standard IO until it is ready to receive connections on any of its devices.
+# This option is a useful way for external programs to launch QEMU without having
+# to cope with initialization race conditions.
+# !end texinfo
+##
+{ 'option': '--daemonize',
+  'help': "-daemonize      daemonize QEMU after initializing" }
+
+##
+# @--option-rom:
+# !texinfo
+# -option-rom @var{file}@*
+# Load the contents of @var{file} as an option ROM.
+# This option is useful to load things like EtherBoot.
+# !end texinfo
+##
+{ 'option': '--option-rom',
+  'data': 'str',                # FIXME QAPIfy qemu_option_rom_opts
+  'help': "-option-rom rom load a file, rom, into the option ROM space" }
+
+##
+# @--clock:
+##
+# TODO deprecate
+{ 'option': '--clock',
+  'data': 'str',                # FIXME
+  'help': null }
+
+##
+# @--localtime:
+##
+# TODO deprecate
+{ 'option': '--localtime',
+  'help': null }
+
+##
+# @--startdate:
+##
+# TODO deprecate
+{ 'option': '--startdate',
+  'data': 'str',                # FIXME QAPIfy configure_rtc_date_offset()
+  'help': null }
+
+##
+# @--rtc:
+# !texinfo
+#
+# -rtc [base=utc|localtime|@var{date}][,clock=host|vm][,driftfix=none|slew]@*
+# Specify @option{base} as @code{utc} or @code{localtime} to let the RTC start at the current
+# UTC or local time, respectively. @code{localtime} is required for correct date in
+# MS-DOS or Windows. To start at a specific point in time, provide @var{date} in the
+# format @code{2006-06-17T16:01:21} or @code{2006-06-17}. The default base is UTC.
+#
+# By default the RTC is driven by the host system time. This allows using of the
+# RTC as accurate reference clock inside the guest, specifically if the host
+# time is smoothly following an accurate external reference clock, e.g. via NTP.
+# If you want to isolate the guest time from the host, you can set @option{clock}
+# to @code{rt} instead.  To even prevent it from progressing during suspension,
+# you can set it to @code{vm}.
+#
+# Enable @option{driftfix} (i386 targets only) if you experience time drift problems,
+# specifically with Windows' ACPI HAL. This option will try to figure out how
+# many timer interrupts were not processed by the Windows guest and will
+# re-inject them.
+# !end texinfo
+##
+{ 'option': '--rtc',
+  'data': 'str',                # FIXME QAPIfy qemu_rtc_opts
+  'help': [
+"-rtc [base=utc|localtime|date][,clock=host|rt|vm][,driftfix=none|slew]",
+"                set the RTC base and clock, enable drift fix for clock ticks (x86 only)"] }
+
+##
+# @--icount:
+# !texinfo
+# -icount [shift=@var{N}|auto][,rr=record|replay,rrfile=@var{filename},rrsnapshot=@var{snapshot}]@*
+# Enable virtual instruction counter.  The virtual cpu will execute one
+# instruction every 2^@var{N} ns of virtual time.  If @code{auto} is specified
+# then the virtual cpu speed will be automatically adjusted to keep virtual
+# time within a few seconds of real time.
+#
+# When the virtual cpu is sleeping, the virtual time will advance at default
+# speed unless @option{sleep=on|off} is specified.
+# With @option{sleep=on|off}, the virtual time will jump to the next timer deadline
+# instantly whenever the virtual cpu goes to sleep mode and will not advance
+# if no timer is enabled. This behavior give deterministic execution times from
+# the guest point of view.
+#
+# Note that while this option can give deterministic behavior, it does not
+# provide cycle accurate emulation.  Modern CPUs contain superscalar out of
+# order cores with complex cache hierarchies.  The number of instructions
+# executed often has little or no correlation with actual performance.
+#
+# @option{align=on} will activate the delay algorithm which will try
+# to synchronise the host clock and the virtual clock. The goal is to
+# have a guest running at the real frequency imposed by the shift option.
+# Whenever the guest clock is behind the host clock and if
+# @option{align=on} is specified then we print a message to the user
+# to inform about the delay.
+# Currently this option does not work when @option{shift} is @code{auto}.
+# Note: The sync algorithm will work for those shift values for which
+# the guest clock runs ahead of the host clock. Typically this happens
+# when the shift value is high (how high depends on the host machine).
+#
+# When @option{rr} option is specified deterministic record/replay is enabled.
+# Replay log is written into @var{filename} file in record mode and
+# read from this file in replay mode.
+#
+# Option rrsnapshot is used to create new vm snapshot named @var{snapshot}
+# at the start of execution recording. In replay mode this option is used
+# to load the initial VM state.
+# !end texinfo
+##
+{ 'option': '--icount',
+  'data': 'str',                # FIXME QAPIfy qemu_icount_opts
+  'help': [
+"-icount [shift=N|auto][,align=on|off][,sleep=on|off,rr=record|replay,rrfile=<filename>,rrsnapshot=<snapshot>]",
+"                enable virtual instruction counter with 2^N clock ticks per",
+"                instruction, enable aligning the host and virtual clocks",
+"                or disable real time cpu sleeping"] }
+
+##
+# @--watchdog:
+# !texinfo
+# -watchdog @var{model}@*
+# Create a virtual hardware watchdog device.  Once enabled (by a guest
+# action), the watchdog must be periodically polled by an agent inside
+# the guest or else the guest will be restarted. Choose a model for
+# which your guest has drivers.
+#
+# The @var{model} is the model of hardware watchdog to emulate. Use
+# @code{-watchdog help} to list available hardware models. Only one
+# watchdog can be enabled for a guest.
+#
+# The following models may be available:
+# @table @option
+# @item ib700
+# iBASE 700 is a very simple ISA watchdog with a single timer.
+# @item i6300esb
+# Intel 6300ESB I/O controller hub is a much more featureful PCI-based
+# dual-timer watchdog.
+# @item diag288
+# A virtual watchdog for s390x backed by the diagnose 288 hypercall
+# (currently KVM only).
+# @end table
+# !end texinfo
+##
+{ 'option': '--watchdog',
+  'data': 'str',                # FIXME QAPIfy select_watchdog()
+  'help': [
+"-watchdog model",
+"                enable virtual hardware watchdog [default=none]"] }
+
+##
+# @--watchdog-action:
+# !texinfo
+# -watchdog-action @var{action}@*
+#
+# The @var{action} controls what QEMU will do when the watchdog timer
+# expires.
+# The default is
+# @code{reset} (forcefully reset the guest).
+# Other possible actions are:
+# @code{shutdown} (attempt to gracefully shutdown the guest),
+# @code{poweroff} (forcefully poweroff the guest),
+# @code{inject-nmi} (inject a NMI into the guest),
+# @code{pause} (pause the guest),
+# @code{debug} (print a debug message and continue), or
+# @code{none} (do nothing).
+#
+# Note that the @code{shutdown} action requires that the guest responds
+# to ACPI signals, which it may not be able to do in the sort of
+# situations where the watchdog would have expired, and thus
+# @code{-watchdog-action shutdown} is not recommended for production use.
+#
+# Examples:
+#
+# @table @code
+# @item -watchdog i6300esb -watchdog-action pause@*
+# @itemx -watchdog ib700@*
+# @end table
+# !end texinfo
+##
+{ 'option': '--watchdog-action',
+  'data': 'str',                # FIXME enum
+  'help': [
+"-watchdog-action reset|shutdown|poweroff|inject-nmi|pause|debug|none",
+"                action when watchdog fires [default=reset]"] }
+
+##
+# @--echr:
+# !texinfo
+#
+# -echr @var{numeric_ascii_value}@*
+# Change the escape character used for switching to the monitor when using
+# monitor and serial sharing.  The default is @code{0x01} when using the
+# @code{-nographic} option.  @code{0x01} is equal to pressing
+# @code{Control-a}.  You can select a different character from the ascii
+# control keys where 1 through 26 map to Control-a through Control-z.  For
+# instance you could use the either of the following to change the escape
+# character to Control-t.
+# @table @code
+# @item -echr 0x14@*
+# @itemx -echr 20@*
+# @end table
+# !end texinfo
+##
+{ 'option': '--echr',
+  'data': 'str',                # FIXME int
+  'help': "-echr chr       set terminal escape character instead of ctrl-a" }
+
+##
+# @--virtioconsole:
+# !texinfo
+# -virtioconsole @var{c}@*
+# Set virtio console.
+#
+# This option is maintained for backward compatibility.
+#
+# Please use @code{-device virtconsole} for the new way of invocation.
+# !end texinfo
+##
+{ 'option': '--virtioconsole',
+  'data': 'str',                # FIXME QAPIfy virtcon_parse()
+  'help': [
+"-virtioconsole c",
+"                set virtio console"] }
+
+##
+# @--show-cursor:
+# !texinfo
+# -show-cursor@*
+# Show cursor.
+# !end texinfo
+##
+{ 'option': '--show-cursor',
+  'help': "-show-cursor    show cursor" }
+
+##
+# @--tb-size:
+# !texinfo
+# -tb-size @var{n}@*
+# Set TB size.
+# !end texinfo
+##
+{ 'option': '--tb-size',
+  'data': 'str',                # FIXME size
+  'help': "-tb-size n      set TB size" }
+
+##
+# @--incoming:
+# !texinfo
+# -incoming tcp:[@var{host}]:@var{port}[,to=@var{maxport}][,ipv4][,ipv6]@*
+# -incoming rdma:@var{host}:@var{port}[,ipv4][,ipv6]@*
+# Prepare for incoming migration, listen on a given tcp port.
+#
+# -incoming unix:@var{socketpath}@*
+# Prepare for incoming migration, listen on a given unix socket.
+#
+# -incoming fd:@var{fd}@*
+# Accept incoming migration from a given filedescriptor.
+#
+# -incoming exec:@var{cmdline}@*
+# Accept incoming migration as an output from specified external command.
+#
+# -incoming defer@*
+# Wait for the URI to be specified via migrate_incoming.  The monitor can
+# be used to change settings (such as migration parameters) prior to issuing
+# the migrate_incoming to allow the migration to begin.
+# !end texinfo
+##
+{ 'option': '--incoming',
+  'data': 'str',                # FIXME QAPIfy qemu_start_incoming_migration()
+  'help': [
+"-incoming tcp:[host]:port[,to=maxport][,ipv4][,ipv6]",
+"-incoming rdma:host:port[,ipv4][,ipv6]",
+"-incoming unix:socketpath",
+"                prepare for incoming migration, listen on",
+"                specified protocol and socket address",
+"-incoming fd:fd",
+"-incoming exec:cmdline",
+"                accept incoming migration on given file descriptor",
+"                or from given external command",
+"-incoming defer",
+"                wait for the URI to be specified via migrate_incoming"] }
+
+##
+# @--only-migratable:
+# !texinfo
+# -only-migratable@*
+# Only allow migratable devices. Devices will not be allowed to enter an
+# unmigratable state.
+# !end texinfo
+##
+{ 'option': '--only-migratable',
+  'help': "-only-migratable     allow only migratable devices" }
+
+##
+# @--nodefaults:
+# !texinfo
+# -nodefaults@*
+# Don't create default devices. Normally, QEMU sets the default devices like serial
+# port, parallel port, virtual console, monitor device, VGA adapter, floppy and
+# CD-ROM drive and others. The @code{-nodefaults} option will disable all those
+# default devices.
+# !end texinfo
+##
+{ 'option': '--nodefaults',
+  'help': "-nodefaults     don't create default devices" }
+
+##
+# @--chroot:
+# !texinfo
+# -chroot @var{dir}@*
+# Immediately before starting guest execution, chroot to the specified
+# directory.  Especially useful in combination with -runas.
+# !end texinfo
+##
+{ 'option': '--chroot',
+  'data': 'str',
+  'help': "-chroot dir     chroot to dir just before starting the VM" }
+
+##
+# @--runas:
+# !texinfo
+# -runas @var{user}@*
+# Immediately before starting guest execution, drop root privileges, switching
+# to the specified user.
+# !end texinfo
+##
+{ 'option': '--runas',
+  'data': 'str',
+  'help': "-runas user     change to user id user just before starting the VM" }
+
+##
+# @--prom-env:
+# !texinfo
+# -prom-env @var{variable}=@var{value}@*
+# Set OpenBIOS nvram @var{variable} to given @var{value} (PPC, SPARC only).
+# !end texinfo
+##
+{ 'option': '--prom-env',
+  'data': 'str',                # fine (we leave parsing it to OpenBIOS)
+  'help': [
+"-prom-env variable=value",
+"                set OpenBIOS nvram variables"] }
+
+##
+# @--semihosting:
+# !texinfo
+# -semihosting@*
+# Enable semihosting mode (ARM, M68K, Xtensa, MIPS only).
+# !end texinfo
+##
+{ 'option': '--semihosting',
+  'help': "-semihosting    semihosting mode" }
+
+##
+# @--semihosting-config:
+# !texinfo
+# -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]@*
+# Enable and configure semihosting (ARM, M68K, Xtensa, MIPS only).
+# @table @option
+# @item target=@code{native|gdb|auto}
+# Defines where the semihosting calls will be addressed, to QEMU (@code{native})
+# or to GDB (@code{gdb}). The default is @code{auto}, which means @code{gdb}
+# during debug sessions and @code{native} otherwise.
+# @item arg=@var{str1},arg=@var{str2},...
+# Allows the user to pass input arguments, and can be used multiple times to build
+# up a list. The old-style @code{-kernel}/@code{-append} method of passing a
+# command line is still supported for backward compatibility. If both the
+# @code{--semihosting-config arg} and the @code{-kernel}/@code{-append} are
+# specified, the former is passed to semihosting as it always takes precedence.
+# @end table
+# !end texinfo
+##
+{ 'option': '--semihosting-config',
+  'data': 'str',                # FIXME QAPIfy qemu_semihosting_config_opts
+  'help': [
+"-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]",
+"                semihosting configuration"] }
+
+##
+# @--old-param:
+# !texinfo
+# -old-param@*
+# Old param mode (ARM only).
+# !end texinfo
+##
+{ 'option': '--old-param',
+  'help': "-old-param      old param mode" }
+
+##
+# @--sandbox:
+# !texinfo
+# -sandbox @var{arg}[,obsolete=@var{string}][,elevateprivileges=@var{string}][,spawn=@var{string}][,resourcecontrol=@var{string}]@*
+# Enable Seccomp mode 2 system call filter. 'on' will enable syscall filtering and 'off' will
+# disable it.  The default is 'off'.
+# @table @option
+# @item obsolete=@var{string}
+# Enable Obsolete system calls
+# @item elevateprivileges=@var{string}
+# Disable set*uid|gid system calls
+# @item spawn=@var{string}
+# Disable *fork and execve
+# @item resourcecontrol=@var{string}
+# Disable process affinity and schedular priority
+# @end table
+# !end texinfo
+##
+{ 'option': '--sandbox',
+  'data': 'str',                # FIXME QAPIfy qemu_sandbox_opts
+  'help': [
+"-sandbox on[,obsolete=allow|deny][,elevateprivileges=allow|deny|children]",
+"          [,spawn=allow|deny][,resourcecontrol=allow|deny]",
+"                Enable seccomp mode 2 system call filter (default 'off').",
+"                use 'obsolete' to allow obsolete system calls that are provided",
+"                    by the kernel, but typically no longer used by modern",
+"                    C library implementations.",
+"                use 'elevateprivileges' to allow or deny QEMU process to elevate",
+"                    its privileges by blacklisting all set*uid|gid system calls.",
+"                    The value 'children' will deny set*uid|gid system calls for",
+"                    main QEMU process but will allow forks and execves to run unprivileged",
+"                use 'spawn' to avoid QEMU to spawn new threads or processes by",
+"                     blacklisting *fork and execve",
+"                use 'resourcecontrol' to disable process affinity and schedular priority"] }
+
+##
+# @--readconfig:
+# !texinfo
+# -readconfig @var{file}@*
+# Read device configuration from @var{file}. This approach is useful when you want to spawn
+# QEMU process with many command line options but you don't want to exceed the command line
+# character limit.
+# !end texinfo
+##
+{ 'option': '--readconfig',
+  'data': 'str',                # FIXME
+  'help': "-readconfig <file>" }
+
+##
+# @--writeconfig:
+# !texinfo
+# -writeconfig @var{file}@*
+# Write device configuration to @var{file}. The @var{file} can be either filename to save
+# command line and device configuration into file or dash @code{-}) character to print the
+# output to stdout. This can be later used as input file for @code{-readconfig} option.
+# !end texinfo
+##
+{ 'option': '--writeconfig',
+  'data': 'str',                # FIXME
+  'help': [
+"-writeconfig <file>",
+"                read/write config file"] }
+
+##
+# @--nodefconfig:
+# !texinfo
+# -nodefconfig@*
+# Normally QEMU loads configuration files from @var{sysconfdir} and @var{datadir} at startup.
+# The @code{-nodefconfig} option will prevent QEMU from loading any of those config files.
+# !end texinfo
+##
+{ 'option': '--nodefconfig',
+  'help': [
+"-nodefconfig",
+"                do not load default config files at startup"] }
+
+##
+# @--no-user-config:
+# !texinfo
+# -no-user-config@*
+# The @code{-no-user-config} option makes QEMU not load any of the user-provided
+# config files on @var{sysconfdir}, but won't make it skip the QEMU-provided config
+# files from @var{datadir}.
+# !end texinfo
+##
+{ 'option': '--no-user-config',
+  'help': [
+"-no-user-config",
+"                do not load user-provided config files at startup"] }
+
+##
+# @--trace:
+# !texinfo
+# HXCOMM This line is not accurate, as some sub-options are backend-specific but
+# HXCOMM HX does not support conditional compilation of text.
+# -trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]@*
+# @include qemu-option-trace.texi
+# !end texinfo
+##
+{ 'option': '--trace',
+  'data': 'str',                # FIXME QAPIfy trace_opt_parse()
+  'help': [
+"-trace [[enable=]<pattern>][,events=<file>][,file=<file>]",
+"                specify tracing options"] }
+
+##
+# @--qtest:
+##
+{ 'option': '--qtest',
+  'data': 'str',                # FIXME QAPIfy qemu_chr_new()
+  'help': null }
+
+##
+# @--qtest-log:
+##
+{ 'option': '--qtest-log',
+  'data': 'str',
+  'help': null }
+
+##
+# @--enable-fips:
+# !texinfo
+# -enable-fips@*
+# Enable FIPS 140-2 compliance mode.
+# !end texinfo
+##
+{ 'option': '--enable-fips',
+  'help': "-enable-fips    enable FIPS 140-2 compliance" }
+
+##
+# @--no-kvm:
+##
+# TODO deprecate
+{ 'option': '--no-kvm',
+  'help': null }
+
+##
+# @--no-kvm-pit-reinjection:
+##
+# TODO deprecate
+{ 'option': '--no-kvm-pit-reinjection',
+  'help': null }
+
+##
+# @--no-kvm-pit:
+##
+# TODO deprecate
+{ 'option': '--no-kvm-pit',
+  'help': null }
+
+##
+# @--no-kvm-irqchip:
+##
+# TODO deprecate
+{ 'option': '--no-kvm-irqchip',
+  'help': null }
+
+##
+# @--tdf:
+##
+# TODO deprecate
+{ 'option': '--tdf',
+  'help': null }
+
+##
+# @--msg:
+# !texinfo
+# -msg timestamp[=on|off]@*
+# prepend a timestamp to each log message.(default:on)
+# !end texinfo
+##
+{ 'option': '--msg',
+  'data': 'str',                # FIXME QAPIfy qemu_msg_opts
+  'help': [
+"-msg timestamp[=on|off]",
+"                change the format of messages",
+"                on|off controls leading timestamps (default:on)"] }
+
+##
+# @--dump-vmstate:
+# !texinfo
+# -dump-vmstate @var{file}@*
+# Dump json-encoded vmstate information for current machine type to file
+# in @var{file}
+# !end texinfo
+##
+{ 'option': '--dump-vmstate',
+  'data': 'str',
+  'help': [
+"-dump-vmstate <file>",
+"                Output vmstate information in JSON format to file.",
+"                Use the scripts/vmstate-static-checker.py file to",
+"                check for possible regressions in migration code",
+"                by comparing two such vmstate dumps."] }
+
+##
+# == Generic object creation
+##
+
+##
+# @--object:
+# !texinfo
+# -object @var{typename}[,@var{prop1}=@var{value1},...]@*
+# Create a new object of type @var{typename} setting properties
+# in the order they are specified.  Note that the 'id'
+# property must be set.  These objects are placed in the
+# '/objects' path.
+#
+# @table @option
+#
+# @item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off},discard-data=@var{on|off}
+#
+# Creates a memory file backend object, which can be used to back
+# the guest RAM with huge pages. The @option{id} parameter is a
+# unique ID that will be used to reference this memory region
+# when configuring the @option{-numa} argument. The @option{size}
+# option provides the size of the memory region, and accepts
+# common suffixes, eg @option{500M}. The @option{mem-path} provides
+# the path to either a shared memory or huge page filesystem mount.
+# The @option{share} boolean option determines whether the memory
+# region is marked as private to QEMU, or shared. The latter allows
+# a co-operating external process to access the QEMU memory region.
+# Setting the @option{discard-data} boolean option to @var{on}
+# indicates that file contents can be destroyed when QEMU exits,
+# to avoid unnecessarily flushing data to the backing file.  Note
+# that @option{discard-data} is only an optimization, and QEMU
+# might not discard file contents if it aborts unexpectedly or is
+# terminated using SIGKILL.
+#
+# @item -object rng-random,id=@var{id},filename=@var{/dev/random}
+#
+# Creates a random number generator backend which obtains entropy from
+# a device on the host. The @option{id} parameter is a unique ID that
+# will be used to reference this entropy backend from the @option{virtio-rng}
+# device. The @option{filename} parameter specifies which file to obtain
+# entropy from and if omitted defaults to @option{/dev/random}.
+#
+# @item -object rng-egd,id=@var{id},chardev=@var{chardevid}
+#
+# Creates a random number generator backend which obtains entropy from
+# an external daemon running on the host. The @option{id} parameter is
+# a unique ID that will be used to reference this entropy backend from
+# the @option{virtio-rng} device. The @option{chardev} parameter is
+# the unique ID of a character device backend that provides the connection
+# to the RNG daemon.
+#
+# @item -object tls-creds-anon,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/cred/dir},verify-peer=@var{on|off}
+#
+# Creates a TLS anonymous credentials object, which can be used to provide
+# TLS support on network backends. The @option{id} parameter is a unique
+# ID which network backends will use to access the credentials. The
+# @option{endpoint} is either @option{server} or @option{client} depending
+# on whether the QEMU network backend that uses the credentials will be
+# acting as a client or as a server. If @option{verify-peer} is enabled
+# (the default) then once the handshake is completed, the peer credentials
+# will be verified, though this is a no-op for anonymous credentials.
+#
+# The @var{dir} parameter tells QEMU where to find the credential
+# files. For server endpoints, this directory may contain a file
+# @var{dh-params.pem} providing diffie-hellman parameters to use
+# for the TLS server. If the file is missing, QEMU will generate
+# a set of DH parameters at startup. This is a computationally
+# expensive operation that consumes random pool entropy, so it is
+# recommended that a persistent set of parameters be generated
+# upfront and saved.
+#
+# @item -object tls-creds-x509,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/cred/dir},verify-peer=@var{on|off},passwordid=@var{id}
+#
+# Creates a TLS anonymous credentials object, which can be used to provide
+# TLS support on network backends. The @option{id} parameter is a unique
+# ID which network backends will use to access the credentials. The
+# @option{endpoint} is either @option{server} or @option{client} depending
+# on whether the QEMU network backend that uses the credentials will be
+# acting as a client or as a server. If @option{verify-peer} is enabled
+# (the default) then once the handshake is completed, the peer credentials
+# will be verified. With x509 certificates, this implies that the clients
+# must be provided with valid client certificates too.
+#
+# The @var{dir} parameter tells QEMU where to find the credential
+# files. For server endpoints, this directory may contain a file
+# @var{dh-params.pem} providing diffie-hellman parameters to use
+# for the TLS server. If the file is missing, QEMU will generate
+# a set of DH parameters at startup. This is a computationally
+# expensive operation that consumes random pool entropy, so it is
+# recommended that a persistent set of parameters be generated
+# upfront and saved.
+#
+# For x509 certificate credentials the directory will contain further files
+# providing the x509 certificates. The certificates must be stored
+# in PEM format, in filenames @var{ca-cert.pem}, @var{ca-crl.pem} (optional),
+# @var{server-cert.pem} (only servers), @var{server-key.pem} (only servers),
+# @var{client-cert.pem} (only clients), and @var{client-key.pem} (only clients).
+#
+# For the @var{server-key.pem} and @var{client-key.pem} files which
+# contain sensitive private keys, it is possible to use an encrypted
+# version by providing the @var{passwordid} parameter. This provides
+# the ID of a previously created @code{secret} object containing the
+# password for decryption.
+#
+# @item -object filter-buffer,id=@var{id},netdev=@var{netdevid},interval=@var{t}[,queue=@var{all|rx|tx}][,status=@var{on|off}]
+#
+# Interval @var{t} can't be 0, this filter batches the packet delivery: all
+# packets arriving in a given interval on netdev @var{netdevid} are delayed
+# until the end of the interval. Interval is in microseconds.
+# @option{status} is optional that indicate whether the netfilter is
+# on (enabled) or off (disabled), the default status for netfilter will be 'on'.
+#
+# queue @var{all|rx|tx} is an option that can be applied to any netfilter.
+#
+# @option{all}: the filter is attached both to the receive and the transmit
+#               queue of the netdev (default).
+#
+# @option{rx}: the filter is attached to the receive queue of the netdev,
+#              where it will receive packets sent to the netdev.
+#
+# @option{tx}: the filter is attached to the transmit queue of the netdev,
+#              where it will receive packets sent by the netdev.
+#
+# @item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
+#
+# filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len.
+#
+# @item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
+#
+# filter-redirector on netdev @var{netdevid},redirect filter's net packet to chardev
+# @var{chardevid},and redirect indev's packet to filter.if it has the vnet_hdr_support flag,
+# filter-redirector will redirect packet with vnet_hdr_len.
+# Create a filter-redirector we need to differ outdev id from indev id, id can not
+# be the same. we can just use indev or outdev, but at least one of indev or outdev
+# need to be specified.
+#
+# @item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},queue=@var{all|rx|tx},[vnet_hdr_support]
+#
+# Filter-rewriter is a part of COLO project.It will rewrite tcp packet to
+# secondary from primary to keep secondary tcp connection,and rewrite
+# tcp packet to primary from secondary make tcp packet can be handled by
+# client.if it has the vnet_hdr_support flag, we can parse packet with vnet header.
+#
+# usage:
+# colo secondary:
+# -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
+# -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
+# -object filter-rewriter,id=rew0,netdev=hn0,queue=all
+#
+# @item -object filter-dump,id=@var{id},netdev=@var{dev}[,file=@var{filename}][,maxlen=@var{len}]
+#
+# Dump the network traffic on netdev @var{dev} to the file specified by
+# @var{filename}. At most @var{len} bytes (64k by default) per packet are stored.
+# The file format is libpcap, so it can be analyzed with tools such as tcpdump
+# or Wireshark.
+#
+# @item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid}[,vnet_hdr_support]
+#
+# Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with
+# secondary packet. If the packets are same, we will output primary
+# packet to outdev@var{chardevid}, else we will notify colo-frame
+# do checkpoint and send primary packet to outdev@var{chardevid}.
+# if it has the vnet_hdr_support flag, colo compare will send/recv packet with vnet_hdr_len.
+#
+# we must use it with the help of filter-mirror and filter-redirector.
+#
+# @example
+#
+# primary:
+# -netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
+# -device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
+# -chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait
+# -chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait
+# -chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait
+# -chardev socket,id=compare0-0,host=3.3.3.3,port=9001
+# -chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
+# -chardev socket,id=compare_out0,host=3.3.3.3,port=9005
+# -object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
+# -object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
+# -object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
+# -object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0
+#
+# secondary:
+# -netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
+# -device e1000,netdev=hn0,mac=52:a4:00:12:78:66
+# -chardev socket,id=red0,host=3.3.3.3,port=9003
+# -chardev socket,id=red1,host=3.3.3.3,port=9004
+# -object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
+# -object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
+#
+# @end example
+#
+# If you want to know the detail of above command line, you can read
+# the colo-compare git log.
+#
+# @item -object cryptodev-backend-builtin,id=@var{id}[,queues=@var{queues}]
+#
+# Creates a cryptodev backend which executes crypto opreation from
+# the QEMU cipher APIS. The @var{id} parameter is
+# a unique ID that will be used to reference this cryptodev backend from
+# the @option{virtio-crypto} device. The @var{queues} parameter is optional,
+# which specify the queue number of cryptodev backend, the default of
+# @var{queues} is 1.
+#
+# @example
+#
+#  # qemu-system-x86_64 \
+#    [...] \
+#        -object cryptodev-backend-builtin,id=cryptodev0 \
+#        -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 \
+#    [...]
+# @end example
+#
+# @item -object secret,id=@var{id},data=@var{string},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
+# @item -object secret,id=@var{id},file=@var{filename},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
+#
+# Defines a secret to store a password, encryption key, or some other sensitive
+# data. The sensitive data can either be passed directly via the @var{data}
+# parameter, or indirectly via the @var{file} parameter. Using the @var{data}
+# parameter is insecure unless the sensitive data is encrypted.
+#
+# The sensitive data can be provided in raw format (the default), or base64.
+# When encoded as JSON, the raw format only supports valid UTF-8 characters,
+# so base64 is recommended for sending binary data. QEMU will convert from
+# which ever format is provided to the format it needs internally. eg, an
+# RBD password can be provided in raw format, even though it will be base64
+# encoded when passed onto the RBD sever.
+#
+# For added protection, it is possible to encrypt the data associated with
+# a secret using the AES-256-CBC cipher. Use of encryption is indicated
+# by providing the @var{keyid} and @var{iv} parameters. The @var{keyid}
+# parameter provides the ID of a previously defined secret that contains
+# the AES-256 decryption key. This key should be 32-bytes long and be
+# base64 encoded. The @var{iv} parameter provides the random initialization
+# vector used for encryption of this particular secret and should be a
+# base64 encrypted string of the 16-byte IV.
+#
+# The simplest (insecure) usage is to provide the secret inline
+#
+# @example
+#
+#  # $QEMU -object secret,id=sec0,data=letmein,format=raw
+#
+# @end example
+#
+# The simplest secure usage is to provide the secret via a file
+#
+#  # printf "letmein" > mypasswd.txt
+#  # $QEMU -object secret,id=sec0,file=mypasswd.txt,format=raw
+#
+# For greater security, AES-256-CBC should be used. To illustrate usage,
+# consider the openssl command line tool which can encrypt the data. Note
+# that when encrypting, the plaintext must be padded to the cipher block
+# size (32 bytes) using the standard PKCS#5/6 compatible padding algorithm.
+#
+# First a master key needs to be created in base64 encoding:
+#
+# @example
+#  # openssl rand -base64 32 > key.b64
+#  # KEY=$(base64 -d key.b64 | hexdump  -v -e '/1 "%02X"')
+# @end example
+#
+# Each secret to be encrypted needs to have a random initialization vector
+# generated. These do not need to be kept secret
+#
+# @example
+#  # openssl rand -base64 16 > iv.b64
+#  # IV=$(base64 -d iv.b64 | hexdump  -v -e '/1 "%02X"')
+# @end example
+#
+# The secret to be defined can now be encrypted, in this case we're
+# telling openssl to base64 encode the result, but it could be left
+# as raw bytes if desired.
+#
+# @example
+#  # SECRET=$(printf "letmein" |
+#             openssl enc -aes-256-cbc -a -K $KEY -iv $IV)
+# @end example
+#
+# When launching QEMU, create a master secret pointing to @code{key.b64}
+# and specify that to be used to decrypt the user password. Pass the
+# contents of @code{iv.b64} to the second secret
+#
+# @example
+#  # $QEMU \
+#      -object secret,id=secmaster0,format=base64,file=key.b64 \
+#      -object secret,id=sec0,keyid=secmaster0,format=base64,\
+#          data=$SECRET,iv=$(<iv.b64)
+# @end example
+#
+# @end table
+# !end texinfo
+##
+{ 'option': '--object',
+  'data': 'str',                # FIXME QAPIfy qemu_object_opts: object_add
+  'help': [
+"-object TYPENAME[,PROP1=VALUE1,...]",
+"                create a new object of type TYPENAME setting properties",
+"                in the order they are specified.  Note that the 'id'",
+"                property must be set.  These objects are placed in the",
+"                '/objects' path."] }
diff --git a/qemu-doc.texi b/qemu-doc.texi
index 848e49966a..57223e2dc3 100644
--- a/qemu-doc.texi
+++ b/qemu-doc.texi
@@ -241,7 +241,7 @@ Linux should boot and give you a prompt.
 @var{disk_image} is a raw hard disk image for IDE hard disk 0. Some
 targets do not need a disk image.
 
-@include qemu-options.texi
+FIXME include options part of docs/interop/qemu-qmp-qapi.texi
 
 @c man end
 
@@ -968,7 +968,7 @@ useful yet as it was with the legacy @code{-usbdevice} option. So to
 configure an USB bluetooth device, you might need to use
 "@code{-usbdevice bt}[:@var{hci-type}]" instead. This configures a
 bluetooth dongle whose type is specified in the same format as with
-the @option{-bt hci} option, @pxref{bt-hcis,,allowed HCI types}.  If
+the @option{-bt hci} option, FIXME @@pxref@{bt-hcis,,allowed HCI types@}.  If
 no type is given, the HCI logic corresponds to @code{-bt hci,vlan=0}.
 This USB device implements the USB Transport Layer of HCI.  Example
 usage:
diff --git a/qemu-options-wrapper.h b/qemu-options-wrapper.h
deleted file mode 100644
index 13bfea0294..0000000000
--- a/qemu-options-wrapper.h
+++ /dev/null
@@ -1,41 +0,0 @@
-
-#if defined(QEMU_OPTIONS_GENERATE_ENUM)
-
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)     \
-    opt_enum,
-#define DEFHEADING(text)
-#define ARCHHEADING(text, arch_mask)
-
-#elif defined(QEMU_OPTIONS_GENERATE_HELP)
-
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)    \
-    if ((arch_mask) & arch_type)                               \
-        fputs(opt_help, stdout);
-
-#define ARCHHEADING(text, arch_mask) \
-    if ((arch_mask) & arch_type)    \
-        puts(stringify(text));
-
-#define DEFHEADING(text) ARCHHEADING(text, QEMU_ARCH_ALL)
-
-#elif defined(QEMU_OPTIONS_GENERATE_OPTIONS)
-
-#define DEF(option, opt_arg, opt_enum, opt_help, arch_mask)     \
-    { option, opt_arg, opt_enum, arch_mask },
-#define DEFHEADING(text)
-#define ARCHHEADING(text, arch_mask)
-
-#else
-#error "qemu-options-wrapper.h included with no option defined"
-#endif
-
-#include "qemu-options.def"
-
-#undef DEF
-#undef DEFHEADING
-#undef ARCHHEADING
-#undef GEN_DOCS
-
-#undef QEMU_OPTIONS_GENERATE_ENUM
-#undef QEMU_OPTIONS_GENERATE_HELP
-#undef QEMU_OPTIONS_GENERATE_OPTIONS
diff --git a/qemu-options.h b/qemu-options.h
deleted file mode 100644
index b4ee63cd60..0000000000
--- a/qemu-options.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * qemu-options.h
- *
- * Defines needed for command line argument processing.
- *
- * Copyright (c) 2003-2008 Fabrice Bellard
- * Copyright (c) 2010 Jes Sorensen <Jes.Sorensen@redhat.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-#ifndef QEMU_OPTIONS_H
-#define QEMU_OPTIONS_H
-
-enum {
-#define QEMU_OPTIONS_GENERATE_ENUM
-#include "qemu-options-wrapper.h"
-};
-
-#endif
diff --git a/qemu-options.hx b/qemu-options.hx
deleted file mode 100644
index 32afc11296..0000000000
--- a/qemu-options.hx
+++ /dev/null
@@ -1,4256 +0,0 @@
-HXCOMM Use DEFHEADING() to define headings in both help text and texi
-HXCOMM Text between STEXI and ETEXI are copied to texi version and
-HXCOMM discarded from C version
-HXCOMM DEF(option, HAS_ARG/0, opt_enum, opt_help, arch_mask) is used to
-HXCOMM construct option structures, enums and help message for specified
-HXCOMM architectures.
-HXCOMM HXCOMM can be used for comments, discarded from both texi and C
-
-DEFHEADING(Standard options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("help", 0, QEMU_OPTION_h,
-    "-h or -help     display this help and exit\n", QEMU_ARCH_ALL)
-STEXI
-@item -h
-@findex -h
-Display help and exit
-ETEXI
-
-DEF("version", 0, QEMU_OPTION_version,
-    "-version        display version information and exit\n", QEMU_ARCH_ALL)
-STEXI
-@item -version
-@findex -version
-Display version information and exit
-ETEXI
-
-DEF("machine", HAS_ARG, QEMU_OPTION_machine, \
-    "-machine [type=]name[,prop[=value][,...]]\n"
-    "                selects emulated machine ('-machine help' for list)\n"
-    "                property accel=accel1[:accel2[:...]] selects accelerator\n"
-    "                supported accelerators are kvm, xen, hax or tcg (default: tcg)\n"
-    "                kernel_irqchip=on|off|split controls accelerated irqchip support (default=off)\n"
-    "                vmport=on|off|auto controls emulation of vmport (default: auto)\n"
-    "                kvm_shadow_mem=size of KVM shadow MMU in bytes\n"
-    "                dump-guest-core=on|off include guest memory in a core dump (default=on)\n"
-    "                mem-merge=on|off controls memory merge support (default: on)\n"
-    "                igd-passthru=on|off controls IGD GFX passthrough support (default=off)\n"
-    "                aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n"
-    "                dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n"
-    "                suppress-vmdesc=on|off disables self-describing migration (default=off)\n"
-    "                nvdimm=on|off controls NVDIMM support (default=off)\n"
-    "                enforce-config-section=on|off enforce configuration section migration (default=off)\n"
-    "                s390-squash-mcss=on|off controls support for squashing into default css (default=off)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -machine [type=]@var{name}[,prop=@var{value}[,...]]
-@findex -machine
-Select the emulated machine by @var{name}. Use @code{-machine help} to list
-available machines.
-
-For architectures which aim to support live migration compatibility
-across releases, each release will introduce a new versioned machine
-type. For example, the 2.8.0 release introduced machine types
-``pc-i440fx-2.8'' and ``pc-q35-2.8'' for the x86_64/i686 architectures.
-
-To allow live migration of guests from QEMU version 2.8.0, to QEMU
-version 2.9.0, the 2.9.0 version must support the ``pc-i440fx-2.8''
-and ``pc-q35-2.8'' machines too. To allow users live migrating VMs
-to skip multiple intermediate releases when upgrading, new releases
-of QEMU will support machine types from many previous versions.
-
-Supported machine properties are:
-@table @option
-@item accel=@var{accels1}[:@var{accels2}[:...]]
-This is used to enable an accelerator. Depending on the target architecture,
-kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
-more than one accelerator specified, the next one is used if the previous one
-fails to initialize.
-@item kernel_irqchip=on|off
-Controls in-kernel irqchip support for the chosen accelerator when available.
-@item gfx_passthru=on|off
-Enables IGD GFX passthrough support for the chosen machine when available.
-@item vmport=on|off|auto
-Enables emulation of VMWare IO port, for vmmouse etc. auto says to select the
-value based on accel. For accel=xen the default is off otherwise the default
-is on.
-@item kvm_shadow_mem=size
-Defines the size of the KVM shadow MMU.
-@item dump-guest-core=on|off
-Include guest memory in a core dump. The default is on.
-@item mem-merge=on|off
-Enables or disables memory merge support. This feature, when supported by
-the host, de-duplicates identical memory pages among VMs instances
-(enabled by default).
-@item aes-key-wrap=on|off
-Enables or disables AES key wrapping support on s390-ccw hosts. This feature
-controls whether AES wrapping keys will be created to allow
-execution of AES cryptographic functions.  The default is on.
-@item dea-key-wrap=on|off
-Enables or disables DEA key wrapping support on s390-ccw hosts. This feature
-controls whether DEA wrapping keys will be created to allow
-execution of DEA cryptographic functions.  The default is on.
-@item nvdimm=on|off
-Enables or disables NVDIMM support. The default is off.
-@item s390-squash-mcss=on|off
-Enables or disables squashing subchannels into the default css.
-The default is off.
-@item enforce-config-section=on|off
-If @option{enforce-config-section} is set to @var{on}, force migration
-code to send configuration section even if the machine-type sets the
-@option{migration.send-configuration} property to @var{off}.
-NOTE: this parameter is deprecated. Please use @option{-global}
-@option{migration.send-configuration}=@var{on|off} instead.
-@end table
-ETEXI
-
-HXCOMM Deprecated by -machine
-DEF("M", HAS_ARG, QEMU_OPTION_M, "", QEMU_ARCH_ALL)
-
-DEF("cpu", HAS_ARG, QEMU_OPTION_cpu,
-    "-cpu cpu        select CPU ('-cpu help' for list)\n", QEMU_ARCH_ALL)
-STEXI
-@item -cpu @var{model}
-@findex -cpu
-Select CPU model (@code{-cpu help} for list and additional feature selection)
-ETEXI
-
-DEF("accel", HAS_ARG, QEMU_OPTION_accel,
-    "-accel [accel=]accelerator[,thread=single|multi]\n"
-    "                select accelerator (kvm, xen, hax or tcg; use 'help' for a list)\n"
-    "                thread=single|multi (enable multi-threaded TCG)\n", QEMU_ARCH_ALL)
-STEXI
-@item -accel @var{name}[,prop=@var{value}[,...]]
-@findex -accel
-This is used to enable an accelerator. Depending on the target architecture,
-kvm, xen, hax or tcg can be available. By default, tcg is used. If there is
-more than one accelerator specified, the next one is used if the previous one
-fails to initialize.
-@table @option
-@item thread=single|multi
-Controls number of TCG threads. When the TCG is multi-threaded there will be one
-thread per vCPU therefor taking advantage of additional host cores. The default
-is to enable multi-threading where both the back-end and front-ends support it and
-no incompatible TCG features have been enabled (e.g. icount/replay).
-@end table
-ETEXI
-
-DEF("smp", HAS_ARG, QEMU_OPTION_smp,
-    "-smp [cpus=]n[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]\n"
-    "                set the number of CPUs to 'n' [default=1]\n"
-    "                maxcpus= maximum number of total cpus, including\n"
-    "                offline CPUs for hotplug, etc\n"
-    "                cores= number of CPU cores on one socket\n"
-    "                threads= number of threads on one CPU core\n"
-    "                sockets= number of discrete sockets in the system\n",
-        QEMU_ARCH_ALL)
-STEXI
-@item -smp [cpus=]@var{n}[,cores=@var{cores}][,threads=@var{threads}][,sockets=@var{sockets}][,maxcpus=@var{maxcpus}]
-@findex -smp
-Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
-CPUs are supported. On Sparc32 target, Linux limits the number of usable CPUs
-to 4.
-For the PC target, the number of @var{cores} per socket, the number
-of @var{threads} per cores and the total number of @var{sockets} can be
-specified. Missing values will be computed. If any on the three values is
-given, the total number of CPUs @var{n} can be omitted. @var{maxcpus}
-specifies the maximum number of hotpluggable CPUs.
-ETEXI
-
-DEF("numa", HAS_ARG, QEMU_OPTION_numa,
-    "-numa node[,mem=size][,cpus=firstcpu[-lastcpu]][,nodeid=node]\n"
-    "-numa node[,memdev=id][,cpus=firstcpu[-lastcpu]][,nodeid=node]\n"
-    "-numa dist,src=source,dst=destination,val=distance\n", QEMU_ARCH_ALL)
-STEXI
-@item -numa node[,mem=@var{size}][,cpus=@var{firstcpu}[-@var{lastcpu}]][,nodeid=@var{node}]
-@itemx -numa node[,memdev=@var{id}][,cpus=@var{firstcpu}[-@var{lastcpu}]][,nodeid=@var{node}]
-@itemx -numa dist,src=@var{source},dst=@var{destination},val=@var{distance}
-@itemx -numa cpu,node-id=@var{node}[,socket-id=@var{x}][,core-id=@var{y}][,thread-id=@var{z}]
-@findex -numa
-Define a NUMA node and assign RAM and VCPUs to it.
-Set the NUMA distance from a source node to a destination node.
-
-Legacy VCPU assignment uses @samp{cpus} option where
-@var{firstcpu} and @var{lastcpu} are CPU indexes. Each
-@samp{cpus} option represent a contiguous range of CPU indexes
-(or a single VCPU if @var{lastcpu} is omitted). A non-contiguous
-set of VCPUs can be represented by providing multiple @samp{cpus}
-options. If @samp{cpus} is omitted on all nodes, VCPUs are automatically
-split between them.
-
-For example, the following option assigns VCPUs 0, 1, 2 and 5 to
-a NUMA node:
-@example
--numa node,cpus=0-2,cpus=5
-@end example
-
-@samp{cpu} option is a new alternative to @samp{cpus} option
-which uses @samp{socket-id|core-id|thread-id} properties to assign
-CPU objects to a @var{node} using topology layout properties of CPU.
-The set of properties is machine specific, and depends on used
-machine type/@samp{smp} options. It could be queried with
-@samp{hotpluggable-cpus} monitor command.
-@samp{node-id} property specifies @var{node} to which CPU object
-will be assigned, it's required for @var{node} to be declared
-with @samp{node} option before it's used with @samp{cpu} option.
-
-For example:
-@example
--M pc \
--smp 1,sockets=2,maxcpus=2 \
--numa node,nodeid=0 -numa node,nodeid=1 \
--numa cpu,node-id=0,socket-id=0 -numa cpu,node-id=1,socket-id=1
-@end example
-
-@samp{mem} assigns a given RAM amount to a node. @samp{memdev}
-assigns RAM from a given memory backend device to a node. If
-@samp{mem} and @samp{memdev} are omitted in all nodes, RAM is
-split equally between them.
-
-@samp{mem} and @samp{memdev} are mutually exclusive. Furthermore,
-if one node uses @samp{memdev}, all of them have to use it.
-
-@var{source} and @var{destination} are NUMA node IDs.
-@var{distance} is the NUMA distance from @var{source} to @var{destination}.
-The distance from a node to itself is always 10. If any pair of nodes is
-given a distance, then all pairs must be given distances. Although, when
-distances are only given in one direction for each pair of nodes, then
-the distances in the opposite directions are assumed to be the same. If,
-however, an asymmetrical pair of distances is given for even one node
-pair, then all node pairs must be provided distance values for both
-directions, even when they are symmetrical. When a node is unreachable
-from another node, set the pair's distance to 255.
-
-Note that the -@option{numa} option doesn't allocate any of the
-specified resources, it just assigns existing resources to NUMA
-nodes. This means that one still has to use the @option{-m},
-@option{-smp} options to allocate RAM and VCPUs respectively.
-
-ETEXI
-
-DEF("add-fd", HAS_ARG, QEMU_OPTION_add_fd,
-    "-add-fd fd=fd,set=set[,opaque=opaque]\n"
-    "                Add 'fd' to fd 'set'\n", QEMU_ARCH_ALL)
-STEXI
-@item -add-fd fd=@var{fd},set=@var{set}[,opaque=@var{opaque}]
-@findex -add-fd
-
-Add a file descriptor to an fd set.  Valid options are:
-
-@table @option
-@item fd=@var{fd}
-This option defines the file descriptor of which a duplicate is added to fd set.
-The file descriptor cannot be stdin, stdout, or stderr.
-@item set=@var{set}
-This option defines the ID of the fd set to add the file descriptor to.
-@item opaque=@var{opaque}
-This option defines a free-form string that can be used to describe @var{fd}.
-@end table
-
-You can open an image using pre-opened file descriptors from an fd set:
-@example
-qemu-system-i386
--add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
--add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
--drive file=/dev/fdset/2,index=0,media=disk
-@end example
-ETEXI
-
-DEF("set", HAS_ARG, QEMU_OPTION_set,
-    "-set group.id.arg=value\n"
-    "                set <arg> parameter for item <id> of type <group>\n"
-    "                i.e. -set drive.$id.file=/path/to/image\n", QEMU_ARCH_ALL)
-STEXI
-@item -set @var{group}.@var{id}.@var{arg}=@var{value}
-@findex -set
-Set parameter @var{arg} for item @var{id} of type @var{group}
-ETEXI
-
-DEF("global", HAS_ARG, QEMU_OPTION_global,
-    "-global driver.property=value\n"
-    "-global driver=driver,property=property,value=value\n"
-    "                set a global default for a driver property\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -global @var{driver}.@var{prop}=@var{value}
-@itemx -global driver=@var{driver},property=@var{property},value=@var{value}
-@findex -global
-Set default value of @var{driver}'s property @var{prop} to @var{value}, e.g.:
-
-@example
-qemu-system-i386 -global ide-hd.physical_block_size=4096 disk-image.img
-@end example
-
-In particular, you can use this to set driver properties for devices which are
-created automatically by the machine model. To create a device which is not
-created automatically and set properties on it, use -@option{device}.
-
--global @var{driver}.@var{prop}=@var{value} is shorthand for -global
-driver=@var{driver},property=@var{prop},value=@var{value}.  The
-longhand syntax works even when @var{driver} contains a dot.
-ETEXI
-
-DEF("boot", HAS_ARG, QEMU_OPTION_boot,
-    "-boot [order=drives][,once=drives][,menu=on|off]\n"
-    "      [,splash=sp_name][,splash-time=sp_time][,reboot-timeout=rb_time][,strict=on|off]\n"
-    "                'drives': floppy (a), hard disk (c), CD-ROM (d), network (n)\n"
-    "                'sp_name': the file's name that would be passed to bios as logo picture, if menu=on\n"
-    "                'sp_time': the period that splash picture last if menu=on, unit is ms\n"
-    "                'rb_timeout': the timeout before guest reboot when boot failed, unit is ms\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -boot [order=@var{drives}][,once=@var{drives}][,menu=on|off][,splash=@var{sp_name}][,splash-time=@var{sp_time}][,reboot-timeout=@var{rb_timeout}][,strict=on|off]
-@findex -boot
-Specify boot order @var{drives} as a string of drive letters. Valid
-drive letters depend on the target architecture. The x86 PC uses: a, b
-(floppy 1 and 2), c (first hard disk), d (first CD-ROM), n-p (Etherboot
-from network adapter 1-4), hard disk boot is the default. To apply a
-particular boot order only on the first startup, specify it via
-@option{once}. Note that the @option{order} or @option{once} parameter
-should not be used together with the @option{bootindex} property of
-devices, since the firmware implementations normally do not support both
-at the same time.
-
-Interactive boot menus/prompts can be enabled via @option{menu=on} as far
-as firmware/BIOS supports them. The default is non-interactive boot.
-
-A splash picture could be passed to bios, enabling user to show it as logo,
-when option splash=@var{sp_name} is given and menu=on, If firmware/BIOS
-supports them. Currently Seabios for X86 system support it.
-limitation: The splash file could be a jpeg file or a BMP file in 24 BPP
-format(true color). The resolution should be supported by the SVGA mode, so
-the recommended is 320x240, 640x480, 800x640.
-
-A timeout could be passed to bios, guest will pause for @var{rb_timeout} ms
-when boot failed, then reboot. If @var{rb_timeout} is '-1', guest will not
-reboot, qemu passes '-1' to bios by default. Currently Seabios for X86
-system support it.
-
-Do strict boot via @option{strict=on} as far as firmware/BIOS
-supports it. This only effects when boot priority is changed by
-bootindex options. The default is non-strict boot.
-
-@example
-# try to boot from network first, then from hard disk
-qemu-system-i386 -boot order=nc
-# boot from CD-ROM first, switch back to default order after reboot
-qemu-system-i386 -boot once=d
-# boot with a splash picture for 5 seconds.
-qemu-system-i386 -boot menu=on,splash=/root/boot.bmp,splash-time=5000
-@end example
-
-Note: The legacy format '-boot @var{drives}' is still supported but its
-use is discouraged as it may be removed from future versions.
-ETEXI
-
-DEF("m", HAS_ARG, QEMU_OPTION_m,
-    "-m [size=]megs[,slots=n,maxmem=size]\n"
-    "                configure guest RAM\n"
-    "                size: initial amount of guest memory\n"
-    "                slots: number of hotplug slots (default: none)\n"
-    "                maxmem: maximum amount of guest memory (default: none)\n"
-    "NOTE: Some architectures might enforce a specific granularity\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -m [size=]@var{megs}[,slots=n,maxmem=size]
-@findex -m
-Sets guest startup RAM size to @var{megs} megabytes. Default is 128 MiB.
-Optionally, a suffix of ``M'' or ``G'' can be used to signify a value in
-megabytes or gigabytes respectively. Optional pair @var{slots}, @var{maxmem}
-could be used to set amount of hotpluggable memory slots and maximum amount of
-memory. Note that @var{maxmem} must be aligned to the page size.
-
-For example, the following command-line sets the guest startup RAM size to
-1GB, creates 3 slots to hotplug additional memory and sets the maximum
-memory the guest can reach to 4GB:
-
-@example
-qemu-system-x86_64 -m 1G,slots=3,maxmem=4G
-@end example
-
-If @var{slots} and @var{maxmem} are not specified, memory hotplug won't
-be enabled and the guest startup RAM will never increase.
-ETEXI
-
-DEF("mem-path", HAS_ARG, QEMU_OPTION_mempath,
-    "-mem-path FILE  provide backing storage for guest RAM\n", QEMU_ARCH_ALL)
-STEXI
-@item -mem-path @var{path}
-@findex -mem-path
-Allocate guest RAM from a temporarily created file in @var{path}.
-ETEXI
-
-DEF("mem-prealloc", 0, QEMU_OPTION_mem_prealloc,
-    "-mem-prealloc   preallocate guest memory (use with -mem-path)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -mem-prealloc
-@findex -mem-prealloc
-Preallocate memory when using -mem-path.
-ETEXI
-
-DEF("k", HAS_ARG, QEMU_OPTION_k,
-    "-k language     use keyboard layout (for example 'fr' for French)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -k @var{language}
-@findex -k
-Use keyboard layout @var{language} (for example @code{fr} for
-French). This option is only needed where it is not easy to get raw PC
-keycodes (e.g. on Macs, with some X11 servers or with a VNC or curses
-display). You don't normally need to use it on PC/Linux or PC/Windows
-hosts.
-
-The available layouts are:
-@example
-ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
-da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
-de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
-@end example
-
-The default is @code{en-us}.
-ETEXI
-
-
-DEF("audio-help", 0, QEMU_OPTION_audio_help,
-    "-audio-help     print list of audio drivers and their options\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -audio-help
-@findex -audio-help
-Will show the audio subsystem help: list of drivers, tunable
-parameters.
-ETEXI
-
-DEF("soundhw", HAS_ARG, QEMU_OPTION_soundhw,
-    "-soundhw c1,... enable audio support\n"
-    "                and only specified sound cards (comma separated list)\n"
-    "                use '-soundhw help' to get the list of supported cards\n"
-    "                use '-soundhw all' to enable all of them\n", QEMU_ARCH_ALL)
-STEXI
-@item -soundhw @var{card1}[,@var{card2},...] or -soundhw all
-@findex -soundhw
-Enable audio and selected sound hardware. Use 'help' to print all
-available sound hardware.
-
-@example
-qemu-system-i386 -soundhw sb16,adlib disk.img
-qemu-system-i386 -soundhw es1370 disk.img
-qemu-system-i386 -soundhw ac97 disk.img
-qemu-system-i386 -soundhw hda disk.img
-qemu-system-i386 -soundhw all disk.img
-qemu-system-i386 -soundhw help
-@end example
-
-Note that Linux's i810_audio OSS kernel (for AC97) module might
-require manually specifying clocking.
-
-@example
-modprobe i810_audio clocking=48000
-@end example
-ETEXI
-
-DEF("balloon", HAS_ARG, QEMU_OPTION_balloon,
-    "-balloon none   disable balloon device\n"
-    "-balloon virtio[,addr=str]\n"
-    "                enable virtio balloon device (default)\n", QEMU_ARCH_ALL)
-STEXI
-@item -balloon none
-@findex -balloon
-Disable balloon device.
-@item -balloon virtio[,addr=@var{addr}]
-Enable virtio balloon device (default), optionally with PCI address
-@var{addr}.
-ETEXI
-
-DEF("device", HAS_ARG, QEMU_OPTION_device,
-    "-device driver[,prop[=value][,...]]\n"
-    "                add device (based on driver)\n"
-    "                prop=value,... sets driver properties\n"
-    "                use '-device help' to print all possible drivers\n"
-    "                use '-device driver,help' to print all possible properties\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -device @var{driver}[,@var{prop}[=@var{value}][,...]]
-@findex -device
-Add device @var{driver}.  @var{prop}=@var{value} sets driver
-properties.  Valid properties depend on the driver.  To get help on
-possible drivers and properties, use @code{-device help} and
-@code{-device @var{driver},help}.
-
-Some drivers are:
-@item -device ipmi-bmc-sim,id=@var{id}[,slave_addr=@var{val}][,sdrfile=@var{file}][,furareasize=@var{val}][,furdatafile=@var{file}]
-
-Add an IPMI BMC.  This is a simulation of a hardware management
-interface processor that normally sits on a system.  It provides
-a watchdog and the ability to reset and power control the system.
-You need to connect this to an IPMI interface to make it useful
-
-The IPMI slave address to use for the BMC.  The default is 0x20.
-This address is the BMC's address on the I2C network of management
-controllers.  If you don't know what this means, it is safe to ignore
-it.
-
-@table @option
-@item bmc=@var{id}
-The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
-@item slave_addr=@var{val}
-Define slave address to use for the BMC.  The default is 0x20.
-@item sdrfile=@var{file}
-file containing raw Sensor Data Records (SDR) data. The default is none.
-@item fruareasize=@var{val}
-size of a Field Replaceable Unit (FRU) area.  The default is 1024.
-@item frudatafile=@var{file}
-file containing raw Field Replaceable Unit (FRU) inventory data. The default is none.
-@end table
-
-@item -device ipmi-bmc-extern,id=@var{id},chardev=@var{id}[,slave_addr=@var{val}]
-
-Add a connection to an external IPMI BMC simulator.  Instead of
-locally emulating the BMC like the above item, instead connect
-to an external entity that provides the IPMI services.
-
-A connection is made to an external BMC simulator.  If you do this, it
-is strongly recommended that you use the "reconnect=" chardev option
-to reconnect to the simulator if the connection is lost.  Note that if
-this is not used carefully, it can be a security issue, as the
-interface has the ability to send resets, NMIs, and power off the VM.
-It's best if QEMU makes a connection to an external simulator running
-on a secure port on localhost, so neither the simulator nor QEMU is
-exposed to any outside network.
-
-See the "lanserv/README.vm" file in the OpenIPMI library for more
-details on the external interface.
-
-@item -device isa-ipmi-kcs,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]
-
-Add a KCS IPMI interafce on the ISA bus.  This also adds a
-corresponding ACPI and SMBIOS entries, if appropriate.
-
-@table @option
-@item bmc=@var{id}
-The BMC to connect to, one of ipmi-bmc-sim or ipmi-bmc-extern above.
-@item ioport=@var{val}
-Define the I/O address of the interface.  The default is 0xca0 for KCS.
-@item irq=@var{val}
-Define the interrupt to use.  The default is 5.  To disable interrupts,
-set this to 0.
-@end table
-
-@item -device isa-ipmi-bt,bmc=@var{id}[,ioport=@var{val}][,irq=@var{val}]
-
-Like the KCS interface, but defines a BT interface.  The default port is
-0xe4 and the default interrupt is 5.
-
-ETEXI
-
-DEF("name", HAS_ARG, QEMU_OPTION_name,
-    "-name string1[,process=string2][,debug-threads=on|off]\n"
-    "                set the name of the guest\n"
-    "                string1 sets the window title and string2 the process name (on Linux)\n"
-    "                When debug-threads is enabled, individual threads are given a separate name (on Linux)\n"
-    "                NOTE: The thread names are for debugging and not a stable API.\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -name @var{name}
-@findex -name
-Sets the @var{name} of the guest.
-This name will be displayed in the SDL window caption.
-The @var{name} will also be used for the VNC server.
-Also optionally set the top visible process name in Linux.
-Naming of individual threads can also be enabled on Linux to aid debugging.
-ETEXI
-
-DEF("uuid", HAS_ARG, QEMU_OPTION_uuid,
-    "-uuid %08x-%04x-%04x-%04x-%012x\n"
-    "                specify machine UUID\n", QEMU_ARCH_ALL)
-STEXI
-@item -uuid @var{uuid}
-@findex -uuid
-Set system UUID.
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Block device options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("fda", HAS_ARG, QEMU_OPTION_fda,
-    "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n", QEMU_ARCH_ALL)
-DEF("fdb", HAS_ARG, QEMU_OPTION_fdb, "", QEMU_ARCH_ALL)
-STEXI
-@item -fda @var{file}
-@itemx -fdb @var{file}
-@findex -fda
-@findex -fdb
-Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}).
-ETEXI
-
-DEF("hda", HAS_ARG, QEMU_OPTION_hda,
-    "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image\n", QEMU_ARCH_ALL)
-DEF("hdb", HAS_ARG, QEMU_OPTION_hdb, "", QEMU_ARCH_ALL)
-DEF("hdc", HAS_ARG, QEMU_OPTION_hdc,
-    "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n", QEMU_ARCH_ALL)
-DEF("hdd", HAS_ARG, QEMU_OPTION_hdd, "", QEMU_ARCH_ALL)
-STEXI
-@item -hda @var{file}
-@itemx -hdb @var{file}
-@itemx -hdc @var{file}
-@itemx -hdd @var{file}
-@findex -hda
-@findex -hdb
-@findex -hdc
-@findex -hdd
-Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk_images}).
-ETEXI
-
-DEF("cdrom", HAS_ARG, QEMU_OPTION_cdrom,
-    "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -cdrom @var{file}
-@findex -cdrom
-Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
-@option{-cdrom} at the same time). You can use the host CD-ROM by
-using @file{/dev/cdrom} as filename (@pxref{host_drives}).
-ETEXI
-
-DEF("blockdev", HAS_ARG, QEMU_OPTION_blockdev,
-    "-blockdev [driver=]driver[,node-name=N][,discard=ignore|unmap]\n"
-    "          [,cache.direct=on|off][,cache.no-flush=on|off]\n"
-    "          [,read-only=on|off][,detect-zeroes=on|off|unmap]\n"
-    "          [,driver specific parameters...]\n"
-    "                configure a block backend\n", QEMU_ARCH_ALL)
-STEXI
-@item -blockdev @var{option}[,@var{option}[,@var{option}[,...]]]
-@findex -blockdev
-
-Define a new block driver node. Some of the options apply to all block drivers,
-other options are only accepted for a specific block driver. See below for a
-list of generic options and options for the most common block drivers.
-
-Options that expect a reference to another node (e.g. @code{file}) can be
-given in two ways. Either you specify the node name of an already existing node
-(file=@var{node-name}), or you define a new node inline, adding options
-for the referenced node after a dot (file.filename=@var{path},file.aio=native).
-
-A block driver node created with @option{-blockdev} can be used for a guest
-device by specifying its node name for the @code{drive} property in a
-@option{-device} argument that defines a block device.
-
-@table @option
-@item Valid options for any block driver node:
-
-@table @code
-@item driver
-Specifies the block driver to use for the given node.
-@item node-name
-This defines the name of the block driver node by which it will be referenced
-later. The name must be unique, i.e. it must not match the name of a different
-block driver node, or (if you use @option{-drive} as well) the ID of a drive.
-
-If no node name is specified, it is automatically generated. The generated node
-name is not intended to be predictable and changes between QEMU invocations.
-For the top level, an explicit node name must be specified.
-@item read-only
-Open the node read-only. Guest write attempts will fail.
-@item cache.direct
-The host page cache can be avoided with @option{cache.direct=on}. This will
-attempt to do disk IO directly to the guest's memory. QEMU may still perform an
-internal copy of the data.
-@item cache.no-flush
-In case you don't care about data integrity over host failures, you can use
-@option{cache.no-flush=on}. This option tells QEMU that it never needs to write
-any data to the disk but can instead keep things in cache. If anything goes
-wrong, like your host losing power, the disk storage getting disconnected
-accidentally, etc. your image will most probably be rendered unusable.
-@item discard=@var{discard}
-@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and controls
-whether @code{discard} (also known as @code{trim} or @code{unmap}) requests are
-ignored or passed to the filesystem. Some machine types may not support
-discard requests.
-@item detect-zeroes=@var{detect-zeroes}
-@var{detect-zeroes} is "off", "on" or "unmap" and enables the automatic
-conversion of plain zero writes by the OS to driver specific optimized
-zero write commands. You may even choose "unmap" if @var{discard} is set
-to "unmap" to allow a zero write to be converted to an @code{unmap} operation.
-@end table
-
-@item Driver-specific options for @code{file}
-
-This is the protocol-level block driver for accessing regular files.
-
-@table @code
-@item filename
-The path to the image file in the local filesystem
-@item aio
-Specifies the AIO backend (threads/native, default: threads)
-@end table
-Example:
-@example
--blockdev driver=file,node-name=disk,filename=disk.img
-@end example
-
-@item Driver-specific options for @code{raw}
-
-This is the image format block driver for raw images. It is usually
-stacked on top of a protocol level block driver such as @code{file}.
-
-@table @code
-@item file
-Reference to or definition of the data source block driver node
-(e.g. a @code{file} driver node)
-@end table
-Example 1:
-@example
--blockdev driver=file,node-name=disk_file,filename=disk.img
--blockdev driver=raw,node-name=disk,file=disk_file
-@end example
-Example 2:
-@example
--blockdev driver=raw,node-name=disk,file.driver=file,file.filename=disk.img
-@end example
-
-@item Driver-specific options for @code{qcow2}
-
-This is the image format block driver for qcow2 images. It is usually
-stacked on top of a protocol level block driver such as @code{file}.
-
-@table @code
-@item file
-Reference to or definition of the data source block driver node
-(e.g. a @code{file} driver node)
-
-@item backing
-Reference to or definition of the backing file block device (default is taken
-from the image file). It is allowed to pass an empty string here in order to
-disable the default backing file.
-
-@item lazy-refcounts
-Whether to enable the lazy refcounts feature (on/off; default is taken from the
-image file)
-
-@item cache-size
-The maximum total size of the L2 table and refcount block caches in bytes
-(default: 1048576 bytes or 8 clusters, whichever is larger)
-
-@item l2-cache-size
-The maximum size of the L2 table cache in bytes
-(default: 4/5 of the total cache size)
-
-@item refcount-cache-size
-The maximum size of the refcount block cache in bytes
-(default: 1/5 of the total cache size)
-
-@item cache-clean-interval
-Clean unused entries in the L2 and refcount caches. The interval is in seconds.
-The default value is 0 and it disables this feature.
-
-@item pass-discard-request
-Whether discard requests to the qcow2 device should be forwarded to the data
-source (on/off; default: on if discard=unmap is specified, off otherwise)
-
-@item pass-discard-snapshot
-Whether discard requests for the data source should be issued when a snapshot
-operation (e.g. deleting a snapshot) frees clusters in the qcow2 file (on/off;
-default: on)
-
-@item pass-discard-other
-Whether discard requests for the data source should be issued on other
-occasions where a cluster gets freed (on/off; default: off)
-
-@item overlap-check
-Which overlap checks to perform for writes to the image
-(none/constant/cached/all; default: cached). For details or finer
-granularity control refer to the QAPI documentation of @code{blockdev-add}.
-@end table
-
-Example 1:
-@example
--blockdev driver=file,node-name=my_file,filename=/tmp/disk.qcow2
--blockdev driver=qcow2,node-name=hda,file=my_file,overlap-check=none,cache-size=16777216
-@end example
-Example 2:
-@example
--blockdev driver=qcow2,node-name=disk,file.driver=http,file.filename=http://example.com/image.qcow2
-@end example
-
-@item Driver-specific options for other drivers
-Please refer to the QAPI documentation of the @code{blockdev-add} QMP command.
-
-@end table
-
-ETEXI
-
-DEF("drive", HAS_ARG, QEMU_OPTION_drive,
-    "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
-    "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
-    "       [,cache=writethrough|writeback|none|directsync|unsafe][,format=f]\n"
-    "       [,serial=s][,addr=A][,rerror=ignore|stop|report]\n"
-    "       [,werror=ignore|stop|report|enospc][,id=name][,aio=threads|native]\n"
-    "       [,readonly=on|off][,copy-on-read=on|off]\n"
-    "       [,discard=ignore|unmap][,detect-zeroes=on|off|unmap]\n"
-    "       [[,bps=b]|[[,bps_rd=r][,bps_wr=w]]]\n"
-    "       [[,iops=i]|[[,iops_rd=r][,iops_wr=w]]]\n"
-    "       [[,bps_max=bm]|[[,bps_rd_max=rm][,bps_wr_max=wm]]]\n"
-    "       [[,iops_max=im]|[[,iops_rd_max=irm][,iops_wr_max=iwm]]]\n"
-    "       [[,iops_size=is]]\n"
-    "       [[,group=g]]\n"
-    "                use 'file' as a drive image\n", QEMU_ARCH_ALL)
-STEXI
-@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
-@findex -drive
-
-Define a new drive. This includes creating a block driver node (the backend) as
-well as a guest device, and is mostly a shortcut for defining the corresponding
-@option{-blockdev} and @option{-device} options.
-
-@option{-drive} accepts all options that are accepted by @option{-blockdev}. In
-addition, it knows the following options:
-
-@table @option
-@item file=@var{file}
-This option defines which disk image (@pxref{disk_images}) to use with
-this drive. If the filename contains comma, you must double it
-(for instance, "file=my,,file" to use file "my,file").
-
-Special files such as iSCSI devices can be specified using protocol
-specific URLs. See the section for "Device URL Syntax" for more information.
-@item if=@var{interface}
-This option defines on which type on interface the drive is connected.
-Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio, none.
-@item bus=@var{bus},unit=@var{unit}
-These options define where is connected the drive by defining the bus number and
-the unit id.
-@item index=@var{index}
-This option defines where is connected the drive by using an index in the list
-of available connectors of a given interface type.
-@item media=@var{media}
-This option defines the type of the media: disk or cdrom.
-@item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
-These options have the same definition as they have in @option{-hdachs}.
-These parameters are deprecated, use the corresponding parameters
-of @code{-device} instead.
-@item snapshot=@var{snapshot}
-@var{snapshot} is "on" or "off" and controls snapshot mode for the given drive
-(see @option{-snapshot}).
-@item cache=@var{cache}
-@var{cache} is "none", "writeback", "unsafe", "directsync" or "writethrough"
-and controls how the host cache is used to access block data. This is a
-shortcut that sets the @option{cache.direct} and @option{cache.no-flush}
-options (as in @option{-blockdev}), and additionally @option{cache.writeback},
-which provides a default for the @option{write-cache} option of block guest
-devices (as in @option{-device}). The modes correspond to the following
-settings:
-
-@c Our texi2pod.pl script doesn't support @multitable, so fall back to using
-@c plain ASCII art (well, UTF-8 art really). This looks okay both in the manpage
-@c and the HTML output.
-@example
-@             │ cache.writeback   cache.direct   cache.no-flush
-─────────────┼─────────────────────────────────────────────────
-writeback    │ on                off            off
-none         │ on                on             off
-writethrough │ off               off            off
-directsync   │ off               on             off
-unsafe       │ on                off            on
-@end example
-
-The default mode is @option{cache=writeback}.
-
-@item aio=@var{aio}
-@var{aio} is "threads", or "native" and selects between pthread based disk I/O and native Linux AIO.
-@item format=@var{format}
-Specify which disk @var{format} will be used rather than detecting
-the format.  Can be used to specify format=raw to avoid interpreting
-an untrusted format header.
-@item serial=@var{serial}
-This option specifies the serial number to assign to the device. This
-parameter is deprecated, use the corresponding parameter of @code{-device}
-instead.
-@item addr=@var{addr}
-Specify the controller's PCI address (if=virtio only). This parameter is
-deprecated, use the corresponding parameter of @code{-device} instead.
-@item werror=@var{action},rerror=@var{action}
-Specify which @var{action} to take on write and read errors. Valid actions are:
-"ignore" (ignore the error and try to continue), "stop" (pause QEMU),
-"report" (report the error to the guest), "enospc" (pause QEMU only if the
-host disk is full; report the error to the guest otherwise).
-The default setting is @option{werror=enospc} and @option{rerror=report}.
-@item copy-on-read=@var{copy-on-read}
-@var{copy-on-read} is "on" or "off" and enables whether to copy read backing
-file sectors into the image file.
-@item bps=@var{b},bps_rd=@var{r},bps_wr=@var{w}
-Specify bandwidth throttling limits in bytes per second, either for all request
-types or for reads or writes only.  Small values can lead to timeouts or hangs
-inside the guest.  A safe minimum for disks is 2 MB/s.
-@item bps_max=@var{bm},bps_rd_max=@var{rm},bps_wr_max=@var{wm}
-Specify bursts in bytes per second, either for all request types or for reads
-or writes only.  Bursts allow the guest I/O to spike above the limit
-temporarily.
-@item iops=@var{i},iops_rd=@var{r},iops_wr=@var{w}
-Specify request rate limits in requests per second, either for all request
-types or for reads or writes only.
-@item iops_max=@var{bm},iops_rd_max=@var{rm},iops_wr_max=@var{wm}
-Specify bursts in requests per second, either for all request types or for reads
-or writes only.  Bursts allow the guest I/O to spike above the limit
-temporarily.
-@item iops_size=@var{is}
-Let every @var{is} bytes of a request count as a new request for iops
-throttling purposes.  Use this option to prevent guests from circumventing iops
-limits by sending fewer but larger requests.
-@item group=@var{g}
-Join a throttling quota group with given name @var{g}.  All drives that are
-members of the same group are accounted for together.  Use this option to
-prevent guests from circumventing throttling limits by using many small disks
-instead of a single larger disk.
-@end table
-
-By default, the @option{cache.writeback=on} mode is used. It will report data
-writes as completed as soon as the data is present in the host page cache.
-This is safe as long as your guest OS makes sure to correctly flush disk caches
-where needed. If your guest OS does not handle volatile disk write caches
-correctly and your host crashes or loses power, then the guest may experience
-data corruption.
-
-For such guests, you should consider using @option{cache.writeback=off}. This
-means that the host page cache will be used to read and write data, but write
-notification will be sent to the guest only after QEMU has made sure to flush
-each write to the disk. Be aware that this has a major impact on performance.
-
-When using the @option{-snapshot} option, unsafe caching is always used.
-
-Copy-on-read avoids accessing the same backing file sectors repeatedly and is
-useful when the backing file is over a slow network.  By default copy-on-read
-is off.
-
-Instead of @option{-cdrom} you can use:
-@example
-qemu-system-i386 -drive file=file,index=2,media=cdrom
-@end example
-
-Instead of @option{-hda}, @option{-hdb}, @option{-hdc}, @option{-hdd}, you can
-use:
-@example
-qemu-system-i386 -drive file=file,index=0,media=disk
-qemu-system-i386 -drive file=file,index=1,media=disk
-qemu-system-i386 -drive file=file,index=2,media=disk
-qemu-system-i386 -drive file=file,index=3,media=disk
-@end example
-
-You can open an image using pre-opened file descriptors from an fd set:
-@example
-qemu-system-i386
--add-fd fd=3,set=2,opaque="rdwr:/path/to/file"
--add-fd fd=4,set=2,opaque="rdonly:/path/to/file"
--drive file=/dev/fdset/2,index=0,media=disk
-@end example
-
-You can connect a CDROM to the slave of ide0:
-@example
-qemu-system-i386 -drive file=file,if=ide,index=1,media=cdrom
-@end example
-
-If you don't specify the "file=" argument, you define an empty drive:
-@example
-qemu-system-i386 -drive if=ide,index=1,media=cdrom
-@end example
-
-Instead of @option{-fda}, @option{-fdb}, you can use:
-@example
-qemu-system-i386 -drive file=file,index=0,if=floppy
-qemu-system-i386 -drive file=file,index=1,if=floppy
-@end example
-
-By default, @var{interface} is "ide" and @var{index} is automatically
-incremented:
-@example
-qemu-system-i386 -drive file=a -drive file=b"
-@end example
-is interpreted like:
-@example
-qemu-system-i386 -hda a -hdb b
-@end example
-ETEXI
-
-DEF("mtdblock", HAS_ARG, QEMU_OPTION_mtdblock,
-    "-mtdblock file  use 'file' as on-board Flash memory image\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -mtdblock @var{file}
-@findex -mtdblock
-Use @var{file} as on-board Flash memory image.
-ETEXI
-
-DEF("sd", HAS_ARG, QEMU_OPTION_sd,
-    "-sd file        use 'file' as SecureDigital card image\n", QEMU_ARCH_ALL)
-STEXI
-@item -sd @var{file}
-@findex -sd
-Use @var{file} as SecureDigital card image.
-ETEXI
-
-DEF("pflash", HAS_ARG, QEMU_OPTION_pflash,
-    "-pflash file    use 'file' as a parallel flash image\n", QEMU_ARCH_ALL)
-STEXI
-@item -pflash @var{file}
-@findex -pflash
-Use @var{file} as a parallel flash image.
-ETEXI
-
-DEF("snapshot", 0, QEMU_OPTION_snapshot,
-    "-snapshot       write to temporary files instead of disk image files\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -snapshot
-@findex -snapshot
-Write to temporary files instead of disk image files. In this case,
-the raw disk image you use is not written back. You can however force
-the write back by pressing @key{C-a s} (@pxref{disk_images}).
-ETEXI
-
-DEF("hdachs", HAS_ARG, QEMU_OPTION_hdachs, \
-    "-hdachs c,h,s[,t]\n" \
-    "                force hard disk 0 physical geometry and the optional BIOS\n" \
-    "                translation (t=none or lba) (usually QEMU can guess them)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -hdachs @var{c},@var{h},@var{s},[,@var{t}]
-@findex -hdachs
-Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
-@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
-translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
-all those parameters. This option is deprecated, please use
-@code{-device ide-hd,cyls=c,heads=h,secs=s,...} instead.
-ETEXI
-
-DEF("fsdev", HAS_ARG, QEMU_OPTION_fsdev,
-    "-fsdev fsdriver,id=id[,path=path,][security_model={mapped-xattr|mapped-file|passthrough|none}]\n"
-    " [,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n"
-    " [[,throttling.bps-total=b]|[[,throttling.bps-read=r][,throttling.bps-write=w]]]\n"
-    " [[,throttling.iops-total=i]|[[,throttling.iops-read=r][,throttling.iops-write=w]]]\n"
-    " [[,throttling.bps-total-max=bm]|[[,throttling.bps-read-max=rm][,throttling.bps-write-max=wm]]]\n"
-    " [[,throttling.iops-total-max=im]|[[,throttling.iops-read-max=irm][,throttling.iops-write-max=iwm]]]\n"
-    " [[,throttling.iops-size=is]]\n",
-    QEMU_ARCH_ALL)
-
-STEXI
-
-@item -fsdev @var{fsdriver},id=@var{id},path=@var{path},[security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}]
-@findex -fsdev
-Define a new file system device. Valid options are:
-@table @option
-@item @var{fsdriver}
-This option specifies the fs driver backend to use.
-Currently "local", "handle" and "proxy" file system drivers are supported.
-@item id=@var{id}
-Specifies identifier for this device
-@item path=@var{path}
-Specifies the export path for the file system device. Files under
-this path will be available to the 9p client on the guest.
-@item security_model=@var{security_model}
-Specifies the security model to be used for this export path.
-Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
-In "passthrough" security model, files are stored using the same
-credentials as they are created on the guest. This requires QEMU
-to run as root. In "mapped-xattr" security model, some of the file
-attributes like uid, gid, mode bits and link target are stored as
-file attributes. For "mapped-file" these attributes are stored in the
-hidden .virtfs_metadata directory. Directories exported by this security model cannot
-interact with other unix tools. "none" security model is same as
-passthrough except the sever won't report failures if it fails to
-set file attributes like ownership. Security model is mandatory
-only for local fsdriver. Other fsdrivers (like handle, proxy) don't take
-security model as a parameter.
-@item writeout=@var{writeout}
-This is an optional argument. The only supported value is "immediate".
-This means that host page cache will be used to read and write data but
-write notification will be sent to the guest only when the data has been
-reported as written by the storage subsystem.
-@item readonly
-Enables exporting 9p share as a readonly mount for guests. By default
-read-write access is given.
-@item socket=@var{socket}
-Enables proxy filesystem driver to use passed socket file for communicating
-with virtfs-proxy-helper
-@item sock_fd=@var{sock_fd}
-Enables proxy filesystem driver to use passed socket descriptor for
-communicating with virtfs-proxy-helper. Usually a helper like libvirt
-will create socketpair and pass one of the fds as sock_fd
-@item fmode=@var{fmode}
-Specifies the default mode for newly created files on the host. Works only
-with security models "mapped-xattr" and "mapped-file".
-@item dmode=@var{dmode}
-Specifies the default mode for newly created directories on the host. Works
-only with security models "mapped-xattr" and "mapped-file".
-@end table
-
--fsdev option is used along with -device driver "virtio-9p-pci".
-@item -device virtio-9p-pci,fsdev=@var{id},mount_tag=@var{mount_tag}
-Options for virtio-9p-pci driver are:
-@table @option
-@item fsdev=@var{id}
-Specifies the id value specified along with -fsdev option
-@item mount_tag=@var{mount_tag}
-Specifies the tag name to be used by the guest to mount this export point
-@end table
-
-ETEXI
-
-DEF("virtfs", HAS_ARG, QEMU_OPTION_virtfs,
-    "-virtfs local,path=path,mount_tag=tag,security_model=[mapped-xattr|mapped-file|passthrough|none]\n"
-    "        [,id=id][,writeout=immediate][,readonly][,socket=socket|sock_fd=sock_fd][,fmode=fmode][,dmode=dmode]\n",
-    QEMU_ARCH_ALL)
-
-STEXI
-
-@item -virtfs @var{fsdriver}[,path=@var{path}],mount_tag=@var{mount_tag}[,security_model=@var{security_model}][,writeout=@var{writeout}][,readonly][,socket=@var{socket}|sock_fd=@var{sock_fd}][,fmode=@var{fmode}][,dmode=@var{dmode}]
-@findex -virtfs
-
-The general form of a Virtual File system pass-through options are:
-@table @option
-@item @var{fsdriver}
-This option specifies the fs driver backend to use.
-Currently "local", "handle" and "proxy" file system drivers are supported.
-@item id=@var{id}
-Specifies identifier for this device
-@item path=@var{path}
-Specifies the export path for the file system device. Files under
-this path will be available to the 9p client on the guest.
-@item security_model=@var{security_model}
-Specifies the security model to be used for this export path.
-Supported security models are "passthrough", "mapped-xattr", "mapped-file" and "none".
-In "passthrough" security model, files are stored using the same
-credentials as they are created on the guest. This requires QEMU
-to run as root. In "mapped-xattr" security model, some of the file
-attributes like uid, gid, mode bits and link target are stored as
-file attributes. For "mapped-file" these attributes are stored in the
-hidden .virtfs_metadata directory. Directories exported by this security model cannot
-interact with other unix tools. "none" security model is same as
-passthrough except the sever won't report failures if it fails to
-set file attributes like ownership. Security model is mandatory only
-for local fsdriver. Other fsdrivers (like handle, proxy) don't take security
-model as a parameter.
-@item writeout=@var{writeout}
-This is an optional argument. The only supported value is "immediate".
-This means that host page cache will be used to read and write data but
-write notification will be sent to the guest only when the data has been
-reported as written by the storage subsystem.
-@item readonly
-Enables exporting 9p share as a readonly mount for guests. By default
-read-write access is given.
-@item socket=@var{socket}
-Enables proxy filesystem driver to use passed socket file for
-communicating with virtfs-proxy-helper. Usually a helper like libvirt
-will create socketpair and pass one of the fds as sock_fd
-@item sock_fd
-Enables proxy filesystem driver to use passed 'sock_fd' as the socket
-descriptor for interfacing with virtfs-proxy-helper
-@item fmode=@var{fmode}
-Specifies the default mode for newly created files on the host. Works only
-with security models "mapped-xattr" and "mapped-file".
-@item dmode=@var{dmode}
-Specifies the default mode for newly created directories on the host. Works
-only with security models "mapped-xattr" and "mapped-file".
-@end table
-ETEXI
-
-DEF("virtfs_synth", 0, QEMU_OPTION_virtfs_synth,
-    "-virtfs_synth Create synthetic file system image\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -virtfs_synth
-@findex -virtfs_synth
-Create synthetic file system image
-ETEXI
-
-DEF("iscsi", HAS_ARG, QEMU_OPTION_iscsi,
-    "-iscsi [user=user][,password=password]\n"
-    "       [,header-digest=CRC32C|CR32C-NONE|NONE-CRC32C|NONE\n"
-    "       [,initiator-name=initiator-iqn][,id=target-iqn]\n"
-    "       [,timeout=timeout]\n"
-    "                iSCSI session parameters\n", QEMU_ARCH_ALL)
-
-STEXI
-@item -iscsi
-@findex -iscsi
-Configure iSCSI session parameters.
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(USB options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("usb", 0, QEMU_OPTION_usb,
-    "-usb            enable the USB driver (if it is not used by default yet)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -usb
-@findex -usb
-Enable the USB driver (if it is not used by default yet).
-ETEXI
-
-DEF("usbdevice", HAS_ARG, QEMU_OPTION_usbdevice,
-    "-usbdevice name add the host or guest USB device 'name'\n",
-    QEMU_ARCH_ALL)
-STEXI
-
-@item -usbdevice @var{devname}
-@findex -usbdevice
-Add the USB device @var{devname}. Note that this option is deprecated,
-please use @code{-device usb-...} instead. @xref{usb_devices}.
-
-@table @option
-
-@item mouse
-Virtual Mouse. This will override the PS/2 mouse emulation when activated.
-
-@item tablet
-Pointer device that uses absolute coordinates (like a touchscreen). This
-means QEMU is able to report the mouse position without having to grab the
-mouse. Also overrides the PS/2 mouse emulation when activated.
-
-@item disk:[format=@var{format}]:@var{file}
-Mass storage device based on file. The optional @var{format} argument
-will be used rather than detecting the format. Can be used to specify
-@code{format=raw} to avoid interpreting an untrusted format header.
-
-@item host:@var{bus}.@var{addr}
-Pass through the host device identified by @var{bus}.@var{addr} (Linux only).
-
-@item host:@var{vendor_id}:@var{product_id}
-Pass through the host device identified by @var{vendor_id}:@var{product_id}
-(Linux only).
-
-@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
-Serial converter to host character device @var{dev}, see @code{-serial} for the
-available devices.
-
-@item braille
-Braille device.  This will use BrlAPI to display the braille output on a real
-or fake device.
-
-@item net:@var{options}
-Network adapter that supports CDC ethernet and RNDIS protocols.
-
-@end table
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Display options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("display", HAS_ARG, QEMU_OPTION_display,
-    "-display sdl[,frame=on|off][,alt_grab=on|off][,ctrl_grab=on|off]\n"
-    "            [,window_close=on|off][,gl=on|off]\n"
-    "-display gtk[,grab_on_hover=on|off][,gl=on|off]|\n"
-    "-display vnc=<display>[,<optargs>]\n"
-    "-display curses\n"
-    "-display none"
-    "                select display type\n"
-    "The default display is equivalent to\n"
-#if defined(CONFIG_GTK)
-            "\t\"-display gtk\"\n"
-#elif defined(CONFIG_SDL)
-            "\t\"-display sdl\"\n"
-#elif defined(CONFIG_COCOA)
-            "\t\"-display cocoa\"\n"
-#elif defined(CONFIG_VNC)
-            "\t\"-vnc localhost:0,to=99,id=default\"\n"
-#else
-            "\t\"-display none\"\n"
-#endif
-    , QEMU_ARCH_ALL)
-STEXI
-@item -display @var{type}
-@findex -display
-Select type of display to use. This option is a replacement for the
-old style -sdl/-curses/... options. Valid values for @var{type} are
-@table @option
-@item sdl
-Display video output via SDL (usually in a separate graphics
-window; see the SDL documentation for other possibilities).
-@item curses
-Display video output via curses. For graphics device models which
-support a text mode, QEMU can display this output using a
-curses/ncurses interface. Nothing is displayed when the graphics
-device is in graphical mode or if the graphics device does not support
-a text mode. Generally only the VGA device models support text mode.
-@item none
-Do not display video output. The guest will still see an emulated
-graphics card, but its output will not be displayed to the QEMU
-user. This option differs from the -nographic option in that it
-only affects what is done with video output; -nographic also changes
-the destination of the serial and parallel port data.
-@item gtk
-Display video output in a GTK window. This interface provides drop-down
-menus and other UI elements to configure and control the VM during
-runtime.
-@item vnc
-Start a VNC server on display <arg>
-@end table
-ETEXI
-
-DEF("nographic", 0, QEMU_OPTION_nographic,
-    "-nographic      disable graphical output and redirect serial I/Os to console\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -nographic
-@findex -nographic
-Normally, if QEMU is compiled with graphical window support, it displays
-output such as guest graphics, guest console, and the QEMU monitor in a
-window. With this option, you can totally disable graphical output so
-that QEMU is a simple command line application. The emulated serial port
-is redirected on the console and muxed with the monitor (unless
-redirected elsewhere explicitly). Therefore, you can still use QEMU to
-debug a Linux kernel with a serial console. Use @key{C-a h} for help on
-switching between the console and monitor.
-ETEXI
-
-DEF("curses", 0, QEMU_OPTION_curses,
-    "-curses         shorthand for -display curses\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -curses
-@findex -curses
-Normally, if QEMU is compiled with graphical window support, it displays
-output such as guest graphics, guest console, and the QEMU monitor in a
-window. With this option, QEMU can display the VGA output when in text
-mode using a curses/ncurses interface. Nothing is displayed in graphical
-mode.
-ETEXI
-
-DEF("no-frame", 0, QEMU_OPTION_no_frame,
-    "-no-frame       open SDL window without a frame and window decorations\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -no-frame
-@findex -no-frame
-Do not use decorations for SDL windows and start them using the whole
-available screen space. This makes the using QEMU in a dedicated desktop
-workspace more convenient.
-ETEXI
-
-DEF("alt-grab", 0, QEMU_OPTION_alt_grab,
-    "-alt-grab       use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -alt-grab
-@findex -alt-grab
-Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt). Note that this also
-affects the special keys (for fullscreen, monitor-mode switching, etc).
-ETEXI
-
-DEF("ctrl-grab", 0, QEMU_OPTION_ctrl_grab,
-    "-ctrl-grab      use Right-Ctrl to grab mouse (instead of Ctrl-Alt)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -ctrl-grab
-@findex -ctrl-grab
-Use Right-Ctrl to grab mouse (instead of Ctrl-Alt). Note that this also
-affects the special keys (for fullscreen, monitor-mode switching, etc).
-ETEXI
-
-DEF("no-quit", 0, QEMU_OPTION_no_quit,
-    "-no-quit        disable SDL window close capability\n", QEMU_ARCH_ALL)
-STEXI
-@item -no-quit
-@findex -no-quit
-Disable SDL window close capability.
-ETEXI
-
-DEF("sdl", 0, QEMU_OPTION_sdl,
-    "-sdl            shorthand for -display sdl\n", QEMU_ARCH_ALL)
-STEXI
-@item -sdl
-@findex -sdl
-Enable SDL.
-ETEXI
-
-DEF("spice", HAS_ARG, QEMU_OPTION_spice,
-    "-spice [port=port][,tls-port=secured-port][,x509-dir=<dir>]\n"
-    "       [,x509-key-file=<file>][,x509-key-password=<file>]\n"
-    "       [,x509-cert-file=<file>][,x509-cacert-file=<file>]\n"
-    "       [,x509-dh-key-file=<file>][,addr=addr][,ipv4|ipv6|unix]\n"
-    "       [,tls-ciphers=<list>]\n"
-    "       [,tls-channel=[main|display|cursor|inputs|record|playback]]\n"
-    "       [,plaintext-channel=[main|display|cursor|inputs|record|playback]]\n"
-    "       [,sasl][,password=<secret>][,disable-ticketing]\n"
-    "       [,image-compression=[auto_glz|auto_lz|quic|glz|lz|off]]\n"
-    "       [,jpeg-wan-compression=[auto|never|always]]\n"
-    "       [,zlib-glz-wan-compression=[auto|never|always]]\n"
-    "       [,streaming-video=[off|all|filter]][,disable-copy-paste]\n"
-    "       [,disable-agent-file-xfer][,agent-mouse=[on|off]]\n"
-    "       [,playback-compression=[on|off]][,seamless-migration=[on|off]]\n"
-    "       [,gl=[on|off]][,rendernode=<file>]\n"
-    "   enable spice\n"
-    "   at least one of {port, tls-port} is mandatory\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -spice @var{option}[,@var{option}[,...]]
-@findex -spice
-Enable the spice remote desktop protocol. Valid options are
-
-@table @option
-
-@item port=<nr>
-Set the TCP port spice is listening on for plaintext channels.
-
-@item addr=<addr>
-Set the IP address spice is listening on.  Default is any address.
-
-@item ipv4
-@itemx ipv6
-@itemx unix
-Force using the specified IP version.
-
-@item password=<secret>
-Set the password you need to authenticate.
-
-@item sasl
-Require that the client use SASL to authenticate with the spice.
-The exact choice of authentication method used is controlled from the
-system / user's SASL configuration file for the 'qemu' service. This
-is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
-unprivileged user, an environment variable SASL_CONF_PATH can be used
-to make it search alternate locations for the service config.
-While some SASL auth methods can also provide data encryption (eg GSSAPI),
-it is recommended that SASL always be combined with the 'tls' and
-'x509' settings to enable use of SSL and server certificates. This
-ensures a data encryption preventing compromise of authentication
-credentials.
-
-@item disable-ticketing
-Allow client connects without authentication.
-
-@item disable-copy-paste
-Disable copy paste between the client and the guest.
-
-@item disable-agent-file-xfer
-Disable spice-vdagent based file-xfer between the client and the guest.
-
-@item tls-port=<nr>
-Set the TCP port spice is listening on for encrypted channels.
-
-@item x509-dir=<dir>
-Set the x509 file directory. Expects same filenames as -vnc $display,x509=$dir
-
-@item x509-key-file=<file>
-@itemx x509-key-password=<file>
-@itemx x509-cert-file=<file>
-@itemx x509-cacert-file=<file>
-@itemx x509-dh-key-file=<file>
-The x509 file names can also be configured individually.
-
-@item tls-ciphers=<list>
-Specify which ciphers to use.
-
-@item tls-channel=[main|display|cursor|inputs|record|playback]
-@itemx plaintext-channel=[main|display|cursor|inputs|record|playback]
-Force specific channel to be used with or without TLS encryption.  The
-options can be specified multiple times to configure multiple
-channels.  The special name "default" can be used to set the default
-mode.  For channels which are not explicitly forced into one mode the
-spice client is allowed to pick tls/plaintext as he pleases.
-
-@item image-compression=[auto_glz|auto_lz|quic|glz|lz|off]
-Configure image compression (lossless).
-Default is auto_glz.
-
-@item jpeg-wan-compression=[auto|never|always]
-@itemx zlib-glz-wan-compression=[auto|never|always]
-Configure wan image compression (lossy for slow links).
-Default is auto.
-
-@item streaming-video=[off|all|filter]
-Configure video stream detection.  Default is off.
-
-@item agent-mouse=[on|off]
-Enable/disable passing mouse events via vdagent.  Default is on.
-
-@item playback-compression=[on|off]
-Enable/disable audio stream compression (using celt 0.5.1).  Default is on.
-
-@item seamless-migration=[on|off]
-Enable/disable spice seamless migration. Default is off.
-
-@item gl=[on|off]
-Enable/disable OpenGL context. Default is off.
-
-@item rendernode=<file>
-DRM render node for OpenGL rendering. If not specified, it will pick
-the first available. (Since 2.9)
-
-@end table
-ETEXI
-
-DEF("portrait", 0, QEMU_OPTION_portrait,
-    "-portrait       rotate graphical output 90 deg left (only PXA LCD)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -portrait
-@findex -portrait
-Rotate graphical output 90 deg left (only PXA LCD).
-ETEXI
-
-DEF("rotate", HAS_ARG, QEMU_OPTION_rotate,
-    "-rotate <deg>   rotate graphical output some deg left (only PXA LCD)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -rotate @var{deg}
-@findex -rotate
-Rotate graphical output some deg left (only PXA LCD).
-ETEXI
-
-DEF("vga", HAS_ARG, QEMU_OPTION_vga,
-    "-vga [std|cirrus|vmware|qxl|xenfb|tcx|cg3|virtio|none]\n"
-    "                select video card type\n", QEMU_ARCH_ALL)
-STEXI
-@item -vga @var{type}
-@findex -vga
-Select type of VGA card to emulate. Valid values for @var{type} are
-@table @option
-@item cirrus
-Cirrus Logic GD5446 Video card. All Windows versions starting from
-Windows 95 should recognize and use this graphic card. For optimal
-performances, use 16 bit color depth in the guest and the host OS.
-(This card was the default before QEMU 2.2)
-@item std
-Standard VGA card with Bochs VBE extensions.  If your guest OS
-supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want
-to use high resolution modes (>= 1280x1024x16) then you should use
-this option. (This card is the default since QEMU 2.2)
-@item vmware
-VMWare SVGA-II compatible adapter. Use it if you have sufficiently
-recent XFree86/XOrg server or Windows guest with a driver for this
-card.
-@item qxl
-QXL paravirtual graphic card.  It is VGA compatible (including VESA
-2.0 VBE support).  Works best with qxl guest drivers installed though.
-Recommended choice when using the spice protocol.
-@item tcx
-(sun4m only) Sun TCX framebuffer. This is the default framebuffer for
-sun4m machines and offers both 8-bit and 24-bit colour depths at a
-fixed resolution of 1024x768.
-@item cg3
-(sun4m only) Sun cgthree framebuffer. This is a simple 8-bit framebuffer
-for sun4m machines available in both 1024x768 (OpenBIOS) and 1152x900 (OBP)
-resolutions aimed at people wishing to run older Solaris versions.
-@item virtio
-Virtio VGA card.
-@item none
-Disable VGA card.
-@end table
-ETEXI
-
-DEF("full-screen", 0, QEMU_OPTION_full_screen,
-    "-full-screen    start in full screen\n", QEMU_ARCH_ALL)
-STEXI
-@item -full-screen
-@findex -full-screen
-Start in full screen.
-ETEXI
-
-DEF("g", 1, QEMU_OPTION_g ,
-    "-g WxH[xDEPTH]  Set the initial graphical resolution and depth\n",
-    QEMU_ARCH_PPC | QEMU_ARCH_SPARC)
-STEXI
-@item -g @var{width}x@var{height}[x@var{depth}]
-@findex -g
-Set the initial graphical resolution and depth (PPC, SPARC only).
-ETEXI
-
-DEF("vnc", HAS_ARG, QEMU_OPTION_vnc ,
-    "-vnc <display>  shorthand for -display vnc=<display>\n", QEMU_ARCH_ALL)
-STEXI
-@item -vnc @var{display}[,@var{option}[,@var{option}[,...]]]
-@findex -vnc
-Normally, if QEMU is compiled with graphical window support, it displays
-output such as guest graphics, guest console, and the QEMU monitor in a
-window. With this option, you can have QEMU listen on VNC display
-@var{display} and redirect the VGA display over the VNC session. It is
-very useful to enable the usb tablet device when using this option
-(option @option{-device usb-tablet}). When using the VNC display, you
-must use the @option{-k} parameter to set the keyboard layout if you are
-not using en-us. Valid syntax for the @var{display} is
-
-@table @option
-
-@item to=@var{L}
-
-With this option, QEMU will try next available VNC @var{display}s, until the
-number @var{L}, if the origianlly defined "-vnc @var{display}" is not
-available, e.g. port 5900+@var{display} is already used by another
-application. By default, to=0.
-
-@item @var{host}:@var{d}
-
-TCP connections will only be allowed from @var{host} on display @var{d}.
-By convention the TCP port is 5900+@var{d}. Optionally, @var{host} can
-be omitted in which case the server will accept connections from any host.
-
-@item unix:@var{path}
-
-Connections will be allowed over UNIX domain sockets where @var{path} is the
-location of a unix socket to listen for connections on.
-
-@item none
-
-VNC is initialized but not started. The monitor @code{change} command
-can be used to later start the VNC server.
-
-@end table
-
-Following the @var{display} value there may be one or more @var{option} flags
-separated by commas. Valid options are
-
-@table @option
-
-@item reverse
-
-Connect to a listening VNC client via a ``reverse'' connection. The
-client is specified by the @var{display}. For reverse network
-connections (@var{host}:@var{d},@code{reverse}), the @var{d} argument
-is a TCP port number, not a display number.
-
-@item websocket
-
-Opens an additional TCP listening port dedicated to VNC Websocket connections.
-If a bare @var{websocket} option is given, the Websocket port is
-5700+@var{display}. An alternative port can be specified with the
-syntax @code{websocket}=@var{port}.
-
-If @var{host} is specified connections will only be allowed from this host.
-It is possible to control the websocket listen address independently, using
-the syntax @code{websocket}=@var{host}:@var{port}.
-
-If no TLS credentials are provided, the websocket connection runs in
-unencrypted mode. If TLS credentials are provided, the websocket connection
-requires encrypted client connections.
-
-@item password
-
-Require that password based authentication is used for client connections.
-
-The password must be set separately using the @code{set_password} command in
-the @ref{pcsys_monitor}. The syntax to change your password is:
-@code{set_password <protocol> <password>} where <protocol> could be either
-"vnc" or "spice".
-
-If you would like to change <protocol> password expiration, you should use
-@code{expire_password <protocol> <expiration-time>} where expiration time could
-be one of the following options: now, never, +seconds or UNIX time of
-expiration, e.g. +60 to make password expire in 60 seconds, or 1335196800
-to make password expire on "Mon Apr 23 12:00:00 EDT 2012" (UNIX time for this
-date and time).
-
-You can also use keywords "now" or "never" for the expiration time to
-allow <protocol> password to expire immediately or never expire.
-
-@item tls-creds=@var{ID}
-
-Provides the ID of a set of TLS credentials to use to secure the
-VNC server. They will apply to both the normal VNC server socket
-and the websocket socket (if enabled). Setting TLS credentials
-will cause the VNC server socket to enable the VeNCrypt auth
-mechanism.  The credentials should have been previously created
-using the @option{-object tls-creds} argument.
-
-The @option{tls-creds} parameter obsoletes the @option{tls},
-@option{x509}, and @option{x509verify} options, and as such
-it is not permitted to set both new and old type options at
-the same time.
-
-@item tls
-
-Require that client use TLS when communicating with the VNC server. This
-uses anonymous TLS credentials so is susceptible to a man-in-the-middle
-attack. It is recommended that this option be combined with either the
-@option{x509} or @option{x509verify} options.
-
-This option is now deprecated in favor of using the @option{tls-creds}
-argument.
-
-@item x509=@var{/path/to/certificate/dir}
-
-Valid if @option{tls} is specified. Require that x509 credentials are used
-for negotiating the TLS session. The server will send its x509 certificate
-to the client. It is recommended that a password be set on the VNC server
-to provide authentication of the client when this is used. The path following
-this option specifies where the x509 certificates are to be loaded from.
-See the @ref{vnc_security} section for details on generating certificates.
-
-This option is now deprecated in favour of using the @option{tls-creds}
-argument.
-
-@item x509verify=@var{/path/to/certificate/dir}
-
-Valid if @option{tls} is specified. Require that x509 credentials are used
-for negotiating the TLS session. The server will send its x509 certificate
-to the client, and request that the client send its own x509 certificate.
-The server will validate the client's certificate against the CA certificate,
-and reject clients when validation fails. If the certificate authority is
-trusted, this is a sufficient authentication mechanism. You may still wish
-to set a password on the VNC server as a second authentication layer. The
-path following this option specifies where the x509 certificates are to
-be loaded from. See the @ref{vnc_security} section for details on generating
-certificates.
-
-This option is now deprecated in favour of using the @option{tls-creds}
-argument.
-
-@item sasl
-
-Require that the client use SASL to authenticate with the VNC server.
-The exact choice of authentication method used is controlled from the
-system / user's SASL configuration file for the 'qemu' service. This
-is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
-unprivileged user, an environment variable SASL_CONF_PATH can be used
-to make it search alternate locations for the service config.
-While some SASL auth methods can also provide data encryption (eg GSSAPI),
-it is recommended that SASL always be combined with the 'tls' and
-'x509' settings to enable use of SSL and server certificates. This
-ensures a data encryption preventing compromise of authentication
-credentials. See the @ref{vnc_security} section for details on using
-SASL authentication.
-
-@item acl
-
-Turn on access control lists for checking of the x509 client certificate
-and SASL party. For x509 certs, the ACL check is made against the
-certificate's distinguished name. This is something that looks like
-@code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
-made against the username, which depending on the SASL plugin, may
-include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
-When the @option{acl} flag is set, the initial access list will be
-empty, with a @code{deny} policy. Thus no one will be allowed to
-use the VNC server until the ACLs have been loaded. This can be
-achieved using the @code{acl} monitor command.
-
-@item lossy
-
-Enable lossy compression methods (gradient, JPEG, ...). If this
-option is set, VNC client may receive lossy framebuffer updates
-depending on its encoding settings. Enabling this option can save
-a lot of bandwidth at the expense of quality.
-
-@item non-adaptive
-
-Disable adaptive encodings. Adaptive encodings are enabled by default.
-An adaptive encoding will try to detect frequently updated screen regions,
-and send updates in these regions using a lossy encoding (like JPEG).
-This can be really helpful to save bandwidth when playing videos. Disabling
-adaptive encodings restores the original static behavior of encodings
-like Tight.
-
-@item share=[allow-exclusive|force-shared|ignore]
-
-Set display sharing policy.  'allow-exclusive' allows clients to ask
-for exclusive access.  As suggested by the rfb spec this is
-implemented by dropping other connections.  Connecting multiple
-clients in parallel requires all clients asking for a shared session
-(vncviewer: -shared switch).  This is the default.  'force-shared'
-disables exclusive client access.  Useful for shared desktop sessions,
-where you don't want someone forgetting specify -shared disconnect
-everybody else.  'ignore' completely ignores the shared flag and
-allows everybody connect unconditionally.  Doesn't conform to the rfb
-spec but is traditional QEMU behavior.
-
-@item key-delay-ms
-
-Set keyboard delay, for key down and key up events, in milliseconds.
-Default is 10.  Keyboards are low-bandwidth devices, so this slowdown
-can help the device and guest to keep up and not lose events in case
-events are arriving in bulk.  Possible causes for the latter are flaky
-network connections, or scripts for automated testing.
-
-@end table
-ETEXI
-
-STEXI
-@end table
-ETEXI
-ARCHHEADING(, QEMU_ARCH_I386)
-
-ARCHHEADING(i386 target only:, QEMU_ARCH_I386)
-STEXI
-@table @option
-ETEXI
-
-DEF("win2k-hack", 0, QEMU_OPTION_win2k_hack,
-    "-win2k-hack     use it when installing Windows 2000 to avoid a disk full bug\n",
-    QEMU_ARCH_I386)
-STEXI
-@item -win2k-hack
-@findex -win2k-hack
-Use it when installing Windows 2000 to avoid a disk full bug. After
-Windows 2000 is installed, you no longer need this option (this option
-slows down the IDE transfers).
-ETEXI
-
-HXCOMM Deprecated by -rtc
-DEF("rtc-td-hack", 0, QEMU_OPTION_rtc_td_hack, "", QEMU_ARCH_I386)
-
-DEF("no-fd-bootchk", 0, QEMU_OPTION_no_fd_bootchk,
-    "-no-fd-bootchk  disable boot signature checking for floppy disks\n",
-    QEMU_ARCH_I386)
-STEXI
-@item -no-fd-bootchk
-@findex -no-fd-bootchk
-Disable boot signature checking for floppy disks in BIOS. May
-be needed to boot from old floppy disks.
-ETEXI
-
-DEF("no-acpi", 0, QEMU_OPTION_no_acpi,
-           "-no-acpi        disable ACPI\n", QEMU_ARCH_I386 | QEMU_ARCH_ARM)
-STEXI
-@item -no-acpi
-@findex -no-acpi
-Disable ACPI (Advanced Configuration and Power Interface) support. Use
-it if your guest OS complains about ACPI problems (PC target machine
-only).
-ETEXI
-
-DEF("no-hpet", 0, QEMU_OPTION_no_hpet,
-    "-no-hpet        disable HPET\n", QEMU_ARCH_I386)
-STEXI
-@item -no-hpet
-@findex -no-hpet
-Disable HPET support.
-ETEXI
-
-DEF("acpitable", HAS_ARG, QEMU_OPTION_acpitable,
-    "-acpitable [sig=str][,rev=n][,oem_id=str][,oem_table_id=str][,oem_rev=n][,asl_compiler_id=str][,asl_compiler_rev=n][,{data|file}=file1[:file2]...]\n"
-    "                ACPI table description\n", QEMU_ARCH_I386)
-STEXI
-@item -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]
-@findex -acpitable
-Add ACPI table with specified header fields and context from specified files.
-For file=, take whole ACPI table from the specified files, including all
-ACPI headers (possible overridden by other options).
-For data=, only data
-portion of the table is used, all header information is specified in the
-command line.
-If a SLIC table is supplied to QEMU, then the SLIC's oem_id and oem_table_id
-fields will override the same in the RSDT and the FADT (a.k.a. FACP), in order
-to ensure the field matches required by the Microsoft SLIC spec and the ACPI
-spec.
-ETEXI
-
-DEF("smbios", HAS_ARG, QEMU_OPTION_smbios,
-    "-smbios file=binary\n"
-    "                load SMBIOS entry from binary file\n"
-    "-smbios type=0[,vendor=str][,version=str][,date=str][,release=%d.%d]\n"
-    "              [,uefi=on|off]\n"
-    "                specify SMBIOS type 0 fields\n"
-    "-smbios type=1[,manufacturer=str][,product=str][,version=str][,serial=str]\n"
-    "              [,uuid=uuid][,sku=str][,family=str]\n"
-    "                specify SMBIOS type 1 fields\n"
-    "-smbios type=2[,manufacturer=str][,product=str][,version=str][,serial=str]\n"
-    "              [,asset=str][,location=str]\n"
-    "                specify SMBIOS type 2 fields\n"
-    "-smbios type=3[,manufacturer=str][,version=str][,serial=str][,asset=str]\n"
-    "              [,sku=str]\n"
-    "                specify SMBIOS type 3 fields\n"
-    "-smbios type=4[,sock_pfx=str][,manufacturer=str][,version=str][,serial=str]\n"
-    "              [,asset=str][,part=str]\n"
-    "                specify SMBIOS type 4 fields\n"
-    "-smbios type=17[,loc_pfx=str][,bank=str][,manufacturer=str][,serial=str]\n"
-    "               [,asset=str][,part=str][,speed=%d]\n"
-    "                specify SMBIOS type 17 fields\n",
-    QEMU_ARCH_I386 | QEMU_ARCH_ARM)
-STEXI
-@item -smbios file=@var{binary}
-@findex -smbios
-Load SMBIOS entry from binary file.
-
-@item -smbios type=0[,vendor=@var{str}][,version=@var{str}][,date=@var{str}][,release=@var{%d.%d}][,uefi=on|off]
-Specify SMBIOS type 0 fields
-
-@item -smbios type=1[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,uuid=@var{uuid}][,sku=@var{str}][,family=@var{str}]
-Specify SMBIOS type 1 fields
-
-@item -smbios type=2[,manufacturer=@var{str}][,product=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,location=@var{str}][,family=@var{str}]
-Specify SMBIOS type 2 fields
-
-@item -smbios type=3[,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,sku=@var{str}]
-Specify SMBIOS type 3 fields
-
-@item -smbios type=4[,sock_pfx=@var{str}][,manufacturer=@var{str}][,version=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}]
-Specify SMBIOS type 4 fields
-
-@item -smbios type=17[,loc_pfx=@var{str}][,bank=@var{str}][,manufacturer=@var{str}][,serial=@var{str}][,asset=@var{str}][,part=@var{str}][,speed=@var{%d}]
-Specify SMBIOS type 17 fields
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Network options:)
-STEXI
-@table @option
-ETEXI
-
-HXCOMM Legacy slirp options (now moved to -net user):
-#ifdef CONFIG_SLIRP
-DEF("tftp", HAS_ARG, QEMU_OPTION_tftp, "", QEMU_ARCH_ALL)
-DEF("bootp", HAS_ARG, QEMU_OPTION_bootp, "", QEMU_ARCH_ALL)
-DEF("redir", HAS_ARG, QEMU_OPTION_redir, "", QEMU_ARCH_ALL)
-#ifndef _WIN32
-DEF("smb", HAS_ARG, QEMU_OPTION_smb, "", QEMU_ARCH_ALL)
-#endif
-#endif
-
-DEF("netdev", HAS_ARG, QEMU_OPTION_netdev,
-#ifdef CONFIG_SLIRP
-    "-netdev user,id=str[,ipv4[=on|off]][,net=addr[/mask]][,host=addr]\n"
-    "         [,ipv6[=on|off]][,ipv6-net=addr[/int]][,ipv6-host=addr]\n"
-    "         [,restrict=on|off][,hostname=host][,dhcpstart=addr]\n"
-    "         [,dns=addr][,ipv6-dns=addr][,dnssearch=domain][,tftp=dir]\n"
-    "         [,bootfile=f][,hostfwd=rule][,guestfwd=rule]"
-#ifndef _WIN32
-                                             "[,smb=dir[,smbserver=addr]]\n"
-#endif
-    "                configure a user mode network backend with ID 'str',\n"
-    "                its DHCP server and optional services\n"
-#endif
-#ifdef _WIN32
-    "-netdev tap,id=str,ifname=name\n"
-    "                configure a host TAP network backend with ID 'str'\n"
-#else
-    "-netdev tap,id=str[,fd=h][,fds=x:y:...:z][,ifname=name][,script=file][,downscript=dfile]\n"
-    "         [,br=bridge][,helper=helper][,sndbuf=nbytes][,vnet_hdr=on|off][,vhost=on|off]\n"
-    "         [,vhostfd=h][,vhostfds=x:y:...:z][,vhostforce=on|off][,queues=n]\n"
-    "         [,poll-us=n]\n"
-    "                configure a host TAP network backend with ID 'str'\n"
-    "                connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
-    "                use network scripts 'file' (default=" DEFAULT_NETWORK_SCRIPT ")\n"
-    "                to configure it and 'dfile' (default=" DEFAULT_NETWORK_DOWN_SCRIPT ")\n"
-    "                to deconfigure it\n"
-    "                use '[down]script=no' to disable script execution\n"
-    "                use network helper 'helper' (default=" DEFAULT_BRIDGE_HELPER ") to\n"
-    "                configure it\n"
-    "                use 'fd=h' to connect to an already opened TAP interface\n"
-    "                use 'fds=x:y:...:z' to connect to already opened multiqueue capable TAP interfaces\n"
-    "                use 'sndbuf=nbytes' to limit the size of the send buffer (the\n"
-    "                default is disabled 'sndbuf=0' to enable flow control set 'sndbuf=1048576')\n"
-    "                use vnet_hdr=off to avoid enabling the IFF_VNET_HDR tap flag\n"
-    "                use vnet_hdr=on to make the lack of IFF_VNET_HDR support an error condition\n"
-    "                use vhost=on to enable experimental in kernel accelerator\n"
-    "                    (only has effect for virtio guests which use MSIX)\n"
-    "                use vhostforce=on to force vhost on for non-MSIX virtio guests\n"
-    "                use 'vhostfd=h' to connect to an already opened vhost net device\n"
-    "                use 'vhostfds=x:y:...:z to connect to multiple already opened vhost net devices\n"
-    "                use 'queues=n' to specify the number of queues to be created for multiqueue TAP\n"
-    "                use 'poll-us=n' to speciy the maximum number of microseconds that could be\n"
-    "                spent on busy polling for vhost net\n"
-    "-netdev bridge,id=str[,br=bridge][,helper=helper]\n"
-    "                configure a host TAP network backend with ID 'str' that is\n"
-    "                connected to a bridge (default=" DEFAULT_BRIDGE_INTERFACE ")\n"
-    "                using the program 'helper (default=" DEFAULT_BRIDGE_HELPER ")\n"
-#endif
-#ifdef __linux__
-    "-netdev l2tpv3,id=str,src=srcaddr,dst=dstaddr[,srcport=srcport][,dstport=dstport]\n"
-    "         [,rxsession=rxsession],txsession=txsession[,ipv6=on/off][,udp=on/off]\n"
-    "         [,cookie64=on/off][,counter][,pincounter][,txcookie=txcookie]\n"
-    "         [,rxcookie=rxcookie][,offset=offset]\n"
-    "                configure a network backend with ID 'str' connected to\n"
-    "                an Ethernet over L2TPv3 pseudowire.\n"
-    "                Linux kernel 3.3+ as well as most routers can talk\n"
-    "                L2TPv3. This transport allows connecting a VM to a VM,\n"
-    "                VM to a router and even VM to Host. It is a nearly-universal\n"
-    "                standard (RFC3391). Note - this implementation uses static\n"
-    "                pre-configured tunnels (same as the Linux kernel).\n"
-    "                use 'src=' to specify source address\n"
-    "                use 'dst=' to specify destination address\n"
-    "                use 'udp=on' to specify udp encapsulation\n"
-    "                use 'srcport=' to specify source udp port\n"
-    "                use 'dstport=' to specify destination udp port\n"
-    "                use 'ipv6=on' to force v6\n"
-    "                L2TPv3 uses cookies to prevent misconfiguration as\n"
-    "                well as a weak security measure\n"
-    "                use 'rxcookie=0x012345678' to specify a rxcookie\n"
-    "                use 'txcookie=0x012345678' to specify a txcookie\n"
-    "                use 'cookie64=on' to set cookie size to 64 bit, otherwise 32\n"
-    "                use 'counter=off' to force a 'cut-down' L2TPv3 with no counter\n"
-    "                use 'pincounter=on' to work around broken counter handling in peer\n"
-    "                use 'offset=X' to add an extra offset between header and data\n"
-#endif
-    "-netdev socket,id=str[,fd=h][,listen=[host]:port][,connect=host:port]\n"
-    "                configure a network backend to connect to another network\n"
-    "                using a socket connection\n"
-    "-netdev socket,id=str[,fd=h][,mcast=maddr:port[,localaddr=addr]]\n"
-    "                configure a network backend to connect to a multicast maddr and port\n"
-    "                use 'localaddr=addr' to specify the host address to send packets from\n"
-    "-netdev socket,id=str[,fd=h][,udp=host:port][,localaddr=host:port]\n"
-    "                configure a network backend to connect to another network\n"
-    "                using an UDP tunnel\n"
-#ifdef CONFIG_VDE
-    "-netdev vde,id=str[,sock=socketpath][,port=n][,group=groupname][,mode=octalmode]\n"
-    "                configure a network backend to connect to port 'n' of a vde switch\n"
-    "                running on host and listening for incoming connections on 'socketpath'.\n"
-    "                Use group 'groupname' and mode 'octalmode' to change default\n"
-    "                ownership and permissions for communication port.\n"
-#endif
-#ifdef CONFIG_NETMAP
-    "-netdev netmap,id=str,ifname=name[,devname=nmname]\n"
-    "                attach to the existing netmap-enabled network interface 'name', or to a\n"
-    "                VALE port (created on the fly) called 'name' ('nmname' is name of the \n"
-    "                netmap device, defaults to '/dev/netmap')\n"
-#endif
-    "-netdev vhost-user,id=str,chardev=dev[,vhostforce=on|off]\n"
-    "                configure a vhost-user network, backed by a chardev 'dev'\n"
-    "-netdev hubport,id=str,hubid=n\n"
-    "                configure a hub port on QEMU VLAN 'n'\n", QEMU_ARCH_ALL)
-DEF("net", HAS_ARG, QEMU_OPTION_net,
-    "-net nic[,vlan=n][,macaddr=mac][,model=type][,name=str][,addr=str][,vectors=v]\n"
-    "                old way to create a new NIC and connect it to VLAN 'n'\n"
-    "                (use the '-device devtype,netdev=str' option if possible instead)\n"
-    "-net dump[,vlan=n][,file=f][,len=n]\n"
-    "                dump traffic on vlan 'n' to file 'f' (max n bytes per packet)\n"
-    "-net none       use it alone to have zero network devices. If no -net option\n"
-    "                is provided, the default is '-net nic -net user'\n"
-    "-net ["
-#ifdef CONFIG_SLIRP
-    "user|"
-#endif
-    "tap|"
-    "bridge|"
-#ifdef CONFIG_VDE
-    "vde|"
-#endif
-#ifdef CONFIG_NETMAP
-    "netmap|"
-#endif
-    "socket][,vlan=n][,option][,option][,...]\n"
-    "                old way to initialize a host network interface\n"
-    "                (use the -netdev option if possible instead)\n", QEMU_ARCH_ALL)
-STEXI
-@item -net nic[,vlan=@var{n}][,macaddr=@var{mac}][,model=@var{type}] [,name=@var{name}][,addr=@var{addr}][,vectors=@var{v}]
-@findex -net
-Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
-= 0 is the default). The NIC is an e1000 by default on the PC
-target. Optionally, the MAC address can be changed to @var{mac}, the
-device address set to @var{addr} (PCI cards only),
-and a @var{name} can be assigned for use in monitor commands.
-Optionally, for PCI cards, you can specify the number @var{v} of MSI-X vectors
-that the card should have; this option currently only affects virtio cards; set
-@var{v} = 0 to disable MSI-X. If no @option{-net} option is specified, a single
-NIC is created.  QEMU can emulate several different models of network card.
-Valid values for @var{type} are
-@code{virtio}, @code{i82551}, @code{i82557b}, @code{i82559er},
-@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
-@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
-Not all devices are supported on all targets.  Use @code{-net nic,model=help}
-for a list of available devices for your target.
-
-@item -netdev user,id=@var{id}[,@var{option}][,@var{option}][,...]
-@findex -netdev
-@item -net user[,@var{option}][,@var{option}][,...]
-Use the user mode network stack which requires no administrator
-privilege to run. Valid options are:
-
-@table @option
-@item vlan=@var{n}
-Connect user mode stack to VLAN @var{n} (@var{n} = 0 is the default).
-
-@item id=@var{id}
-@itemx name=@var{name}
-Assign symbolic name for use in monitor commands.
-
-@option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must
-be enabled.  If neither is specified both protocols are enabled.
-
-@item net=@var{addr}[/@var{mask}]
-Set IP network address the guest will see. Optionally specify the netmask,
-either in the form a.b.c.d or as number of valid top-most bits. Default is
-10.0.2.0/24.
-
-@item host=@var{addr}
-Specify the guest-visible address of the host. Default is the 2nd IP in the
-guest network, i.e. x.x.x.2.
-
-@item ipv6-net=@var{addr}[/@var{int}]
-Set IPv6 network address the guest will see (default is fec0::/64). The
-network prefix is given in the usual hexadecimal IPv6 address
-notation. The prefix size is optional, and is given as the number of
-valid top-most bits (default is 64).
-
-@item ipv6-host=@var{addr}
-Specify the guest-visible IPv6 address of the host. Default is the 2nd IPv6 in
-the guest network, i.e. xxxx::2.
-
-@item restrict=on|off
-If this option is enabled, the guest will be isolated, i.e. it will not be
-able to contact the host and no guest IP packets will be routed over the host
-to the outside. This option does not affect any explicitly set forwarding rules.
-
-@item hostname=@var{name}
-Specifies the client hostname reported by the built-in DHCP server.
-
-@item dhcpstart=@var{addr}
-Specify the first of the 16 IPs the built-in DHCP server can assign. Default
-is the 15th to 31st IP in the guest network, i.e. x.x.x.15 to x.x.x.31.
-
-@item dns=@var{addr}
-Specify the guest-visible address of the virtual nameserver. The address must
-be different from the host address. Default is the 3rd IP in the guest network,
-i.e. x.x.x.3.
-
-@item ipv6-dns=@var{addr}
-Specify the guest-visible address of the IPv6 virtual nameserver. The address
-must be different from the host address. Default is the 3rd IP in the guest
-network, i.e. xxxx::3.
-
-@item dnssearch=@var{domain}
-Provides an entry for the domain-search list sent by the built-in
-DHCP server. More than one domain suffix can be transmitted by specifying
-this option multiple times. If supported, this will cause the guest to
-automatically try to append the given domain suffix(es) in case a domain name
-can not be resolved.
-
-Example:
-@example
-qemu -net user,dnssearch=mgmt.example.org,dnssearch=example.org [...]
-@end example
-
-@item tftp=@var{dir}
-When using the user mode network stack, activate a built-in TFTP
-server. The files in @var{dir} will be exposed as the root of a TFTP server.
-The TFTP client on the guest must be configured in binary mode (use the command
-@code{bin} of the Unix TFTP client).
-
-@item bootfile=@var{file}
-When using the user mode network stack, broadcast @var{file} as the BOOTP
-filename. In conjunction with @option{tftp}, this can be used to network boot
-a guest from a local directory.
-
-Example (using pxelinux):
-@example
-qemu-system-i386 -hda linux.img -boot n -net user,tftp=/path/to/tftp/files,bootfile=/pxelinux.0
-@end example
-
-@item smb=@var{dir}[,smbserver=@var{addr}]
-When using the user mode network stack, activate a built-in SMB
-server so that Windows OSes can access to the host files in @file{@var{dir}}
-transparently. The IP address of the SMB server can be set to @var{addr}. By
-default the 4th IP in the guest network is used, i.e. x.x.x.4.
-
-In the guest Windows OS, the line:
-@example
-10.0.2.4 smbserver
-@end example
-must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
-or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
-
-Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}.
-
-Note that a SAMBA server must be installed on the host OS.
-QEMU was tested successfully with smbd versions from Red Hat 9,
-Fedora Core 3 and OpenSUSE 11.x.
-
-@item hostfwd=[tcp|udp]:[@var{hostaddr}]:@var{hostport}-[@var{guestaddr}]:@var{guestport}
-Redirect incoming TCP or UDP connections to the host port @var{hostport} to
-the guest IP address @var{guestaddr} on guest port @var{guestport}. If
-@var{guestaddr} is not specified, its value is x.x.x.15 (default first address
-given by the built-in DHCP server). By specifying @var{hostaddr}, the rule can
-be bound to a specific host interface. If no connection type is set, TCP is
-used. This option can be given multiple times.
-
-For example, to redirect host X11 connection from screen 1 to guest
-screen 0, use the following:
-
-@example
-# on the host
-qemu-system-i386 -net user,hostfwd=tcp:127.0.0.1:6001-:6000 [...]
-# this host xterm should open in the guest X11 server
-xterm -display :1
-@end example
-
-To redirect telnet connections from host port 5555 to telnet port on
-the guest, use the following:
-
-@example
-# on the host
-qemu-system-i386 -net user,hostfwd=tcp::5555-:23 [...]
-telnet localhost 5555
-@end example
-
-Then when you use on the host @code{telnet localhost 5555}, you
-connect to the guest telnet server.
-
-@item guestfwd=[tcp]:@var{server}:@var{port}-@var{dev}
-@itemx guestfwd=[tcp]:@var{server}:@var{port}-@var{cmd:command}
-Forward guest TCP connections to the IP address @var{server} on port @var{port}
-to the character device @var{dev} or to a program executed by @var{cmd:command}
-which gets spawned for each connection. This option can be given multiple times.
-
-You can either use a chardev directly and have that one used throughout QEMU's
-lifetime, like in the following example:
-
-@example
-# open 10.10.1.1:4321 on bootup, connect 10.0.2.100:1234 to it whenever
-# the guest accesses it
-qemu -net user,guestfwd=tcp:10.0.2.100:1234-tcp:10.10.1.1:4321 [...]
-@end example
-
-Or you can execute a command on every TCP connection established by the guest,
-so that QEMU behaves similar to an inetd process for that virtual server:
-
-@example
-# call "netcat 10.10.1.1 4321" on every TCP connection to 10.0.2.100:1234
-# and connect the TCP stream to its stdin/stdout
-qemu -net 'user,guestfwd=tcp:10.0.2.100:1234-cmd:netcat 10.10.1.1 4321'
-@end example
-
-@end table
-
-Note: Legacy stand-alone options -tftp, -bootp, -smb and -redir are still
-processed and applied to -net user. Mixing them with the new configuration
-syntax gives undefined results. Their use for new applications is discouraged
-as they will be removed from future versions.
-
-@item -netdev tap,id=@var{id}[,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}]
-@itemx -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}][,br=@var{bridge}][,helper=@var{helper}]
-Connect the host TAP network interface @var{name} to VLAN @var{n}.
-
-Use the network script @var{file} to configure it and the network script
-@var{dfile} to deconfigure it. If @var{name} is not provided, the OS
-automatically provides one. The default network configure script is
-@file{/etc/qemu-ifup} and the default network deconfigure script is
-@file{/etc/qemu-ifdown}. Use @option{script=no} or @option{downscript=no}
-to disable script execution.
-
-If running QEMU as an unprivileged user, use the network helper
-@var{helper} to configure the TAP interface and attach it to the bridge.
-The default network helper executable is @file{/path/to/qemu-bridge-helper}
-and the default bridge device is @file{br0}.
-
-@option{fd}=@var{h} can be used to specify the handle of an already
-opened host TAP interface.
-
-Examples:
-
-@example
-#launch a QEMU instance with the default network script
-qemu-system-i386 linux.img -net nic -net tap
-@end example
-
-@example
-#launch a QEMU instance with two NICs, each one connected
-#to a TAP device
-qemu-system-i386 linux.img \
-                 -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
-                 -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
-@end example
-
-@example
-#launch a QEMU instance with the default network helper to
-#connect a TAP device to bridge br0
-qemu-system-i386 linux.img \
-                 -net nic -net tap,"helper=/path/to/qemu-bridge-helper"
-@end example
-
-@item -netdev bridge,id=@var{id}[,br=@var{bridge}][,helper=@var{helper}]
-@itemx -net bridge[,vlan=@var{n}][,name=@var{name}][,br=@var{bridge}][,helper=@var{helper}]
-Connect a host TAP network interface to a host bridge device.
-
-Use the network helper @var{helper} to configure the TAP interface and
-attach it to the bridge. The default network helper executable is
-@file{/path/to/qemu-bridge-helper} and the default bridge
-device is @file{br0}.
-
-Examples:
-
-@example
-#launch a QEMU instance with the default network helper to
-#connect a TAP device to bridge br0
-qemu-system-i386 linux.img -net bridge -net nic,model=virtio
-@end example
-
-@example
-#launch a QEMU instance with the default network helper to
-#connect a TAP device to bridge qemubr0
-qemu-system-i386 linux.img -net bridge,br=qemubr0 -net nic,model=virtio
-@end example
-
-@item -netdev socket,id=@var{id}[,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
-@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}] [,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
-
-Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
-machine using a TCP socket connection. If @option{listen} is
-specified, QEMU waits for incoming connections on @var{port}
-(@var{host} is optional). @option{connect} is used to connect to
-another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
-specifies an already opened TCP socket.
-
-Example:
-@example
-# launch a first QEMU instance
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:56 \
-                 -net socket,listen=:1234
-# connect the VLAN 0 of this instance to the VLAN 0
-# of the first instance
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:57 \
-                 -net socket,connect=127.0.0.1:1234
-@end example
-
-@item -netdev socket,id=@var{id}[,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]
-@itemx -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}[,localaddr=@var{addr}]]
-
-Create a VLAN @var{n} shared with another QEMU virtual
-machines using a UDP multicast socket, effectively making a bus for
-every QEMU with same multicast address @var{maddr} and @var{port}.
-NOTES:
-@enumerate
-@item
-Several QEMU can be running on different hosts and share same bus (assuming
-correct multicast setup for these hosts).
-@item
-mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
-@url{http://user-mode-linux.sf.net}.
-@item
-Use @option{fd=h} to specify an already opened UDP multicast socket.
-@end enumerate
-
-Example:
-@example
-# launch one QEMU instance
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:56 \
-                 -net socket,mcast=230.0.0.1:1234
-# launch another QEMU instance on same "bus"
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:57 \
-                 -net socket,mcast=230.0.0.1:1234
-# launch yet another QEMU instance on same "bus"
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:58 \
-                 -net socket,mcast=230.0.0.1:1234
-@end example
-
-Example (User Mode Linux compat.):
-@example
-# launch QEMU instance (note mcast address selected
-# is UML's default)
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:56 \
-                 -net socket,mcast=239.192.168.1:1102
-# launch UML
-/path/to/linux ubd0=/path/to/root_fs eth0=mcast
-@end example
-
-Example (send packets from host's 1.2.3.4):
-@example
-qemu-system-i386 linux.img \
-                 -net nic,macaddr=52:54:00:12:34:56 \
-                 -net socket,mcast=239.192.168.1:1102,localaddr=1.2.3.4
-@end example
-
-@item -netdev l2tpv3,id=@var{id},src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]
-@itemx -net l2tpv3[,vlan=@var{n}][,name=@var{name}],src=@var{srcaddr},dst=@var{dstaddr}[,srcport=@var{srcport}][,dstport=@var{dstport}],txsession=@var{txsession}[,rxsession=@var{rxsession}][,ipv6][,udp][,cookie64][,counter][,pincounter][,txcookie=@var{txcookie}][,rxcookie=@var{rxcookie}][,offset=@var{offset}]
-Connect VLAN @var{n} to L2TPv3 pseudowire. L2TPv3 (RFC3391) is a popular
-protocol to transport Ethernet (and other Layer 2) data frames between
-two systems. It is present in routers, firewalls and the Linux kernel
-(from version 3.3 onwards).
-
-This transport allows a VM to communicate to another VM, router or firewall directly.
-
-@table @option
-@item src=@var{srcaddr}
-    source address (mandatory)
-@item dst=@var{dstaddr}
-    destination address (mandatory)
-@item udp
-    select udp encapsulation (default is ip).
-@item srcport=@var{srcport}
-    source udp port.
-@item dstport=@var{dstport}
-    destination udp port.
-@item ipv6
-    force v6, otherwise defaults to v4.
-@item rxcookie=@var{rxcookie}
-@itemx txcookie=@var{txcookie}
-    Cookies are a weak form of security in the l2tpv3 specification.
-Their function is mostly to prevent misconfiguration. By default they are 32
-bit.
-@item cookie64
-    Set cookie size to 64 bit instead of the default 32
-@item counter=off
-    Force a 'cut-down' L2TPv3 with no counter as in
-draft-mkonstan-l2tpext-keyed-ipv6-tunnel-00
-@item pincounter=on
-    Work around broken counter handling in peer. This may also help on
-networks which have packet reorder.
-@item offset=@var{offset}
-    Add an extra offset between header and data
-@end table
-
-For example, to attach a VM running on host 4.3.2.1 via L2TPv3 to the bridge br-lan
-on the remote Linux host 1.2.3.4:
-@example
-# Setup tunnel on linux host using raw ip as encapsulation
-# on 1.2.3.4
-ip l2tp add tunnel remote 4.3.2.1 local 1.2.3.4 tunnel_id 1 peer_tunnel_id 1 \
-    encap udp udp_sport 16384 udp_dport 16384
-ip l2tp add session tunnel_id 1 name vmtunnel0 session_id \
-    0xFFFFFFFF peer_session_id 0xFFFFFFFF
-ifconfig vmtunnel0 mtu 1500
-ifconfig vmtunnel0 up
-brctl addif br-lan vmtunnel0
-
-
-# on 4.3.2.1
-# launch QEMU instance - if your network has reorder or is very lossy add ,pincounter
-
-qemu-system-i386 linux.img -net nic -net l2tpv3,src=4.2.3.1,dst=1.2.3.4,udp,srcport=16384,dstport=16384,rxsession=0xffffffff,txsession=0xffffffff,counter
-
-
-@end example
-
-@item -netdev vde,id=@var{id}[,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
-@itemx -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}] [,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
-Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
-listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
-and MODE @var{octalmode} to change default ownership and permissions for
-communication port. This option is only available if QEMU has been compiled
-with vde support enabled.
-
-Example:
-@example
-# launch vde switch
-vde_switch -F -sock /tmp/myswitch
-# launch QEMU instance
-qemu-system-i386 linux.img -net nic -net vde,sock=/tmp/myswitch
-@end example
-
-@item -netdev hubport,id=@var{id},hubid=@var{hubid}
-
-Create a hub port on QEMU "vlan" @var{hubid}.
-
-The hubport netdev lets you connect a NIC to a QEMU "vlan" instead of a single
-netdev.  @code{-net} and @code{-device} with parameter @option{vlan} create the
-required hub automatically.
-
-@item -netdev vhost-user,chardev=@var{id}[,vhostforce=on|off][,queues=n]
-
-Establish a vhost-user netdev, backed by a chardev @var{id}. The chardev should
-be a unix domain socket backed one. The vhost-user uses a specifically defined
-protocol to pass vhost ioctl replacement messages to an application on the other
-end of the socket. On non-MSIX guests, the feature can be forced with
-@var{vhostforce}. Use 'queues=@var{n}' to specify the number of queues to
-be created for multiqueue vhost-user.
-
-Example:
-@example
-qemu -m 512 -object memory-backend-file,id=mem,size=512M,mem-path=/hugetlbfs,share=on \
-     -numa node,memdev=mem \
-     -chardev socket,id=chr0,path=/path/to/socket \
-     -netdev type=vhost-user,id=net0,chardev=chr0 \
-     -device virtio-net-pci,netdev=net0
-@end example
-
-@item -net dump[,vlan=@var{n}][,file=@var{file}][,len=@var{len}]
-Dump network traffic on VLAN @var{n} to file @var{file} (@file{qemu-vlan0.pcap} by default).
-At most @var{len} bytes (64k by default) per packet are stored. The file format is
-libpcap, so it can be analyzed with tools such as tcpdump or Wireshark.
-Note: For devices created with '-netdev', use '-object filter-dump,...' instead.
-
-@item -net none
-Indicate that no network devices should be configured. It is used to
-override the default configuration (@option{-net nic -net user}) which
-is activated if no @option{-net} options are provided.
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Character device options:)
-
-DEF("chardev", HAS_ARG, QEMU_OPTION_chardev,
-    "-chardev help\n"
-    "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4][,ipv6][,nodelay][,reconnect=seconds]\n"
-    "         [,server][,nowait][,telnet][,reconnect=seconds][,mux=on|off]\n"
-    "         [,logfile=PATH][,logappend=on|off][,tls-creds=ID] (tcp)\n"
-    "-chardev socket,id=id,path=path[,server][,nowait][,telnet][,reconnect=seconds]\n"
-    "         [,mux=on|off][,logfile=PATH][,logappend=on|off] (unix)\n"
-    "-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]\n"
-    "         [,localport=localport][,ipv4][,ipv6][,mux=on|off]\n"
-    "         [,logfile=PATH][,logappend=on|off]\n"
-    "-chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n"
-    "         [,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-#ifdef _WIN32
-    "-chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-#else
-    "-chardev pty,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev stdio,id=id[,mux=on|off][,signal=on|off][,logfile=PATH][,logappend=on|off]\n"
-#endif
-#ifdef CONFIG_BRLAPI
-    "-chardev braille,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-#endif
-#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
-        || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
-    "-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev tty,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-#endif
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__)
-    "-chardev parallel,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev parport,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n"
-#endif
-#if defined(CONFIG_SPICE)
-    "-chardev spicevmc,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n"
-    "-chardev spiceport,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n"
-#endif
-    , QEMU_ARCH_ALL
-)
-
-STEXI
-
-The general form of a character device option is:
-@table @option
-@item -chardev @var{backend} ,id=@var{id} [,mux=on|off] [,@var{options}]
-@findex -chardev
-Backend is one of:
-@option{null},
-@option{socket},
-@option{udp},
-@option{msmouse},
-@option{vc},
-@option{ringbuf},
-@option{file},
-@option{pipe},
-@option{console},
-@option{serial},
-@option{pty},
-@option{stdio},
-@option{braille},
-@option{tty},
-@option{parallel},
-@option{parport},
-@option{spicevmc}.
-@option{spiceport}.
-The specific backend will determine the applicable options.
-
-Use @code{-chardev help} to print all available chardev backend types.
-
-All devices must have an id, which can be any string up to 127 characters long.
-It is used to uniquely identify this device in other command line directives.
-
-A character device may be used in multiplexing mode by multiple front-ends.
-Specify @option{mux=on} to enable this mode.
-A multiplexer is a "1:N" device, and here the "1" end is your specified chardev
-backend, and the "N" end is the various parts of QEMU that can talk to a chardev.
-If you create a chardev with @option{id=myid} and @option{mux=on}, QEMU will
-create a multiplexer with your specified ID, and you can then configure multiple
-front ends to use that chardev ID for their input/output. Up to four different
-front ends can be connected to a single multiplexed chardev. (Without
-multiplexing enabled, a chardev can only be used by a single front end.)
-For instance you could use this to allow a single stdio chardev to be used by
-two serial ports and the QEMU monitor:
-
-@example
--chardev stdio,mux=on,id=char0 \
--mon chardev=char0,mode=readline \
--serial chardev:char0 \
--serial chardev:char0
-@end example
-
-You can have more than one multiplexer in a system configuration; for instance
-you could have a TCP port multiplexed between UART 0 and UART 1, and stdio
-multiplexed between the QEMU monitor and a parallel port:
-
-@example
--chardev stdio,mux=on,id=char0 \
--mon chardev=char0,mode=readline \
--parallel chardev:char0 \
--chardev tcp,...,mux=on,id=char1 \
--serial chardev:char1 \
--serial chardev:char1
-@end example
-
-When you're using a multiplexed character device, some escape sequences are
-interpreted in the input. @xref{mux_keys, Keys in the character backend
-multiplexer}.
-
-Note that some other command line options may implicitly create multiplexed
-character backends; for instance @option{-serial mon:stdio} creates a
-multiplexed stdio backend connected to the serial port and the QEMU monitor,
-and @option{-nographic} also multiplexes the console and the monitor to
-stdio.
-
-There is currently no support for multiplexing in the other direction
-(where a single QEMU front end takes input and output from multiple chardevs).
-
-Every backend supports the @option{logfile} option, which supplies the path
-to a file to record all data transmitted via the backend. The @option{logappend}
-option controls whether the log file will be truncated or appended to when
-opened.
-
-@end table
-
-The available backends are:
-
-@table @option
-@item -chardev null ,id=@var{id}
-A void device. This device will not emit any data, and will drop any data it
-receives. The null backend does not take any options.
-
-@item -chardev socket ,id=@var{id} [@var{TCP options} or @var{unix options}] [,server] [,nowait] [,telnet] [,reconnect=@var{seconds}] [,tls-creds=@var{id}]
-
-Create a two-way stream socket, which can be either a TCP or a unix socket. A
-unix socket will be created if @option{path} is specified. Behaviour is
-undefined if TCP options are specified for a unix socket.
-
-@option{server} specifies that the socket shall be a listening socket.
-
-@option{nowait} specifies that QEMU should not block waiting for a client to
-connect to a listening socket.
-
-@option{telnet} specifies that traffic on the socket should interpret telnet
-escape sequences.
-
-@option{reconnect} sets the timeout for reconnecting on non-server sockets when
-the remote end goes away.  qemu will delay this many seconds and then attempt
-to reconnect.  Zero disables reconnecting, and is the default.
-
-@option{tls-creds} requests enablement of the TLS protocol for encryption,
-and specifies the id of the TLS credentials to use for the handshake. The
-credentials must be previously created with the @option{-object tls-creds}
-argument.
-
-TCP and unix socket options are given below:
-
-@table @option
-
-@item TCP options: port=@var{port} [,host=@var{host}] [,to=@var{to}] [,ipv4] [,ipv6] [,nodelay]
-
-@option{host} for a listening socket specifies the local address to be bound.
-For a connecting socket species the remote host to connect to. @option{host} is
-optional for listening sockets. If not specified it defaults to @code{0.0.0.0}.
-
-@option{port} for a listening socket specifies the local port to be bound. For a
-connecting socket specifies the port on the remote host to connect to.
-@option{port} can be given as either a port number or a service name.
-@option{port} is required.
-
-@option{to} is only relevant to listening sockets. If it is specified, and
-@option{port} cannot be bound, QEMU will attempt to bind to subsequent ports up
-to and including @option{to} until it succeeds. @option{to} must be specified
-as a port number.
-
-@option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must be used.
-If neither is specified the socket may use either protocol.
-
-@option{nodelay} disables the Nagle algorithm.
-
-@item unix options: path=@var{path}
-
-@option{path} specifies the local path of the unix socket. @option{path} is
-required.
-
-@end table
-
-@item -chardev udp ,id=@var{id} [,host=@var{host}] ,port=@var{port} [,localaddr=@var{localaddr}] [,localport=@var{localport}] [,ipv4] [,ipv6]
-
-Sends all traffic from the guest to a remote host over UDP.
-
-@option{host} specifies the remote host to connect to. If not specified it
-defaults to @code{localhost}.
-
-@option{port} specifies the port on the remote host to connect to. @option{port}
-is required.
-
-@option{localaddr} specifies the local address to bind to. If not specified it
-defaults to @code{0.0.0.0}.
-
-@option{localport} specifies the local port to bind to. If not specified any
-available local port will be used.
-
-@option{ipv4} and @option{ipv6} specify that either IPv4 or IPv6 must be used.
-If neither is specified the device may use either protocol.
-
-@item -chardev msmouse ,id=@var{id}
-
-Forward QEMU's emulated msmouse events to the guest. @option{msmouse} does not
-take any options.
-
-@item -chardev vc ,id=@var{id} [[,width=@var{width}] [,height=@var{height}]] [[,cols=@var{cols}] [,rows=@var{rows}]]
-
-Connect to a QEMU text console. @option{vc} may optionally be given a specific
-size.
-
-@option{width} and @option{height} specify the width and height respectively of
-the console, in pixels.
-
-@option{cols} and @option{rows} specify that the console be sized to fit a text
-console with the given dimensions.
-
-@item -chardev ringbuf ,id=@var{id} [,size=@var{size}]
-
-Create a ring buffer with fixed size @option{size}.
-@var{size} must be a power of two and defaults to @code{64K}.
-
-@item -chardev file ,id=@var{id} ,path=@var{path}
-
-Log all traffic received from the guest to a file.
-
-@option{path} specifies the path of the file to be opened. This file will be
-created if it does not already exist, and overwritten if it does. @option{path}
-is required.
-
-@item -chardev pipe ,id=@var{id} ,path=@var{path}
-
-Create a two-way connection to the guest. The behaviour differs slightly between
-Windows hosts and other hosts:
-
-On Windows, a single duplex pipe will be created at
-@file{\\.pipe\@option{path}}.
-
-On other hosts, 2 pipes will be created called @file{@option{path}.in} and
-@file{@option{path}.out}. Data written to @file{@option{path}.in} will be
-received by the guest. Data written by the guest can be read from
-@file{@option{path}.out}. QEMU will not create these fifos, and requires them to
-be present.
-
-@option{path} forms part of the pipe path as described above. @option{path} is
-required.
-
-@item -chardev console ,id=@var{id}
-
-Send traffic from the guest to QEMU's standard output. @option{console} does not
-take any options.
-
-@option{console} is only available on Windows hosts.
-
-@item -chardev serial ,id=@var{id} ,path=@option{path}
-
-Send traffic from the guest to a serial device on the host.
-
-On Unix hosts serial will actually accept any tty device,
-not only serial lines.
-
-@option{path} specifies the name of the serial device to open.
-
-@item -chardev pty ,id=@var{id}
-
-Create a new pseudo-terminal on the host and connect to it. @option{pty} does
-not take any options.
-
-@option{pty} is not available on Windows hosts.
-
-@item -chardev stdio ,id=@var{id} [,signal=on|off]
-Connect to standard input and standard output of the QEMU process.
-
-@option{signal} controls if signals are enabled on the terminal, that includes
-exiting QEMU with the key sequence @key{Control-c}. This option is enabled by
-default, use @option{signal=off} to disable it.
-
-@item -chardev braille ,id=@var{id}
-
-Connect to a local BrlAPI server. @option{braille} does not take any options.
-
-@item -chardev tty ,id=@var{id} ,path=@var{path}
-
-@option{tty} is only available on Linux, Sun, FreeBSD, NetBSD, OpenBSD and
-DragonFlyBSD hosts.  It is an alias for @option{serial}.
-
-@option{path} specifies the path to the tty. @option{path} is required.
-
-@item -chardev parallel ,id=@var{id} ,path=@var{path}
-@itemx -chardev parport ,id=@var{id} ,path=@var{path}
-
-@option{parallel} is only available on Linux, FreeBSD and DragonFlyBSD hosts.
-
-Connect to a local parallel port.
-
-@option{path} specifies the path to the parallel port device. @option{path} is
-required.
-
-@item -chardev spicevmc ,id=@var{id} ,debug=@var{debug}, name=@var{name}
-
-@option{spicevmc} is only available when spice support is built in.
-
-@option{debug} debug level for spicevmc
-
-@option{name} name of spice channel to connect to
-
-Connect to a spice virtual machine channel, such as vdiport.
-
-@item -chardev spiceport ,id=@var{id} ,debug=@var{debug}, name=@var{name}
-
-@option{spiceport} is only available when spice support is built in.
-
-@option{debug} debug level for spicevmc
-
-@option{name} name of spice port to connect to
-
-Connect to a spice port, allowing a Spice client to handle the traffic
-identified by a name (preferably a fqdn).
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Bluetooth(R) options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("bt", HAS_ARG, QEMU_OPTION_bt, \
-    "-bt hci,null    dumb bluetooth HCI - doesn't respond to commands\n" \
-    "-bt hci,host[:id]\n" \
-    "                use host's HCI with the given name\n" \
-    "-bt hci[,vlan=n]\n" \
-    "                emulate a standard HCI in virtual scatternet 'n'\n" \
-    "-bt vhci[,vlan=n]\n" \
-    "                add host computer to virtual scatternet 'n' using VHCI\n" \
-    "-bt device:dev[,vlan=n]\n" \
-    "                emulate a bluetooth device 'dev' in scatternet 'n'\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -bt hci[...]
-@findex -bt
-Defines the function of the corresponding Bluetooth HCI.  -bt options
-are matched with the HCIs present in the chosen machine type.  For
-example when emulating a machine with only one HCI built into it, only
-the first @code{-bt hci[...]} option is valid and defines the HCI's
-logic.  The Transport Layer is decided by the machine type.  Currently
-the machines @code{n800} and @code{n810} have one HCI and all other
-machines have none.
-
-@anchor{bt-hcis}
-The following three types are recognized:
-
-@table @option
-@item -bt hci,null
-(default) The corresponding Bluetooth HCI assumes no internal logic
-and will not respond to any HCI commands or emit events.
-
-@item -bt hci,host[:@var{id}]
-(@code{bluez} only) The corresponding HCI passes commands / events
-to / from the physical HCI identified by the name @var{id} (default:
-@code{hci0}) on the computer running QEMU.  Only available on @code{bluez}
-capable systems like Linux.
-
-@item -bt hci[,vlan=@var{n}]
-Add a virtual, standard HCI that will participate in the Bluetooth
-scatternet @var{n} (default @code{0}).  Similarly to @option{-net}
-VLANs, devices inside a bluetooth network @var{n} can only communicate
-with other devices in the same network (scatternet).
-@end table
-
-@item -bt vhci[,vlan=@var{n}]
-(Linux-host only) Create a HCI in scatternet @var{n} (default 0) attached
-to the host bluetooth stack instead of to the emulated target.  This
-allows the host and target machines to participate in a common scatternet
-and communicate.  Requires the Linux @code{vhci} driver installed.  Can
-be used as following:
-
-@example
-qemu-system-i386 [...OPTIONS...] -bt hci,vlan=5 -bt vhci,vlan=5
-@end example
-
-@item -bt device:@var{dev}[,vlan=@var{n}]
-Emulate a bluetooth device @var{dev} and place it in network @var{n}
-(default @code{0}).  QEMU can only emulate one type of bluetooth devices
-currently:
-
-@table @option
-@item keyboard
-Virtual wireless keyboard implementing the HIDP bluetooth profile.
-@end table
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-#ifdef CONFIG_TPM
-DEFHEADING(TPM device options:)
-
-DEF("tpmdev", HAS_ARG, QEMU_OPTION_tpmdev, \
-    "-tpmdev passthrough,id=id[,path=path][,cancel-path=path]\n"
-    "                use path to provide path to a character device; default is /dev/tpm0\n"
-    "                use cancel-path to provide path to TPM's cancel sysfs entry; if\n"
-    "                not provided it will be searched for in /sys/class/misc/tpm?/device\n",
-    QEMU_ARCH_ALL)
-STEXI
-
-The general form of a TPM device option is:
-@table @option
-
-@item -tpmdev @var{backend} ,id=@var{id} [,@var{options}]
-@findex -tpmdev
-
-The specific backend type will determine the applicable options.
-The @code{-tpmdev} option creates the TPM backend and requires a
-@code{-device} option that specifies the TPM frontend interface model.
-
-Use @code{-tpmdev help} to print all available TPM backend types.
-
-@end table
-
-The available backends are:
-
-@table @option
-
-@item -tpmdev passthrough, id=@var{id}, path=@var{path}, cancel-path=@var{cancel-path}
-
-(Linux-host only) Enable access to the host's TPM using the passthrough
-driver.
-
-@option{path} specifies the path to the host's TPM device, i.e., on
-a Linux host this would be @code{/dev/tpm0}.
-@option{path} is optional and by default @code{/dev/tpm0} is used.
-
-@option{cancel-path} specifies the path to the host TPM device's sysfs
-entry allowing for cancellation of an ongoing TPM command.
-@option{cancel-path} is optional and by default QEMU will search for the
-sysfs entry to use.
-
-Some notes about using the host's TPM with the passthrough driver:
-
-The TPM device accessed by the passthrough driver must not be
-used by any other application on the host.
-
-Since the host's firmware (BIOS/UEFI) has already initialized the TPM,
-the VM's firmware (BIOS/UEFI) will not be able to initialize the
-TPM again and may therefore not show a TPM-specific menu that would
-otherwise allow the user to configure the TPM, e.g., allow the user to
-enable/disable or activate/deactivate the TPM.
-Further, if TPM ownership is released from within a VM then the host's TPM
-will get disabled and deactivated. To enable and activate the
-TPM again afterwards, the host has to be rebooted and the user is
-required to enter the firmware's menu to enable and activate the TPM.
-If the TPM is left disabled and/or deactivated most TPM commands will fail.
-
-To create a passthrough TPM use the following two options:
-@example
--tpmdev passthrough,id=tpm0 -device tpm-tis,tpmdev=tpm0
-@end example
-Note that the @code{-tpmdev} id is @code{tpm0} and is referenced by
-@code{tpmdev=tpm0} in the device option.
-
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-#endif
-
-DEFHEADING(Linux/Multiboot boot specific:)
-STEXI
-
-When using these options, you can use a given Linux or Multiboot
-kernel without installing it in the disk image. It can be useful
-for easier testing of various kernels.
-
-@table @option
-ETEXI
-
-DEF("kernel", HAS_ARG, QEMU_OPTION_kernel, \
-    "-kernel bzImage use 'bzImage' as kernel image\n", QEMU_ARCH_ALL)
-STEXI
-@item -kernel @var{bzImage}
-@findex -kernel
-Use @var{bzImage} as kernel image. The kernel can be either a Linux kernel
-or in multiboot format.
-ETEXI
-
-DEF("append", HAS_ARG, QEMU_OPTION_append, \
-    "-append cmdline use 'cmdline' as kernel command line\n", QEMU_ARCH_ALL)
-STEXI
-@item -append @var{cmdline}
-@findex -append
-Use @var{cmdline} as kernel command line
-ETEXI
-
-DEF("initrd", HAS_ARG, QEMU_OPTION_initrd, \
-           "-initrd file    use 'file' as initial ram disk\n", QEMU_ARCH_ALL)
-STEXI
-@item -initrd @var{file}
-@findex -initrd
-Use @var{file} as initial ram disk.
-
-@item -initrd "@var{file1} arg=foo,@var{file2}"
-
-This syntax is only available with multiboot.
-
-Use @var{file1} and @var{file2} as modules and pass arg=foo as parameter to the
-first module.
-ETEXI
-
-DEF("dtb", HAS_ARG, QEMU_OPTION_dtb, \
-    "-dtb    file    use 'file' as device tree image\n", QEMU_ARCH_ALL)
-STEXI
-@item -dtb @var{file}
-@findex -dtb
-Use @var{file} as a device tree binary (dtb) image and pass it to the kernel
-on boot.
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Debug/Expert options:)
-STEXI
-@table @option
-ETEXI
-
-DEF("fw_cfg", HAS_ARG, QEMU_OPTION_fwcfg,
-    "-fw_cfg [name=]<name>,file=<file>\n"
-    "                add named fw_cfg entry with contents from file\n"
-    "-fw_cfg [name=]<name>,string=<str>\n"
-    "                add named fw_cfg entry with contents from string\n",
-    QEMU_ARCH_ALL)
-STEXI
-
-@item -fw_cfg [name=]@var{name},file=@var{file}
-@findex -fw_cfg
-Add named fw_cfg entry with contents from file @var{file}.
-
-@item -fw_cfg [name=]@var{name},string=@var{str}
-Add named fw_cfg entry with contents from string @var{str}.
-
-The terminating NUL character of the contents of @var{str} will not be
-included as part of the fw_cfg item data. To insert contents with
-embedded NUL characters, you have to use the @var{file} parameter.
-
-The fw_cfg entries are passed by QEMU through to the guest.
-
-Example:
-@example
-    -fw_cfg name=opt/com.mycompany/blob,file=./my_blob.bin
-@end example
-creates an fw_cfg entry named opt/com.mycompany/blob with contents
-from ./my_blob.bin.
-
-ETEXI
-
-DEF("serial", HAS_ARG, QEMU_OPTION_serial, \
-    "-serial dev     redirect the serial port to char device 'dev'\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -serial @var{dev}
-@findex -serial
-Redirect the virtual serial port to host character device
-@var{dev}. The default device is @code{vc} in graphical mode and
-@code{stdio} in non graphical mode.
-
-This option can be used several times to simulate up to 4 serial
-ports.
-
-Use @code{-serial none} to disable all serial ports.
-
-Available character devices are:
-@table @option
-@item vc[:@var{W}x@var{H}]
-Virtual console. Optionally, a width and height can be given in pixel with
-@example
-vc:800x600
-@end example
-It is also possible to specify width or height in characters:
-@example
-vc:80Cx24C
-@end example
-@item pty
-[Linux only] Pseudo TTY (a new PTY is automatically allocated)
-@item none
-No device is allocated.
-@item null
-void device
-@item chardev:@var{id}
-Use a named character device defined with the @code{-chardev} option.
-@item /dev/XXX
-[Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
-parameters are set according to the emulated ones.
-@item /dev/parport@var{N}
-[Linux only, parallel port only] Use host parallel port
-@var{N}. Currently SPP and EPP parallel port features can be used.
-@item file:@var{filename}
-Write output to @var{filename}. No character can be read.
-@item stdio
-[Unix only] standard input/output
-@item pipe:@var{filename}
-name pipe @var{filename}
-@item COM@var{n}
-[Windows only] Use host serial port @var{n}
-@item udp:[@var{remote_host}]:@var{remote_port}[@@[@var{src_ip}]:@var{src_port}]
-This implements UDP Net Console.
-When @var{remote_host} or @var{src_ip} are not specified
-they default to @code{0.0.0.0}.
-When not using a specified @var{src_port} a random port is automatically chosen.
-
-If you just want a simple readonly console you can use @code{netcat} or
-@code{nc}, by starting QEMU with: @code{-serial udp::4555} and nc as:
-@code{nc -u -l -p 4555}. Any time QEMU writes something to that port it
-will appear in the netconsole session.
-
-If you plan to send characters back via netconsole or you want to stop
-and start QEMU a lot of times, you should have QEMU use the same
-source port each time by using something like @code{-serial
-udp::4555@@:4556} to QEMU. Another approach is to use a patched
-version of netcat which can listen to a TCP port and send and receive
-characters via udp.  If you have a patched version of netcat which
-activates telnet remote echo and single char transfer, then you can
-use the following options to set up a netcat redirector to allow
-telnet on port 5555 to access the QEMU port.
-@table @code
-@item QEMU Options:
--serial udp::4555@@:4556
-@item netcat options:
--u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
-@item telnet options:
-localhost 5555
-@end table
-
-@item tcp:[@var{host}]:@var{port}[,@var{server}][,nowait][,nodelay][,reconnect=@var{seconds}]
-The TCP Net Console has two modes of operation.  It can send the serial
-I/O to a location or wait for a connection from a location.  By default
-the TCP Net Console is sent to @var{host} at the @var{port}.  If you use
-the @var{server} option QEMU will wait for a client socket application
-to connect to the port before continuing, unless the @code{nowait}
-option was specified.  The @code{nodelay} option disables the Nagle buffering
-algorithm.  The @code{reconnect} option only applies if @var{noserver} is
-set, if the connection goes down it will attempt to reconnect at the
-given interval.  If @var{host} is omitted, 0.0.0.0 is assumed. Only
-one TCP connection at a time is accepted. You can use @code{telnet} to
-connect to the corresponding character device.
-@table @code
-@item Example to send tcp console to 192.168.0.2 port 4444
--serial tcp:192.168.0.2:4444
-@item Example to listen and wait on port 4444 for connection
--serial tcp::4444,server
-@item Example to not wait and listen on ip 192.168.0.100 port 4444
--serial tcp:192.168.0.100:4444,server,nowait
-@end table
-
-@item telnet:@var{host}:@var{port}[,server][,nowait][,nodelay]
-The telnet protocol is used instead of raw tcp sockets.  The options
-work the same as if you had specified @code{-serial tcp}.  The
-difference is that the port acts like a telnet server or client using
-telnet option negotiation.  This will also allow you to send the
-MAGIC_SYSRQ sequence if you use a telnet that supports sending the break
-sequence.  Typically in unix telnet you do it with Control-] and then
-type "send break" followed by pressing the enter key.
-
-@item unix:@var{path}[,server][,nowait][,reconnect=@var{seconds}]
-A unix domain socket is used instead of a tcp socket.  The option works the
-same as if you had specified @code{-serial tcp} except the unix domain socket
-@var{path} is used for connections.
-
-@item mon:@var{dev_string}
-This is a special option to allow the monitor to be multiplexed onto
-another serial port.  The monitor is accessed with key sequence of
-@key{Control-a} and then pressing @key{c}.
-@var{dev_string} should be any one of the serial devices specified
-above.  An example to multiplex the monitor onto a telnet server
-listening on port 4444 would be:
-@table @code
-@item -serial mon:telnet::4444,server,nowait
-@end table
-When the monitor is multiplexed to stdio in this way, Ctrl+C will not terminate
-QEMU any more but will be passed to the guest instead.
-
-@item braille
-Braille device.  This will use BrlAPI to display the braille output on a real
-or fake device.
-
-@item msmouse
-Three button serial mouse. Configure the guest to use Microsoft protocol.
-@end table
-ETEXI
-
-DEF("parallel", HAS_ARG, QEMU_OPTION_parallel, \
-    "-parallel dev   redirect the parallel port to char device 'dev'\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -parallel @var{dev}
-@findex -parallel
-Redirect the virtual parallel port to host device @var{dev} (same
-devices as the serial port). On Linux hosts, @file{/dev/parportN} can
-be used to use hardware devices connected on the corresponding host
-parallel port.
-
-This option can be used several times to simulate up to 3 parallel
-ports.
-
-Use @code{-parallel none} to disable all parallel ports.
-ETEXI
-
-DEF("monitor", HAS_ARG, QEMU_OPTION_monitor, \
-    "-monitor dev    redirect the monitor to char device 'dev'\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -monitor @var{dev}
-@findex -monitor
-Redirect the monitor to host device @var{dev} (same devices as the
-serial port).
-The default device is @code{vc} in graphical mode and @code{stdio} in
-non graphical mode.
-Use @code{-monitor none} to disable the default monitor.
-ETEXI
-DEF("qmp", HAS_ARG, QEMU_OPTION_qmp, \
-    "-qmp dev        like -monitor but opens in 'control' mode\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -qmp @var{dev}
-@findex -qmp
-Like -monitor but opens in 'control' mode.
-ETEXI
-DEF("qmp-pretty", HAS_ARG, QEMU_OPTION_qmp_pretty, \
-    "-qmp-pretty dev like -qmp but uses pretty JSON formatting\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -qmp-pretty @var{dev}
-@findex -qmp-pretty
-Like -qmp but uses pretty JSON formatting.
-ETEXI
-
-DEF("mon", HAS_ARG, QEMU_OPTION_mon, \
-    "-mon [chardev=]name[,mode=readline|control]\n", QEMU_ARCH_ALL)
-STEXI
-@item -mon [chardev=]name[,mode=readline|control]
-@findex -mon
-Setup monitor on chardev @var{name}.
-ETEXI
-
-DEF("debugcon", HAS_ARG, QEMU_OPTION_debugcon, \
-    "-debugcon dev   redirect the debug console to char device 'dev'\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -debugcon @var{dev}
-@findex -debugcon
-Redirect the debug console to host device @var{dev} (same devices as the
-serial port).  The debug console is an I/O port which is typically port
-0xe9; writing to that I/O port sends output to this device.
-The default device is @code{vc} in graphical mode and @code{stdio} in
-non graphical mode.
-ETEXI
-
-DEF("pidfile", HAS_ARG, QEMU_OPTION_pidfile, \
-    "-pidfile file   write PID to 'file'\n", QEMU_ARCH_ALL)
-STEXI
-@item -pidfile @var{file}
-@findex -pidfile
-Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
-from a script.
-ETEXI
-
-DEF("singlestep", 0, QEMU_OPTION_singlestep, \
-    "-singlestep     always run in singlestep mode\n", QEMU_ARCH_ALL)
-STEXI
-@item -singlestep
-@findex -singlestep
-Run the emulation in single step mode.
-ETEXI
-
-DEF("S", 0, QEMU_OPTION_S, \
-    "-S              freeze CPU at startup (use 'c' to start execution)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -S
-@findex -S
-Do not start CPU at startup (you must type 'c' in the monitor).
-ETEXI
-
-DEF("realtime", HAS_ARG, QEMU_OPTION_realtime,
-    "-realtime [mlock=on|off]\n"
-    "                run qemu with realtime features\n"
-    "                mlock=on|off controls mlock support (default: on)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -realtime mlock=on|off
-@findex -realtime
-Run qemu with realtime features.
-mlocking qemu and guest memory can be enabled via @option{mlock=on}
-(enabled by default).
-ETEXI
-
-DEF("gdb", HAS_ARG, QEMU_OPTION_gdb, \
-    "-gdb dev        wait for gdb connection on 'dev'\n", QEMU_ARCH_ALL)
-STEXI
-@item -gdb @var{dev}
-@findex -gdb
-Wait for gdb connection on device @var{dev} (@pxref{gdb_usage}). Typical
-connections will likely be TCP-based, but also UDP, pseudo TTY, or even
-stdio are reasonable use case. The latter is allowing to start QEMU from
-within gdb and establish the connection via a pipe:
-@example
-(gdb) target remote | exec qemu-system-i386 -gdb stdio ...
-@end example
-ETEXI
-
-DEF("s", 0, QEMU_OPTION_s, \
-    "-s              shorthand for -gdb tcp::" DEFAULT_GDBSTUB_PORT "\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -s
-@findex -s
-Shorthand for -gdb tcp::1234, i.e. open a gdbserver on TCP port 1234
-(@pxref{gdb_usage}).
-ETEXI
-
-DEF("d", HAS_ARG, QEMU_OPTION_d, \
-    "-d item1,...    enable logging of specified items (use '-d help' for a list of log items)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -d @var{item1}[,...]
-@findex -d
-Enable logging of specified items. Use '-d help' for a list of log items.
-ETEXI
-
-DEF("D", HAS_ARG, QEMU_OPTION_D, \
-    "-D logfile      output log to logfile (default stderr)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -D @var{logfile}
-@findex -D
-Output log in @var{logfile} instead of to stderr
-ETEXI
-
-DEF("dfilter", HAS_ARG, QEMU_OPTION_DFILTER, \
-    "-dfilter range,..  filter debug output to range of addresses (useful for -d cpu,exec,etc..)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -dfilter @var{range1}[,...]
-@findex -dfilter
-Filter debug output to that relevant to a range of target addresses. The filter
-spec can be either @var{start}+@var{size}, @var{start}-@var{size} or
-@var{start}..@var{end} where @var{start} @var{end} and @var{size} are the
-addresses and sizes required. For example:
-@example
-    -dfilter 0x8000..0x8fff,0xffffffc000080000+0x200,0xffffffc000060000-0x1000
-@end example
-Will dump output for any code in the 0x1000 sized block starting at 0x8000 and
-the 0x200 sized block starting at 0xffffffc000080000 and another 0x1000 sized
-block starting at 0xffffffc00005f000.
-ETEXI
-
-DEF("L", HAS_ARG, QEMU_OPTION_L, \
-    "-L path         set the directory for the BIOS, VGA BIOS and keymaps\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -L  @var{path}
-@findex -L
-Set the directory for the BIOS, VGA BIOS and keymaps.
-
-To list all the data directories, use @code{-L help}.
-ETEXI
-
-DEF("bios", HAS_ARG, QEMU_OPTION_bios, \
-    "-bios file      set the filename for the BIOS\n", QEMU_ARCH_ALL)
-STEXI
-@item -bios @var{file}
-@findex -bios
-Set the filename for the BIOS.
-ETEXI
-
-DEF("enable-kvm", 0, QEMU_OPTION_enable_kvm, \
-    "-enable-kvm     enable KVM full virtualization support\n", QEMU_ARCH_ALL)
-STEXI
-@item -enable-kvm
-@findex -enable-kvm
-Enable KVM full virtualization support. This option is only available
-if KVM support is enabled when compiling.
-ETEXI
-
-DEF("enable-hax", 0, QEMU_OPTION_enable_hax, \
-    "-enable-hax     enable HAX virtualization support\n", QEMU_ARCH_I386)
-STEXI
-@item -enable-hax
-@findex -enable-hax
-Enable HAX (Hardware-based Acceleration eXecution) support. This option
-is only available if HAX support is enabled when compiling. HAX is only
-applicable to MAC and Windows platform, and thus does not conflict with
-KVM.
-ETEXI
-
-DEF("xen-domid", HAS_ARG, QEMU_OPTION_xen_domid,
-    "-xen-domid id   specify xen guest domain id\n", QEMU_ARCH_ALL)
-DEF("xen-create", 0, QEMU_OPTION_xen_create,
-    "-xen-create     create domain using xen hypercalls, bypassing xend\n"
-    "                warning: should not be used when xend is in use\n",
-    QEMU_ARCH_ALL)
-DEF("xen-attach", 0, QEMU_OPTION_xen_attach,
-    "-xen-attach     attach to existing xen domain\n"
-    "                xend will use this when starting QEMU\n",
-    QEMU_ARCH_ALL)
-DEF("xen-domid-restrict", 0, QEMU_OPTION_xen_domid_restrict,
-    "-xen-domid-restrict     restrict set of available xen operations\n"
-    "                        to specified domain id. (Does not affect\n"
-    "                        xenpv machine type).\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -xen-domid @var{id}
-@findex -xen-domid
-Specify xen guest domain @var{id} (XEN only).
-@item -xen-create
-@findex -xen-create
-Create domain using xen hypercalls, bypassing xend.
-Warning: should not be used when xend is in use (XEN only).
-@item -xen-attach
-@findex -xen-attach
-Attach to existing xen domain.
-xend will use this when starting QEMU (XEN only).
-@findex -xen-domid-restrict
-Restrict set of available xen operations to specified domain id (XEN only).
-ETEXI
-
-DEF("no-reboot", 0, QEMU_OPTION_no_reboot, \
-    "-no-reboot      exit instead of rebooting\n", QEMU_ARCH_ALL)
-STEXI
-@item -no-reboot
-@findex -no-reboot
-Exit instead of rebooting.
-ETEXI
-
-DEF("no-shutdown", 0, QEMU_OPTION_no_shutdown, \
-    "-no-shutdown    stop before shutdown\n", QEMU_ARCH_ALL)
-STEXI
-@item -no-shutdown
-@findex -no-shutdown
-Don't exit QEMU on guest shutdown, but instead only stop the emulation.
-This allows for instance switching to monitor to commit changes to the
-disk image.
-ETEXI
-
-DEF("loadvm", HAS_ARG, QEMU_OPTION_loadvm, \
-    "-loadvm [tag|id]\n" \
-    "                start right away with a saved state (loadvm in monitor)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -loadvm @var{file}
-@findex -loadvm
-Start right away with a saved state (@code{loadvm} in monitor)
-ETEXI
-
-#ifndef _WIN32
-DEF("daemonize", 0, QEMU_OPTION_daemonize, \
-    "-daemonize      daemonize QEMU after initializing\n", QEMU_ARCH_ALL)
-#endif
-STEXI
-@item -daemonize
-@findex -daemonize
-Daemonize the QEMU process after initialization.  QEMU will not detach from
-standard IO until it is ready to receive connections on any of its devices.
-This option is a useful way for external programs to launch QEMU without having
-to cope with initialization race conditions.
-ETEXI
-
-DEF("option-rom", HAS_ARG, QEMU_OPTION_option_rom, \
-    "-option-rom rom load a file, rom, into the option ROM space\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -option-rom @var{file}
-@findex -option-rom
-Load the contents of @var{file} as an option ROM.
-This option is useful to load things like EtherBoot.
-ETEXI
-
-HXCOMM Silently ignored for compatibility
-DEF("clock", HAS_ARG, QEMU_OPTION_clock, "", QEMU_ARCH_ALL)
-
-HXCOMM Options deprecated by -rtc
-DEF("localtime", 0, QEMU_OPTION_localtime, "", QEMU_ARCH_ALL)
-DEF("startdate", HAS_ARG, QEMU_OPTION_startdate, "", QEMU_ARCH_ALL)
-
-DEF("rtc", HAS_ARG, QEMU_OPTION_rtc, \
-    "-rtc [base=utc|localtime|date][,clock=host|rt|vm][,driftfix=none|slew]\n" \
-    "                set the RTC base and clock, enable drift fix for clock ticks (x86 only)\n",
-    QEMU_ARCH_ALL)
-
-STEXI
-
-@item -rtc [base=utc|localtime|@var{date}][,clock=host|vm][,driftfix=none|slew]
-@findex -rtc
-Specify @option{base} as @code{utc} or @code{localtime} to let the RTC start at the current
-UTC or local time, respectively. @code{localtime} is required for correct date in
-MS-DOS or Windows. To start at a specific point in time, provide @var{date} in the
-format @code{2006-06-17T16:01:21} or @code{2006-06-17}. The default base is UTC.
-
-By default the RTC is driven by the host system time. This allows using of the
-RTC as accurate reference clock inside the guest, specifically if the host
-time is smoothly following an accurate external reference clock, e.g. via NTP.
-If you want to isolate the guest time from the host, you can set @option{clock}
-to @code{rt} instead.  To even prevent it from progressing during suspension,
-you can set it to @code{vm}.
-
-Enable @option{driftfix} (i386 targets only) if you experience time drift problems,
-specifically with Windows' ACPI HAL. This option will try to figure out how
-many timer interrupts were not processed by the Windows guest and will
-re-inject them.
-ETEXI
-
-DEF("icount", HAS_ARG, QEMU_OPTION_icount, \
-    "-icount [shift=N|auto][,align=on|off][,sleep=on|off,rr=record|replay,rrfile=<filename>,rrsnapshot=<snapshot>]\n" \
-    "                enable virtual instruction counter with 2^N clock ticks per\n" \
-    "                instruction, enable aligning the host and virtual clocks\n" \
-    "                or disable real time cpu sleeping\n", QEMU_ARCH_ALL)
-STEXI
-@item -icount [shift=@var{N}|auto][,rr=record|replay,rrfile=@var{filename},rrsnapshot=@var{snapshot}]
-@findex -icount
-Enable virtual instruction counter.  The virtual cpu will execute one
-instruction every 2^@var{N} ns of virtual time.  If @code{auto} is specified
-then the virtual cpu speed will be automatically adjusted to keep virtual
-time within a few seconds of real time.
-
-When the virtual cpu is sleeping, the virtual time will advance at default
-speed unless @option{sleep=on|off} is specified.
-With @option{sleep=on|off}, the virtual time will jump to the next timer deadline
-instantly whenever the virtual cpu goes to sleep mode and will not advance
-if no timer is enabled. This behavior give deterministic execution times from
-the guest point of view.
-
-Note that while this option can give deterministic behavior, it does not
-provide cycle accurate emulation.  Modern CPUs contain superscalar out of
-order cores with complex cache hierarchies.  The number of instructions
-executed often has little or no correlation with actual performance.
-
-@option{align=on} will activate the delay algorithm which will try
-to synchronise the host clock and the virtual clock. The goal is to
-have a guest running at the real frequency imposed by the shift option.
-Whenever the guest clock is behind the host clock and if
-@option{align=on} is specified then we print a message to the user
-to inform about the delay.
-Currently this option does not work when @option{shift} is @code{auto}.
-Note: The sync algorithm will work for those shift values for which
-the guest clock runs ahead of the host clock. Typically this happens
-when the shift value is high (how high depends on the host machine).
-
-When @option{rr} option is specified deterministic record/replay is enabled.
-Replay log is written into @var{filename} file in record mode and
-read from this file in replay mode.
-
-Option rrsnapshot is used to create new vm snapshot named @var{snapshot}
-at the start of execution recording. In replay mode this option is used
-to load the initial VM state.
-ETEXI
-
-DEF("watchdog", HAS_ARG, QEMU_OPTION_watchdog, \
-    "-watchdog model\n" \
-    "                enable virtual hardware watchdog [default=none]\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -watchdog @var{model}
-@findex -watchdog
-Create a virtual hardware watchdog device.  Once enabled (by a guest
-action), the watchdog must be periodically polled by an agent inside
-the guest or else the guest will be restarted. Choose a model for
-which your guest has drivers.
-
-The @var{model} is the model of hardware watchdog to emulate. Use
-@code{-watchdog help} to list available hardware models. Only one
-watchdog can be enabled for a guest.
-
-The following models may be available:
-@table @option
-@item ib700
-iBASE 700 is a very simple ISA watchdog with a single timer.
-@item i6300esb
-Intel 6300ESB I/O controller hub is a much more featureful PCI-based
-dual-timer watchdog.
-@item diag288
-A virtual watchdog for s390x backed by the diagnose 288 hypercall
-(currently KVM only).
-@end table
-ETEXI
-
-DEF("watchdog-action", HAS_ARG, QEMU_OPTION_watchdog_action, \
-    "-watchdog-action reset|shutdown|poweroff|inject-nmi|pause|debug|none\n" \
-    "                action when watchdog fires [default=reset]\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -watchdog-action @var{action}
-@findex -watchdog-action
-
-The @var{action} controls what QEMU will do when the watchdog timer
-expires.
-The default is
-@code{reset} (forcefully reset the guest).
-Other possible actions are:
-@code{shutdown} (attempt to gracefully shutdown the guest),
-@code{poweroff} (forcefully poweroff the guest),
-@code{inject-nmi} (inject a NMI into the guest),
-@code{pause} (pause the guest),
-@code{debug} (print a debug message and continue), or
-@code{none} (do nothing).
-
-Note that the @code{shutdown} action requires that the guest responds
-to ACPI signals, which it may not be able to do in the sort of
-situations where the watchdog would have expired, and thus
-@code{-watchdog-action shutdown} is not recommended for production use.
-
-Examples:
-
-@table @code
-@item -watchdog i6300esb -watchdog-action pause
-@itemx -watchdog ib700
-@end table
-ETEXI
-
-DEF("echr", HAS_ARG, QEMU_OPTION_echr, \
-    "-echr chr       set terminal escape character instead of ctrl-a\n",
-    QEMU_ARCH_ALL)
-STEXI
-
-@item -echr @var{numeric_ascii_value}
-@findex -echr
-Change the escape character used for switching to the monitor when using
-monitor and serial sharing.  The default is @code{0x01} when using the
-@code{-nographic} option.  @code{0x01} is equal to pressing
-@code{Control-a}.  You can select a different character from the ascii
-control keys where 1 through 26 map to Control-a through Control-z.  For
-instance you could use the either of the following to change the escape
-character to Control-t.
-@table @code
-@item -echr 0x14
-@itemx -echr 20
-@end table
-ETEXI
-
-DEF("virtioconsole", HAS_ARG, QEMU_OPTION_virtiocon, \
-    "-virtioconsole c\n" \
-    "                set virtio console\n", QEMU_ARCH_ALL)
-STEXI
-@item -virtioconsole @var{c}
-@findex -virtioconsole
-Set virtio console.
-
-This option is maintained for backward compatibility.
-
-Please use @code{-device virtconsole} for the new way of invocation.
-ETEXI
-
-DEF("show-cursor", 0, QEMU_OPTION_show_cursor, \
-    "-show-cursor    show cursor\n", QEMU_ARCH_ALL)
-STEXI
-@item -show-cursor
-@findex -show-cursor
-Show cursor.
-ETEXI
-
-DEF("tb-size", HAS_ARG, QEMU_OPTION_tb_size, \
-    "-tb-size n      set TB size\n", QEMU_ARCH_ALL)
-STEXI
-@item -tb-size @var{n}
-@findex -tb-size
-Set TB size.
-ETEXI
-
-DEF("incoming", HAS_ARG, QEMU_OPTION_incoming, \
-    "-incoming tcp:[host]:port[,to=maxport][,ipv4][,ipv6]\n" \
-    "-incoming rdma:host:port[,ipv4][,ipv6]\n" \
-    "-incoming unix:socketpath\n" \
-    "                prepare for incoming migration, listen on\n" \
-    "                specified protocol and socket address\n" \
-    "-incoming fd:fd\n" \
-    "-incoming exec:cmdline\n" \
-    "                accept incoming migration on given file descriptor\n" \
-    "                or from given external command\n" \
-    "-incoming defer\n" \
-    "                wait for the URI to be specified via migrate_incoming\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -incoming tcp:[@var{host}]:@var{port}[,to=@var{maxport}][,ipv4][,ipv6]
-@itemx -incoming rdma:@var{host}:@var{port}[,ipv4][,ipv6]
-@findex -incoming
-Prepare for incoming migration, listen on a given tcp port.
-
-@item -incoming unix:@var{socketpath}
-Prepare for incoming migration, listen on a given unix socket.
-
-@item -incoming fd:@var{fd}
-Accept incoming migration from a given filedescriptor.
-
-@item -incoming exec:@var{cmdline}
-Accept incoming migration as an output from specified external command.
-
-@item -incoming defer
-Wait for the URI to be specified via migrate_incoming.  The monitor can
-be used to change settings (such as migration parameters) prior to issuing
-the migrate_incoming to allow the migration to begin.
-ETEXI
-
-DEF("only-migratable", 0, QEMU_OPTION_only_migratable, \
-    "-only-migratable     allow only migratable devices\n", QEMU_ARCH_ALL)
-STEXI
-@item -only-migratable
-@findex -only-migratable
-Only allow migratable devices. Devices will not be allowed to enter an
-unmigratable state.
-ETEXI
-
-DEF("nodefaults", 0, QEMU_OPTION_nodefaults, \
-    "-nodefaults     don't create default devices\n", QEMU_ARCH_ALL)
-STEXI
-@item -nodefaults
-@findex -nodefaults
-Don't create default devices. Normally, QEMU sets the default devices like serial
-port, parallel port, virtual console, monitor device, VGA adapter, floppy and
-CD-ROM drive and others. The @code{-nodefaults} option will disable all those
-default devices.
-ETEXI
-
-#ifndef _WIN32
-DEF("chroot", HAS_ARG, QEMU_OPTION_chroot, \
-    "-chroot dir     chroot to dir just before starting the VM\n",
-    QEMU_ARCH_ALL)
-#endif
-STEXI
-@item -chroot @var{dir}
-@findex -chroot
-Immediately before starting guest execution, chroot to the specified
-directory.  Especially useful in combination with -runas.
-ETEXI
-
-#ifndef _WIN32
-DEF("runas", HAS_ARG, QEMU_OPTION_runas, \
-    "-runas user     change to user id user just before starting the VM\n",
-    QEMU_ARCH_ALL)
-#endif
-STEXI
-@item -runas @var{user}
-@findex -runas
-Immediately before starting guest execution, drop root privileges, switching
-to the specified user.
-ETEXI
-
-DEF("prom-env", HAS_ARG, QEMU_OPTION_prom_env,
-    "-prom-env variable=value\n"
-    "                set OpenBIOS nvram variables\n",
-    QEMU_ARCH_PPC | QEMU_ARCH_SPARC)
-STEXI
-@item -prom-env @var{variable}=@var{value}
-@findex -prom-env
-Set OpenBIOS nvram @var{variable} to given @var{value} (PPC, SPARC only).
-ETEXI
-DEF("semihosting", 0, QEMU_OPTION_semihosting,
-    "-semihosting    semihosting mode\n",
-    QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 |
-    QEMU_ARCH_MIPS)
-STEXI
-@item -semihosting
-@findex -semihosting
-Enable semihosting mode (ARM, M68K, Xtensa, MIPS only).
-ETEXI
-DEF("semihosting-config", HAS_ARG, QEMU_OPTION_semihosting_config,
-    "-semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]\n" \
-    "                semihosting configuration\n",
-QEMU_ARCH_ARM | QEMU_ARCH_M68K | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32 |
-QEMU_ARCH_MIPS)
-STEXI
-@item -semihosting-config [enable=on|off][,target=native|gdb|auto][,arg=str[,...]]
-@findex -semihosting-config
-Enable and configure semihosting (ARM, M68K, Xtensa, MIPS only).
-@table @option
-@item target=@code{native|gdb|auto}
-Defines where the semihosting calls will be addressed, to QEMU (@code{native})
-or to GDB (@code{gdb}). The default is @code{auto}, which means @code{gdb}
-during debug sessions and @code{native} otherwise.
-@item arg=@var{str1},arg=@var{str2},...
-Allows the user to pass input arguments, and can be used multiple times to build
-up a list. The old-style @code{-kernel}/@code{-append} method of passing a
-command line is still supported for backward compatibility. If both the
-@code{--semihosting-config arg} and the @code{-kernel}/@code{-append} are
-specified, the former is passed to semihosting as it always takes precedence.
-@end table
-ETEXI
-DEF("old-param", 0, QEMU_OPTION_old_param,
-    "-old-param      old param mode\n", QEMU_ARCH_ARM)
-STEXI
-@item -old-param
-@findex -old-param (ARM)
-Old param mode (ARM only).
-ETEXI
-
-DEF("sandbox", HAS_ARG, QEMU_OPTION_sandbox, \
-    "-sandbox on[,obsolete=allow|deny][,elevateprivileges=allow|deny|children]\n" \
-    "          [,spawn=allow|deny][,resourcecontrol=allow|deny]\n" \
-    "                Enable seccomp mode 2 system call filter (default 'off').\n" \
-    "                use 'obsolete' to allow obsolete system calls that are provided\n" \
-    "                    by the kernel, but typically no longer used by modern\n" \
-    "                    C library implementations.\n" \
-    "                use 'elevateprivileges' to allow or deny QEMU process to elevate\n" \
-    "                    its privileges by blacklisting all set*uid|gid system calls.\n" \
-    "                    The value 'children' will deny set*uid|gid system calls for\n" \
-    "                    main QEMU process but will allow forks and execves to run unprivileged\n" \
-    "                use 'spawn' to avoid QEMU to spawn new threads or processes by\n" \
-    "                     blacklisting *fork and execve\n" \
-    "                use 'resourcecontrol' to disable process affinity and schedular priority\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -sandbox @var{arg}[,obsolete=@var{string}][,elevateprivileges=@var{string}][,spawn=@var{string}][,resourcecontrol=@var{string}]
-@findex -sandbox
-Enable Seccomp mode 2 system call filter. 'on' will enable syscall filtering and 'off' will
-disable it.  The default is 'off'.
-@table @option
-@item obsolete=@var{string}
-Enable Obsolete system calls
-@item elevateprivileges=@var{string}
-Disable set*uid|gid system calls
-@item spawn=@var{string}
-Disable *fork and execve
-@item resourcecontrol=@var{string}
-Disable process affinity and schedular priority
-@end table
-ETEXI
-
-DEF("readconfig", HAS_ARG, QEMU_OPTION_readconfig,
-    "-readconfig <file>\n", QEMU_ARCH_ALL)
-STEXI
-@item -readconfig @var{file}
-@findex -readconfig
-Read device configuration from @var{file}. This approach is useful when you want to spawn
-QEMU process with many command line options but you don't want to exceed the command line
-character limit.
-ETEXI
-DEF("writeconfig", HAS_ARG, QEMU_OPTION_writeconfig,
-    "-writeconfig <file>\n"
-    "                read/write config file\n", QEMU_ARCH_ALL)
-STEXI
-@item -writeconfig @var{file}
-@findex -writeconfig
-Write device configuration to @var{file}. The @var{file} can be either filename to save
-command line and device configuration into file or dash @code{-}) character to print the
-output to stdout. This can be later used as input file for @code{-readconfig} option.
-ETEXI
-DEF("nodefconfig", 0, QEMU_OPTION_nodefconfig,
-    "-nodefconfig\n"
-    "                do not load default config files at startup\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -nodefconfig
-@findex -nodefconfig
-Normally QEMU loads configuration files from @var{sysconfdir} and @var{datadir} at startup.
-The @code{-nodefconfig} option will prevent QEMU from loading any of those config files.
-ETEXI
-DEF("no-user-config", 0, QEMU_OPTION_nouserconfig,
-    "-no-user-config\n"
-    "                do not load user-provided config files at startup\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -no-user-config
-@findex -no-user-config
-The @code{-no-user-config} option makes QEMU not load any of the user-provided
-config files on @var{sysconfdir}, but won't make it skip the QEMU-provided config
-files from @var{datadir}.
-ETEXI
-DEF("trace", HAS_ARG, QEMU_OPTION_trace,
-    "-trace [[enable=]<pattern>][,events=<file>][,file=<file>]\n"
-    "                specify tracing options\n",
-    QEMU_ARCH_ALL)
-STEXI
-HXCOMM This line is not accurate, as some sub-options are backend-specific but
-HXCOMM HX does not support conditional compilation of text.
-@item -trace [[enable=]@var{pattern}][,events=@var{file}][,file=@var{file}]
-@findex -trace
-@include qemu-option-trace.texi
-ETEXI
-
-HXCOMM Internal use
-DEF("qtest", HAS_ARG, QEMU_OPTION_qtest, "", QEMU_ARCH_ALL)
-DEF("qtest-log", HAS_ARG, QEMU_OPTION_qtest_log, "", QEMU_ARCH_ALL)
-
-#ifdef __linux__
-DEF("enable-fips", 0, QEMU_OPTION_enablefips,
-    "-enable-fips    enable FIPS 140-2 compliance\n",
-    QEMU_ARCH_ALL)
-#endif
-STEXI
-@item -enable-fips
-@findex -enable-fips
-Enable FIPS 140-2 compliance mode.
-ETEXI
-
-HXCOMM Deprecated by -machine accel=tcg property
-DEF("no-kvm", 0, QEMU_OPTION_no_kvm, "", QEMU_ARCH_I386)
-
-HXCOMM Deprecated by kvm-pit driver properties
-DEF("no-kvm-pit-reinjection", 0, QEMU_OPTION_no_kvm_pit_reinjection,
-    "", QEMU_ARCH_I386)
-
-HXCOMM Deprecated (ignored)
-DEF("no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit, "", QEMU_ARCH_I386)
-
-HXCOMM Deprecated by -machine kernel_irqchip=on|off property
-DEF("no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip, "", QEMU_ARCH_I386)
-
-HXCOMM Deprecated (ignored)
-DEF("tdf", 0, QEMU_OPTION_tdf,"", QEMU_ARCH_ALL)
-
-DEF("msg", HAS_ARG, QEMU_OPTION_msg,
-    "-msg timestamp[=on|off]\n"
-    "                change the format of messages\n"
-    "                on|off controls leading timestamps (default:on)\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -msg timestamp[=on|off]
-@findex -msg
-prepend a timestamp to each log message.(default:on)
-ETEXI
-
-DEF("dump-vmstate", HAS_ARG, QEMU_OPTION_dump_vmstate,
-    "-dump-vmstate <file>\n"
-    "                Output vmstate information in JSON format to file.\n"
-    "                Use the scripts/vmstate-static-checker.py file to\n"
-    "                check for possible regressions in migration code\n"
-    "                by comparing two such vmstate dumps.\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -dump-vmstate @var{file}
-@findex -dump-vmstate
-Dump json-encoded vmstate information for current machine type to file
-in @var{file}
-ETEXI
-
-STEXI
-@end table
-ETEXI
-DEFHEADING()
-
-DEFHEADING(Generic object creation:)
-STEXI
-@table @option
-ETEXI
-
-DEF("object", HAS_ARG, QEMU_OPTION_object,
-    "-object TYPENAME[,PROP1=VALUE1,...]\n"
-    "                create a new object of type TYPENAME setting properties\n"
-    "                in the order they are specified.  Note that the 'id'\n"
-    "                property must be set.  These objects are placed in the\n"
-    "                '/objects' path.\n",
-    QEMU_ARCH_ALL)
-STEXI
-@item -object @var{typename}[,@var{prop1}=@var{value1},...]
-@findex -object
-Create a new object of type @var{typename} setting properties
-in the order they are specified.  Note that the 'id'
-property must be set.  These objects are placed in the
-'/objects' path.
-
-@table @option
-
-@item -object memory-backend-file,id=@var{id},size=@var{size},mem-path=@var{dir},share=@var{on|off},discard-data=@var{on|off}
-
-Creates a memory file backend object, which can be used to back
-the guest RAM with huge pages. The @option{id} parameter is a
-unique ID that will be used to reference this memory region
-when configuring the @option{-numa} argument. The @option{size}
-option provides the size of the memory region, and accepts
-common suffixes, eg @option{500M}. The @option{mem-path} provides
-the path to either a shared memory or huge page filesystem mount.
-The @option{share} boolean option determines whether the memory
-region is marked as private to QEMU, or shared. The latter allows
-a co-operating external process to access the QEMU memory region.
-Setting the @option{discard-data} boolean option to @var{on}
-indicates that file contents can be destroyed when QEMU exits,
-to avoid unnecessarily flushing data to the backing file.  Note
-that @option{discard-data} is only an optimization, and QEMU
-might not discard file contents if it aborts unexpectedly or is
-terminated using SIGKILL.
-
-@item -object rng-random,id=@var{id},filename=@var{/dev/random}
-
-Creates a random number generator backend which obtains entropy from
-a device on the host. The @option{id} parameter is a unique ID that
-will be used to reference this entropy backend from the @option{virtio-rng}
-device. The @option{filename} parameter specifies which file to obtain
-entropy from and if omitted defaults to @option{/dev/random}.
-
-@item -object rng-egd,id=@var{id},chardev=@var{chardevid}
-
-Creates a random number generator backend which obtains entropy from
-an external daemon running on the host. The @option{id} parameter is
-a unique ID that will be used to reference this entropy backend from
-the @option{virtio-rng} device. The @option{chardev} parameter is
-the unique ID of a character device backend that provides the connection
-to the RNG daemon.
-
-@item -object tls-creds-anon,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/cred/dir},verify-peer=@var{on|off}
-
-Creates a TLS anonymous credentials object, which can be used to provide
-TLS support on network backends. The @option{id} parameter is a unique
-ID which network backends will use to access the credentials. The
-@option{endpoint} is either @option{server} or @option{client} depending
-on whether the QEMU network backend that uses the credentials will be
-acting as a client or as a server. If @option{verify-peer} is enabled
-(the default) then once the handshake is completed, the peer credentials
-will be verified, though this is a no-op for anonymous credentials.
-
-The @var{dir} parameter tells QEMU where to find the credential
-files. For server endpoints, this directory may contain a file
-@var{dh-params.pem} providing diffie-hellman parameters to use
-for the TLS server. If the file is missing, QEMU will generate
-a set of DH parameters at startup. This is a computationally
-expensive operation that consumes random pool entropy, so it is
-recommended that a persistent set of parameters be generated
-upfront and saved.
-
-@item -object tls-creds-x509,id=@var{id},endpoint=@var{endpoint},dir=@var{/path/to/cred/dir},verify-peer=@var{on|off},passwordid=@var{id}
-
-Creates a TLS anonymous credentials object, which can be used to provide
-TLS support on network backends. The @option{id} parameter is a unique
-ID which network backends will use to access the credentials. The
-@option{endpoint} is either @option{server} or @option{client} depending
-on whether the QEMU network backend that uses the credentials will be
-acting as a client or as a server. If @option{verify-peer} is enabled
-(the default) then once the handshake is completed, the peer credentials
-will be verified. With x509 certificates, this implies that the clients
-must be provided with valid client certificates too.
-
-The @var{dir} parameter tells QEMU where to find the credential
-files. For server endpoints, this directory may contain a file
-@var{dh-params.pem} providing diffie-hellman parameters to use
-for the TLS server. If the file is missing, QEMU will generate
-a set of DH parameters at startup. This is a computationally
-expensive operation that consumes random pool entropy, so it is
-recommended that a persistent set of parameters be generated
-upfront and saved.
-
-For x509 certificate credentials the directory will contain further files
-providing the x509 certificates. The certificates must be stored
-in PEM format, in filenames @var{ca-cert.pem}, @var{ca-crl.pem} (optional),
-@var{server-cert.pem} (only servers), @var{server-key.pem} (only servers),
-@var{client-cert.pem} (only clients), and @var{client-key.pem} (only clients).
-
-For the @var{server-key.pem} and @var{client-key.pem} files which
-contain sensitive private keys, it is possible to use an encrypted
-version by providing the @var{passwordid} parameter. This provides
-the ID of a previously created @code{secret} object containing the
-password for decryption.
-
-@item -object filter-buffer,id=@var{id},netdev=@var{netdevid},interval=@var{t}[,queue=@var{all|rx|tx}][,status=@var{on|off}]
-
-Interval @var{t} can't be 0, this filter batches the packet delivery: all
-packets arriving in a given interval on netdev @var{netdevid} are delayed
-until the end of the interval. Interval is in microseconds.
-@option{status} is optional that indicate whether the netfilter is
-on (enabled) or off (disabled), the default status for netfilter will be 'on'.
-
-queue @var{all|rx|tx} is an option that can be applied to any netfilter.
-
-@option{all}: the filter is attached both to the receive and the transmit
-              queue of the netdev (default).
-
-@option{rx}: the filter is attached to the receive queue of the netdev,
-             where it will receive packets sent to the netdev.
-
-@option{tx}: the filter is attached to the transmit queue of the netdev,
-             where it will receive packets sent by the netdev.
-
-@item -object filter-mirror,id=@var{id},netdev=@var{netdevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
-
-filter-mirror on netdev @var{netdevid},mirror net packet to chardev@var{chardevid}, if it has the vnet_hdr_support flag, filter-mirror will mirror packet with vnet_hdr_len.
-
-@item -object filter-redirector,id=@var{id},netdev=@var{netdevid},indev=@var{chardevid},outdev=@var{chardevid},queue=@var{all|rx|tx}[,vnet_hdr_support]
-
-filter-redirector on netdev @var{netdevid},redirect filter's net packet to chardev
-@var{chardevid},and redirect indev's packet to filter.if it has the vnet_hdr_support flag,
-filter-redirector will redirect packet with vnet_hdr_len.
-Create a filter-redirector we need to differ outdev id from indev id, id can not
-be the same. we can just use indev or outdev, but at least one of indev or outdev
-need to be specified.
-
-@item -object filter-rewriter,id=@var{id},netdev=@var{netdevid},queue=@var{all|rx|tx},[vnet_hdr_support]
-
-Filter-rewriter is a part of COLO project.It will rewrite tcp packet to
-secondary from primary to keep secondary tcp connection,and rewrite
-tcp packet to primary from secondary make tcp packet can be handled by
-client.if it has the vnet_hdr_support flag, we can parse packet with vnet header.
-
-usage:
-colo secondary:
--object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
--object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
--object filter-rewriter,id=rew0,netdev=hn0,queue=all
-
-@item -object filter-dump,id=@var{id},netdev=@var{dev}[,file=@var{filename}][,maxlen=@var{len}]
-
-Dump the network traffic on netdev @var{dev} to the file specified by
-@var{filename}. At most @var{len} bytes (64k by default) per packet are stored.
-The file format is libpcap, so it can be analyzed with tools such as tcpdump
-or Wireshark.
-
-@item -object colo-compare,id=@var{id},primary_in=@var{chardevid},secondary_in=@var{chardevid},outdev=@var{chardevid}[,vnet_hdr_support]
-
-Colo-compare gets packet from primary_in@var{chardevid} and secondary_in@var{chardevid}, than compare primary packet with
-secondary packet. If the packets are same, we will output primary
-packet to outdev@var{chardevid}, else we will notify colo-frame
-do checkpoint and send primary packet to outdev@var{chardevid}.
-if it has the vnet_hdr_support flag, colo compare will send/recv packet with vnet_hdr_len.
-
-we must use it with the help of filter-mirror and filter-redirector.
-
-@example
-
-primary:
--netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
--device e1000,id=e0,netdev=hn0,mac=52:a4:00:12:78:66
--chardev socket,id=mirror0,host=3.3.3.3,port=9003,server,nowait
--chardev socket,id=compare1,host=3.3.3.3,port=9004,server,nowait
--chardev socket,id=compare0,host=3.3.3.3,port=9001,server,nowait
--chardev socket,id=compare0-0,host=3.3.3.3,port=9001
--chardev socket,id=compare_out,host=3.3.3.3,port=9005,server,nowait
--chardev socket,id=compare_out0,host=3.3.3.3,port=9005
--object filter-mirror,id=m0,netdev=hn0,queue=tx,outdev=mirror0
--object filter-redirector,netdev=hn0,id=redire0,queue=rx,indev=compare_out
--object filter-redirector,netdev=hn0,id=redire1,queue=rx,outdev=compare0
--object colo-compare,id=comp0,primary_in=compare0-0,secondary_in=compare1,outdev=compare_out0
-
-secondary:
--netdev tap,id=hn0,vhost=off,script=/etc/qemu-ifup,down script=/etc/qemu-ifdown
--device e1000,netdev=hn0,mac=52:a4:00:12:78:66
--chardev socket,id=red0,host=3.3.3.3,port=9003
--chardev socket,id=red1,host=3.3.3.3,port=9004
--object filter-redirector,id=f1,netdev=hn0,queue=tx,indev=red0
--object filter-redirector,id=f2,netdev=hn0,queue=rx,outdev=red1
-
-@end example
-
-If you want to know the detail of above command line, you can read
-the colo-compare git log.
-
-@item -object cryptodev-backend-builtin,id=@var{id}[,queues=@var{queues}]
-
-Creates a cryptodev backend which executes crypto opreation from
-the QEMU cipher APIS. The @var{id} parameter is
-a unique ID that will be used to reference this cryptodev backend from
-the @option{virtio-crypto} device. The @var{queues} parameter is optional,
-which specify the queue number of cryptodev backend, the default of
-@var{queues} is 1.
-
-@example
-
- # qemu-system-x86_64 \
-   [...] \
-       -object cryptodev-backend-builtin,id=cryptodev0 \
-       -device virtio-crypto-pci,id=crypto0,cryptodev=cryptodev0 \
-   [...]
-@end example
-
-@item -object secret,id=@var{id},data=@var{string},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
-@item -object secret,id=@var{id},file=@var{filename},format=@var{raw|base64}[,keyid=@var{secretid},iv=@var{string}]
-
-Defines a secret to store a password, encryption key, or some other sensitive
-data. The sensitive data can either be passed directly via the @var{data}
-parameter, or indirectly via the @var{file} parameter. Using the @var{data}
-parameter is insecure unless the sensitive data is encrypted.
-
-The sensitive data can be provided in raw format (the default), or base64.
-When encoded as JSON, the raw format only supports valid UTF-8 characters,
-so base64 is recommended for sending binary data. QEMU will convert from
-which ever format is provided to the format it needs internally. eg, an
-RBD password can be provided in raw format, even though it will be base64
-encoded when passed onto the RBD sever.
-
-For added protection, it is possible to encrypt the data associated with
-a secret using the AES-256-CBC cipher. Use of encryption is indicated
-by providing the @var{keyid} and @var{iv} parameters. The @var{keyid}
-parameter provides the ID of a previously defined secret that contains
-the AES-256 decryption key. This key should be 32-bytes long and be
-base64 encoded. The @var{iv} parameter provides the random initialization
-vector used for encryption of this particular secret and should be a
-base64 encrypted string of the 16-byte IV.
-
-The simplest (insecure) usage is to provide the secret inline
-
-@example
-
- # $QEMU -object secret,id=sec0,data=letmein,format=raw
-
-@end example
-
-The simplest secure usage is to provide the secret via a file
-
- # printf "letmein" > mypasswd.txt
- # $QEMU -object secret,id=sec0,file=mypasswd.txt,format=raw
-
-For greater security, AES-256-CBC should be used. To illustrate usage,
-consider the openssl command line tool which can encrypt the data. Note
-that when encrypting, the plaintext must be padded to the cipher block
-size (32 bytes) using the standard PKCS#5/6 compatible padding algorithm.
-
-First a master key needs to be created in base64 encoding:
-
-@example
- # openssl rand -base64 32 > key.b64
- # KEY=$(base64 -d key.b64 | hexdump  -v -e '/1 "%02X"')
-@end example
-
-Each secret to be encrypted needs to have a random initialization vector
-generated. These do not need to be kept secret
-
-@example
- # openssl rand -base64 16 > iv.b64
- # IV=$(base64 -d iv.b64 | hexdump  -v -e '/1 "%02X"')
-@end example
-
-The secret to be defined can now be encrypted, in this case we're
-telling openssl to base64 encode the result, but it could be left
-as raw bytes if desired.
-
-@example
- # SECRET=$(printf "letmein" |
-            openssl enc -aes-256-cbc -a -K $KEY -iv $IV)
-@end example
-
-When launching QEMU, create a master secret pointing to @code{key.b64}
-and specify that to be used to decrypt the user password. Pass the
-contents of @code{iv.b64} to the second secret
-
-@example
- # $QEMU \
-     -object secret,id=secmaster0,format=base64,file=key.b64 \
-     -object secret,id=sec0,keyid=secmaster0,format=base64,\
-         data=$SECRET,iv=$(<iv.b64)
-@end example
-
-@end table
-
-ETEXI
-
-
-HXCOMM This is the last statement. Insert new options before this line!
-STEXI
-@end table
-ETEXI
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 958249fbd8..62373ad792 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -134,6 +134,8 @@ class QAPIDoc(object):
         self.sections = []
         # the current section
         self._section = self.body
+        # in embedded texinfo?
+        self._intexi = False
 
     def has_section(self, name):
         """Return True if we have a section with this name."""
@@ -153,10 +155,17 @@ class QAPIDoc(object):
             raise QAPIParseError(self._parser, "Missing space after #")
         line = line[1:]
 
+        if self._intexi:
+            self._section.append(line)
+            if line == '!end texinfo':
+                self._intexi = False
+        elif line == '!texinfo':
+            self._intexi = True
+            self._section.append(line)
+        elif self.symbol:
+            self._append_symbol_line(line)
         # FIXME not nice: things like '#  @foo:' and '# @foo: ' aren't
         # recognized, and get silently treated as ordinary text
-        if self.symbol:
-            self._append_symbol_line(line)
         elif not self.body.text and line.startswith('@'):
             if not line.endswith(':'):
                 raise QAPIParseError(self._parser, "Line should end with :")
@@ -225,7 +234,7 @@ class QAPIDoc(object):
         if (in_arg or not self._section.name
                 or not self._section.name.startswith('Example')):
             line = line.strip()
-        match = re.match(r'(@\S+:)', line)
+        match = re.match(r'(@\S+:)($|\s)', line)
         if match:
             raise QAPIParseError(self._parser,
                                  "'%s' not allowed in free-form documentation"
diff --git a/vl.c b/vl.c
index 3fed457921..b9524f7e11 100644
--- a/vl.c
+++ b/vl.c
@@ -96,11 +96,11 @@ int main(int argc, char **argv)
 #include "sysemu/hax.h"
 #include "qapi/qobject-input-visitor.h"
 #include "qapi/qobject-input-visitor.h"
+#include "qapi-options.h"
 #include "qapi-visit.h"
 #include "qapi/qmp/qjson.h"
 #include "qemu/option.h"
 #include "qemu/config-file.h"
-#include "qemu-options.h"
 #include "qmp-commands.h"
 #include "qemu/main-loop.h"
 #ifdef CONFIG_VIRTFS
@@ -2009,20 +2009,17 @@ static void help(int exitcode)
 {
     version();
     printf("usage: %s [options] [disk_image]\n\n"
-           "'disk_image' is a raw hard disk image for IDE hard disk 0\n\n",
-            error_get_progname());
-
-#define QEMU_OPTIONS_GENERATE_HELP
-#include "qemu-options-wrapper.h"
-
-    printf("\nDuring emulation, the following keys are useful:\n"
+           "'disk_image' is a raw hard disk image for IDE hard disk 0\n\n"
+           "%s"
+           "\nDuring emulation, the following keys are useful:\n"
            "ctrl-alt-f      toggle full screen\n"
            "ctrl-alt-n      switch to virtual console 'n'\n"
            "ctrl-alt        toggle mouse and keyboard grab\n"
            "\n"
            "When using -nographic, press 'ctrl-a h' to get some help.\n"
            "\n"
-           QEMU_HELP_BOTTOM "\n");
+           QEMU_HELP_BOTTOM "\n",
+           error_get_progname(), qapi_options_help);
 
     exit(exitcode);
 }
@@ -2036,13 +2033,6 @@ typedef struct QEMUOption {
     uint32_t arch_mask;
 } QEMUOption;
 
-static const QEMUOption qemu_options[] = {
-    { "h", 0, QEMU_OPTION_h, QEMU_ARCH_ALL },
-#define QEMU_OPTIONS_GENERATE_OPTIONS
-#include "qemu-options-wrapper.h"
-    { NULL },
-};
-
 typedef struct VGAInterfaceInfo {
     const char *opt_name;    /* option name */
     const char *name;        /* human-readable name */
@@ -2800,46 +2790,6 @@ static void qemu_run_machine_init_done_notifiers(void)
     machine_init_done = true;
 }
 
-static const QEMUOption *lookup_opt(int argc, char **argv,
-                                    const char **poptarg, int *poptind)
-{
-    const QEMUOption *popt;
-    int optind = *poptind;
-    char *r = argv[optind];
-    const char *optarg;
-
-    loc_set_cmdline(argv, optind, 1);
-    optind++;
-    /* Treat --foo the same as -foo.  */
-    if (r[1] == '-')
-        r++;
-    popt = qemu_options;
-    for(;;) {
-        if (!popt->name) {
-            error_report("invalid option");
-            exit(1);
-        }
-        if (!strcmp(popt->name, r + 1))
-            break;
-        popt++;
-    }
-    if (popt->flags & HAS_ARG) {
-        if (optind >= argc) {
-            error_report("requires an argument");
-            exit(1);
-        }
-        optarg = argv[optind++];
-        loc_set_cmdline(argv, optind - 2, 2);
-    } else {
-        optarg = NULL;
-    }
-
-    *poptarg = optarg;
-    *poptind = optind;
-
-    return popt;
-}
-
 static MachineClass *select_machine(void)
 {
     MachineClass *machine_class = find_default_machine();
@@ -3088,6 +3038,15 @@ static void register_global_properties(MachineState *ms)
     user_register_global_props();
 }
 
+/* TODO make options conditional in schema and drop this crap */
+static void check_option_arch(uint32_t arch_mask)
+{
+    if (!(arch_type & arch_mask)) {
+        error_report("Option not supported for this target");
+        exit(1);
+    }
+}
+
 int main(int argc, char **argv, char **envp)
 {
     int i;
@@ -3101,8 +3060,6 @@ int main(int argc, char **argv, char **envp)
     QemuOpts *opts, *machine_opts;
     QemuOpts *hda_opts = NULL, *icount_opts = NULL, *accel_opts = NULL;
     QemuOptsList *olist;
-    int optind;
-    const char *optarg;
     const char *loadvm = NULL;
     MachineClass *machine_class;
     const char *cpu_model;
@@ -3133,6 +3090,7 @@ int main(int argc, char **argv, char **envp)
     } BlockdevOptions_queue;
     QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue
         = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
+    QAPIOption *qopt;
 
     module_call_init(MODULE_INIT_TRACE);
 
@@ -3147,6 +3105,8 @@ int main(int argc, char **argv, char **envp)
     module_call_init(MODULE_INIT_QOM);
     monitor_init_qmp_commands();
 
+    qopt = qapi_options_parse(argc, argv);
+
     qemu_add_opts(&qemu_drive_opts);
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
     qemu_add_drive_opts(&qemu_common_drive_opts);
@@ -3202,58 +3162,52 @@ int main(int argc, char **argv, char **envp)
     autostart = 1;
 
     /* first pass of option parsing */
-    optind = 1;
-    while (optind < argc) {
-        if (argv[optind][0] != '-') {
-            /* disk image */
-            optind++;
-        } else {
-            const QEMUOption *popt;
-
-            popt = lookup_opt(argc, argv, &optarg, &optind);
-            switch (popt->index) {
-            case QEMU_OPTION_nodefconfig:
-                defconfig = false;
-                break;
-            case QEMU_OPTION_nouserconfig:
-                userconfig = false;
-                break;
-            }
+    for (i = 0; !qopt[i].cnt; i++) {
+        switch (qopt[i].type) {
+        case QAPI_OPTION_KIND_NODEFCONFIG:
+            defconfig = false;
+            break;
+        case QAPI_OPTION_KIND_NO_USER_CONFIG:
+            userconfig = false;
+            break;
+        case QAPI_OPTION_KIND_READCONFIG:
+            /* TODO read .json config and insert it into @qopt right here */
+            break;
+        case QAPI_OPTION_KIND_WRITECONFIG:
+            /* TODO write .json config here? */
+            break;
+        case QAPI_OPTION_KIND_SET:
+            /* TODO how to port this one from QemuOpts to QAPI? */
+            break;
+        default:
+            ;
         }
     }
 
     if (defconfig && userconfig) {
+        /* TODO read default .json config and prepend it to @qopt */
         if (qemu_read_default_config_file() < 0) {
             exit(1);
         }
     }
 
     /* second pass of option parsing */
-    optind = 1;
-    for(;;) {
-        if (optind >= argc)
-            break;
-        if (argv[optind][0] != '-') {
-            hda_opts = drive_add(IF_DEFAULT, 0, argv[optind++], HD_OPTS);
-        } else {
-            const QEMUOption *popt;
+    for (i = 0; qopt[i].cnt; i++) {
+            /* TODO reindent */
+            loc_set_cmdline(argv, qopt[i].idx, qopt[i].cnt);
 
-            popt = lookup_opt(argc, argv, &optarg, &optind);
-            if (!(popt->arch_mask & arch_type)) {
-                error_report("Option not supported for this target");
-                exit(1);
-            }
-            switch(popt->index) {
-            case QEMU_OPTION_no_kvm_irqchip: {
+            switch (qopt[i].type) {
+            case QAPI_OPTION_KIND_NO_KVM_IRQCHIP: {
+                check_option_arch(QEMU_ARCH_I386);
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "kernel_irqchip=off", false);
                 break;
             }
-            case QEMU_OPTION_cpu:
+            case QAPI_OPTION_KIND_CPU:
                 /* hw initialization will check this */
-                cpu_model = optarg;
+                cpu_model = qopt[i].u.cpu.data;
                 break;
-            case QEMU_OPTION_hda:
+            case QAPI_OPTION_KIND_HDA:
                 {
                     char buf[256];
                     if (cyls == 0)
@@ -3266,21 +3220,25 @@ int main(int argc, char **argv, char **envp)
                                  ",trans=lba" :
                                  translation == BIOS_ATA_TRANSLATION_NONE ?
                                  ",trans=none" : "");
-                    drive_add(IF_DEFAULT, 0, optarg, buf);
+                    drive_add(IF_DEFAULT, 0, qopt[i].u.hda.data, buf);
                     break;
                 }
-            case QEMU_OPTION_hdb:
-            case QEMU_OPTION_hdc:
-            case QEMU_OPTION_hdd:
-                drive_add(IF_DEFAULT, popt->index - QEMU_OPTION_hda, optarg,
-                          HD_OPTS);
+            case QAPI_OPTION_KIND_HDB:
+                drive_add(IF_DEFAULT, 1, qopt[i].u.hdb.data, HD_OPTS);
                 break;
-            case QEMU_OPTION_blockdev:
+            case QAPI_OPTION_KIND_HDC:
+                drive_add(IF_DEFAULT, 2, qopt[i].u.hdc.data, HD_OPTS);
+                break;
+            case QAPI_OPTION_KIND_HDD:
+                drive_add(IF_DEFAULT, 3, qopt[i].u.hdb.data, HD_OPTS);
+                break;
+            case QAPI_OPTION_KIND_BLOCKDEV:
                 {
                     Visitor *v;
                     BlockdevOptions_queue *bdo;
 
-                    v = qobject_input_visitor_new_str(optarg, "driver", &err);
+                    v = qobject_input_visitor_new_str(qopt[i].u.blockdev.data,
+                                                      "driver", &err);
                     if (!v) {
                         error_report_err(err);
                         exit(1);
@@ -3294,35 +3252,37 @@ int main(int argc, char **argv, char **envp)
                     QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry);
                     break;
                 }
-            case QEMU_OPTION_drive:
-                if (drive_def(optarg) == NULL) {
+            case QAPI_OPTION_KIND_DRIVE:
+                if (drive_def(qopt[i].u.drive.data) == NULL) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_set:
-                if (qemu_set_option(optarg) != 0)
+            case QAPI_OPTION_KIND_SET:
+                if (qemu_set_option(qopt[i].u.set.data) != 0) {
                     exit(1);
+                }
                 break;
-            case QEMU_OPTION_global:
-                if (qemu_global_option(optarg) != 0)
+            case QAPI_OPTION_KIND_GLOBAL:
+                if (qemu_global_option(qopt[i].u.global.data) != 0) {
                     exit(1);
+                }
                 break;
-            case QEMU_OPTION_mtdblock:
-                drive_add(IF_MTD, -1, optarg, MTD_OPTS);
+            case QAPI_OPTION_KIND_MTDBLOCK:
+                drive_add(IF_MTD, -1, qopt[i].u.mtdblock.data, MTD_OPTS);
                 break;
-            case QEMU_OPTION_sd:
-                drive_add(IF_SD, -1, optarg, SD_OPTS);
+            case QAPI_OPTION_KIND_SD:
+                drive_add(IF_SD, -1, qopt[i].u.sd.data, SD_OPTS);
                 break;
-            case QEMU_OPTION_pflash:
-                drive_add(IF_PFLASH, -1, optarg, PFLASH_OPTS);
+            case QAPI_OPTION_KIND_PFLASH:
+                drive_add(IF_PFLASH, -1, qopt[i].u.pflash.data, PFLASH_OPTS);
                 break;
-            case QEMU_OPTION_snapshot:
+            case QAPI_OPTION_KIND_SNAPSHOT:
                 snapshot = 1;
                 break;
-            case QEMU_OPTION_hdachs:
+            case QAPI_OPTION_KIND_HDACHS:
                 {
                     const char *p;
-                    p = optarg;
+                    p = qopt[i].u.hdachs.data;
                     cyls = strtol(p, (char **)&p, 0);
                     if (cyls < 1 || cyls > 16383)
                         goto chs_fail;
@@ -3383,23 +3343,23 @@ int main(int argc, char **argv, char **envp)
                 error_report("'-hdachs' is deprecated, please use '-device"
                              " ide-hd,cyls=c,heads=h,secs=s,...' instead");
                 break;
-            case QEMU_OPTION_numa:
+            case QAPI_OPTION_KIND_NUMA:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("numa"),
-                                               optarg, true);
+                                               qopt[i].u.numa.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_display:
-                display_type = select_display(optarg);
+            case QAPI_OPTION_KIND_DISPLAY:
+                display_type = select_display(qopt[i].u.display.data);
                 break;
-            case QEMU_OPTION_nographic:
+            case QAPI_OPTION_KIND_NOGRAPHIC:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "graphics=off", false);
                 nographic = true;
                 display_type = DT_NONE;
                 break;
-            case QEMU_OPTION_curses:
+            case QAPI_OPTION_KIND_CURSES:
 #ifdef CONFIG_CURSES
                 display_type = DT_CURSES;
 #else
@@ -3407,174 +3367,183 @@ int main(int argc, char **argv, char **envp)
                 exit(1);
 #endif
                 break;
-            case QEMU_OPTION_portrait:
+            case QAPI_OPTION_KIND_PORTRAIT:
                 graphic_rotate = 90;
                 break;
-            case QEMU_OPTION_rotate:
-                graphic_rotate = strtol(optarg, (char **) &optarg, 10);
+            case QAPI_OPTION_KIND_ROTATE:
+                graphic_rotate = strtol(qopt[i].u.rotate.data,
+                                        (char **)&qopt[i].u.rotate.data, 10);
                 if (graphic_rotate != 0 && graphic_rotate != 90 &&
                     graphic_rotate != 180 && graphic_rotate != 270) {
                     error_report("only 90, 180, 270 deg rotation is available");
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_kernel:
-                qemu_opts_set(qemu_find_opts("machine"), 0, "kernel", optarg,
-                              &error_abort);
+            case QAPI_OPTION_KIND_KERNEL:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "kernel",
+                              qopt[i].u.kernel.data, &error_abort);
                 break;
-            case QEMU_OPTION_initrd:
-                qemu_opts_set(qemu_find_opts("machine"), 0, "initrd", optarg,
-                              &error_abort);
+            case QAPI_OPTION_KIND_INITRD:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "initrd",
+                              qopt[i].u.initrd.data, &error_abort);
                 break;
-            case QEMU_OPTION_append:
-                qemu_opts_set(qemu_find_opts("machine"), 0, "append", optarg,
-                              &error_abort);
+            case QAPI_OPTION_KIND_APPEND:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "append",
+                              qopt[i].u.append.data, &error_abort);
                 break;
-            case QEMU_OPTION_dtb:
-                qemu_opts_set(qemu_find_opts("machine"), 0, "dtb", optarg,
-                              &error_abort);
+            case QAPI_OPTION_KIND_DTB:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "dtb",
+                              qopt[i].u.dtb.data, &error_abort);
                 break;
-            case QEMU_OPTION_cdrom:
-                drive_add(IF_DEFAULT, 2, optarg, CDROM_OPTS);
+            case QAPI_OPTION_KIND_CDROM:
+                drive_add(IF_DEFAULT, 2, qopt[i].u.cdrom.data, CDROM_OPTS);
                 break;
-            case QEMU_OPTION_boot:
+            case QAPI_OPTION_KIND_BOOT:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("boot-opts"),
-                                               optarg, true);
+                                               qopt[i].u.boot.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_fda:
-            case QEMU_OPTION_fdb:
-                drive_add(IF_FLOPPY, popt->index - QEMU_OPTION_fda,
-                          optarg, FD_OPTS);
+            case QAPI_OPTION_KIND_FDA:
+                drive_add(IF_FLOPPY, 0, qopt[i].u.fda.data, FD_OPTS);
                 break;
-            case QEMU_OPTION_no_fd_bootchk:
+            case QAPI_OPTION_KIND_FDB:
+                drive_add(IF_FLOPPY, 1, qopt[i].u.fdb.data, FD_OPTS);
+                break;
+            case QAPI_OPTION_KIND_NO_FD_BOOTCHK:
+                check_option_arch(QEMU_ARCH_I386);
                 fd_bootchk = 0;
                 break;
-            case QEMU_OPTION_netdev:
+            case QAPI_OPTION_KIND_NETDEV:
                 default_net = 0;
-                if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) {
+                if (net_client_parse(qemu_find_opts("netdev"),
+                                     qopt[i].u.netdev.data) == -1) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_net:
+            case QAPI_OPTION_KIND_NET:
                 default_net = 0;
-                if (net_client_parse(qemu_find_opts("net"), optarg) == -1) {
+                if (net_client_parse(qemu_find_opts("net"),
+                                     qopt[i].u.net.data) == -1) {
                     exit(1);
                 }
                 break;
 #ifdef CONFIG_LIBISCSI
-            case QEMU_OPTION_iscsi:
+            case QAPI_OPTION_KIND_ISCSI:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("iscsi"),
-                                               optarg, false);
+                                               qopt[i].u.iscsi.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 break;
 #endif
 #ifdef CONFIG_SLIRP
-            case QEMU_OPTION_tftp:
+            case QAPI_OPTION_KIND_TFTP:
                 error_report("The -tftp option is deprecated. "
                              "Please use '-netdev user,tftp=...' instead.");
-                legacy_tftp_prefix = optarg;
+                legacy_tftp_prefix = qopt[i].u.tftp.data;
                 break;
-            case QEMU_OPTION_bootp:
+            case QAPI_OPTION_KIND_BOOTP:
                 error_report("The -bootp option is deprecated. "
                              "Please use '-netdev user,bootfile=...' instead.");
-                legacy_bootp_filename = optarg;
+                legacy_bootp_filename = qopt[i].u.bootp.data;
                 break;
-            case QEMU_OPTION_redir:
+            case QAPI_OPTION_KIND_REDIR:
                 error_report("The -redir option is deprecated. "
                              "Please use '-netdev user,hostfwd=...' instead.");
-                if (net_slirp_redir(optarg) < 0)
+                if (net_slirp_redir(qopt[i].u.redir.data) < 0) {
                     exit(1);
+                }
                 break;
 #endif
-            case QEMU_OPTION_bt:
-                add_device_config(DEV_BT, optarg);
+            case QAPI_OPTION_KIND_BT:
+                add_device_config(DEV_BT, qopt[i].u.bt.data);
                 break;
-            case QEMU_OPTION_audio_help:
+            case QAPI_OPTION_KIND_AUDIO_HELP:
                 AUD_help ();
                 exit (0);
                 break;
-            case QEMU_OPTION_soundhw:
-                select_soundhw (optarg);
+            case QAPI_OPTION_KIND_SOUNDHW:
+                select_soundhw(qopt[i].u.soundhw.data);
                 break;
-            case QEMU_OPTION_h:
+            case QAPI_OPTION_KIND_HELP:
                 help(0);
                 break;
-            case QEMU_OPTION_version:
+            case QAPI_OPTION_KIND_VERSION:
                 version();
                 exit(0);
                 break;
-            case QEMU_OPTION_m:
+            case QAPI_OPTION_KIND_MEM:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("memory"),
-                                               optarg, true);
+                                               qopt[i].u.mem.data, true);
                 if (!opts) {
                     exit(EXIT_FAILURE);
                 }
                 break;
 #ifdef CONFIG_TPM
-            case QEMU_OPTION_tpmdev:
-                if (tpm_config_parse(qemu_find_opts("tpmdev"), optarg) < 0) {
+            case QAPI_OPTION_KIND_TPMDEV:
+                if (tpm_config_parse(qemu_find_opts("tpmdev"),
+                                     qopt[i].u.tpmdev.data) < 0) {
                     exit(1);
                 }
                 break;
 #endif
-            case QEMU_OPTION_mempath:
-                mem_path = optarg;
+            case QAPI_OPTION_KIND_MEM_PATH:
+                mem_path = qopt[i].u.mem_path.data;
                 break;
-            case QEMU_OPTION_mem_prealloc:
+            case QAPI_OPTION_KIND_MEM_PREALLOC:
                 mem_prealloc = 1;
                 break;
-            case QEMU_OPTION_d:
-                log_mask = optarg;
+            case QAPI_OPTION_KIND_DEBUG_ENABLE:
+                log_mask = qopt[i].u.debug_enable.data;
                 break;
-            case QEMU_OPTION_D:
-                log_file = optarg;
+            case QAPI_OPTION_KIND_DEBUG_LOG:
+                log_file = qopt[i].u.debug_log.data;
                 break;
-            case QEMU_OPTION_DFILTER:
-                qemu_set_dfilter_ranges(optarg, &error_fatal);
+            case QAPI_OPTION_KIND_DFILTER:
+                qemu_set_dfilter_ranges(qopt[i].u.dfilter.data, &error_fatal);
                 break;
-            case QEMU_OPTION_s:
+            case QAPI_OPTION_KIND_GDB_DEFAULT:
                 add_device_config(DEV_GDB, "tcp::" DEFAULT_GDBSTUB_PORT);
                 break;
-            case QEMU_OPTION_gdb:
-                add_device_config(DEV_GDB, optarg);
+            case QAPI_OPTION_KIND_GDB:
+                add_device_config(DEV_GDB, qopt[i].u.gdb.data);
                 break;
-            case QEMU_OPTION_L:
-                if (is_help_option(optarg)) {
+            case QAPI_OPTION_KIND_LOAD_PATH:
+                if (is_help_option(qopt[i].u.load_path.data)) {
                     list_data_dirs = true;
                 } else {
                     qemu_add_data_dir(optarg);
                 }
                 break;
-            case QEMU_OPTION_bios:
-                qemu_opts_set(qemu_find_opts("machine"), 0, "firmware", optarg,
-                              &error_abort);
+            case QAPI_OPTION_KIND_BIOS:
+                qemu_opts_set(qemu_find_opts("machine"), 0, "firmware",
+                              qopt[i].u.bios.data, &error_abort);
                 break;
-            case QEMU_OPTION_singlestep:
+            case QAPI_OPTION_KIND_SINGLESTEP:
                 singlestep = 1;
                 break;
-            case QEMU_OPTION_S:
+            case QAPI_OPTION_KIND_STOPPED:
                 autostart = 0;
                 break;
-            case QEMU_OPTION_k:
-                keyboard_layout = optarg;
+            case QAPI_OPTION_KIND_KEYBOARD_LAYOUT:
+                keyboard_layout = qopt[i].u.keyboard_layout.data;
                 break;
-            case QEMU_OPTION_localtime:
+            case QAPI_OPTION_KIND_LOCALTIME:
                 rtc_utc = 0;
                 break;
-            case QEMU_OPTION_vga:
-                vga_model = optarg;
+            case QAPI_OPTION_KIND_VGA:
+                vga_model = qopt[i].u.vga.data;
                 default_vga = 0;
                 break;
-            case QEMU_OPTION_g:
+            case QAPI_OPTION_KIND_GRAPHICAL_RESOLUTION:
                 {
                     const char *p;
                     int w, h, depth;
-                    p = optarg;
+
+                    check_option_arch(QEMU_ARCH_PPC | QEMU_ARCH_SPARC);
+                    p = qopt[i].u.graphical_resolution.data;
                     w = strtol(p, (char **)&p, 10);
                     if (w <= 0) {
                     graphic_error:
@@ -3604,55 +3573,57 @@ int main(int argc, char **argv, char **envp)
                     graphic_depth = depth;
                 }
                 break;
-            case QEMU_OPTION_echr:
+            case QAPI_OPTION_KIND_ECHR:
                 {
                     char *r;
-                    term_escape_char = strtol(optarg, &r, 0);
-                    if (r == optarg)
+                    term_escape_char = strtol(qopt[i].u.echr.data, &r, 0);
+                    if (r == qopt[i].u.echr.data) {
                         printf("Bad argument to echr\n");
+                    }
                     break;
                 }
-            case QEMU_OPTION_monitor:
+            case QAPI_OPTION_KIND_MONITOR:
                 default_monitor = 0;
-                if (strncmp(optarg, "none", 4)) {
-                    monitor_parse(optarg, "readline", false);
+                if (strncmp(qopt[i].u.monitor.data, "none", 4)) {
+                    monitor_parse(qopt[i].u.monitor.data, "readline", false);
                 }
                 break;
-            case QEMU_OPTION_qmp:
-                monitor_parse(optarg, "control", false);
+            case QAPI_OPTION_KIND_QMP:
+                monitor_parse(qopt[i].u.qmp.data, "control", false);
                 default_monitor = 0;
                 break;
-            case QEMU_OPTION_qmp_pretty:
-                monitor_parse(optarg, "control", true);
+            case QAPI_OPTION_KIND_QMP_PRETTY:
+                monitor_parse(qopt[i].u.qmp_pretty.data, "control", true);
                 default_monitor = 0;
                 break;
-            case QEMU_OPTION_mon:
-                opts = qemu_opts_parse_noisily(qemu_find_opts("mon"), optarg,
-                                               true);
+            case QAPI_OPTION_KIND_MON:
+                opts = qemu_opts_parse_noisily(qemu_find_opts("mon"),
+                                               qopt[i].u.mon.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 default_monitor = 0;
                 break;
-            case QEMU_OPTION_chardev:
+            case QAPI_OPTION_KIND_CHARDEV:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("chardev"),
-                                               optarg, true);
+                                               qopt[i].u.chardev.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_fsdev:
+            case QAPI_OPTION_KIND_FSDEV:
                 olist = qemu_find_opts("fsdev");
                 if (!olist) {
                     error_report("fsdev support is disabled");
                     exit(1);
                 }
-                opts = qemu_opts_parse_noisily(olist, optarg, true);
+                opts = qemu_opts_parse_noisily(olist, qopt[i].u.fsdev.data,
+                                               true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_virtfs: {
+            case QAPI_OPTION_KIND_VIRTFS: {
                 QemuOpts *fsdev;
                 QemuOpts *device;
                 const char *writeout, *sock_fd, *socket, *path, *security_model;
@@ -3662,7 +3633,8 @@ int main(int argc, char **argv, char **envp)
                     error_report("virtfs support is disabled");
                     exit(1);
                 }
-                opts = qemu_opts_parse_noisily(olist, optarg, true);
+                opts = qemu_opts_parse_noisily(olist, qopt[i].u.virtfs.data,
+                                               true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3724,7 +3696,7 @@ int main(int argc, char **argv, char **envp)
                              qemu_opt_get(opts, "mount_tag"), &error_abort);
                 break;
             }
-            case QEMU_OPTION_virtfs_synth: {
+            case QAPI_OPTION_KIND_VIRTFS_SYNTH: {
                 QemuOpts *fsdev;
                 QemuOpts *device;
 
@@ -3743,62 +3715,63 @@ int main(int argc, char **argv, char **envp)
                 qemu_opt_set(device, "mount_tag", "v_synth", &error_abort);
                 break;
             }
-            case QEMU_OPTION_serial:
-                add_device_config(DEV_SERIAL, optarg);
+            case QAPI_OPTION_KIND_SERIAL:
+                add_device_config(DEV_SERIAL, qopt[i].u.serial.data);
                 default_serial = 0;
-                if (strncmp(optarg, "mon:", 4) == 0) {
+                if (strncmp(qopt[i].u.serial.data, "mon:", 4) == 0) {
                     default_monitor = 0;
                 }
                 break;
-            case QEMU_OPTION_watchdog:
+            case QAPI_OPTION_KIND_WATCHDOG:
                 if (watchdog) {
                     error_report("only one watchdog option may be given");
                     return 1;
                 }
-                watchdog = optarg;
+                watchdog = qopt[i].u.watchdog.data;
                 break;
-            case QEMU_OPTION_watchdog_action:
-                if (select_watchdog_action(optarg) == -1) {
+            case QAPI_OPTION_KIND_WATCHDOG_ACTION:
+                if (select_watchdog_action(qopt[i].u.watchdog_action.data)
+                    == -1) {
                     error_report("unknown -watchdog-action parameter");
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_virtiocon:
-                add_device_config(DEV_VIRTCON, optarg);
+            case QAPI_OPTION_KIND_VIRTIOCONSOLE:
+                add_device_config(DEV_VIRTCON, qopt[i].u.virtioconsole.data);
                 default_virtcon = 0;
-                if (strncmp(optarg, "mon:", 4) == 0) {
+                if (strncmp(qopt[i].u.virtioconsole.data, "mon:", 4) == 0) {
                     default_monitor = 0;
                 }
                 break;
-            case QEMU_OPTION_parallel:
-                add_device_config(DEV_PARALLEL, optarg);
+            case QAPI_OPTION_KIND_PARALLEL:
+                add_device_config(DEV_PARALLEL, qopt[i].u.parallel.data);
                 default_parallel = 0;
-                if (strncmp(optarg, "mon:", 4) == 0) {
+                if (strncmp(qopt[i].u.parallel.data, "mon:", 4) == 0) {
                     default_monitor = 0;
                 }
                 break;
-            case QEMU_OPTION_debugcon:
-                add_device_config(DEV_DEBUGCON, optarg);
+            case QAPI_OPTION_KIND_DEBUGCON:
+                add_device_config(DEV_DEBUGCON, qopt[i].u.debugcon.data);
                 break;
-            case QEMU_OPTION_loadvm:
-                loadvm = optarg;
+            case QAPI_OPTION_KIND_LOADVM:
+                loadvm = qopt[i].u.loadvm.data;
                 break;
-            case QEMU_OPTION_full_screen:
+            case QAPI_OPTION_KIND_FULL_SCREEN:
                 full_screen = 1;
                 break;
-            case QEMU_OPTION_no_frame:
+            case QAPI_OPTION_KIND_NO_FRAME:
                 no_frame = 1;
                 break;
-            case QEMU_OPTION_alt_grab:
+            case QAPI_OPTION_KIND_ALT_GRAB:
                 alt_grab = 1;
                 break;
-            case QEMU_OPTION_ctrl_grab:
+            case QAPI_OPTION_KIND_CTRL_GRAB:
                 ctrl_grab = 1;
                 break;
-            case QEMU_OPTION_no_quit:
+            case QAPI_OPTION_KIND_NO_QUIT:
                 no_quit = 1;
                 break;
-            case QEMU_OPTION_sdl:
+            case QAPI_OPTION_KIND_SDL:
 #ifdef CONFIG_SDL
                 display_type = DT_SDL;
                 break;
@@ -3806,154 +3779,168 @@ int main(int argc, char **argv, char **envp)
                 error_report("SDL support is disabled");
                 exit(1);
 #endif
-            case QEMU_OPTION_pidfile:
-                pid_file = optarg;
+            case QAPI_OPTION_KIND_PIDFILE:
+                pid_file = qopt[i].u.pidfile.data;
                 break;
-            case QEMU_OPTION_win2k_hack:
+            case QAPI_OPTION_KIND_WIN2K_HACK:
+                check_option_arch(QEMU_ARCH_I386);
                 win2k_install_hack = 1;
                 break;
-            case QEMU_OPTION_rtc_td_hack: {
+            case QAPI_OPTION_KIND_RTC_TD_HACK: {
                 static GlobalProperty slew_lost_ticks = {
                     .driver   = "mc146818rtc",
                     .property = "lost_tick_policy",
                     .value    = "slew",
                 };
 
+                check_option_arch(QEMU_ARCH_I386);
                 qdev_prop_register_global(&slew_lost_ticks);
                 break;
             }
-            case QEMU_OPTION_acpitable:
+            case QAPI_OPTION_KIND_ACPITABLE:
+                check_option_arch(QEMU_ARCH_I386);
                 opts = qemu_opts_parse_noisily(qemu_find_opts("acpi"),
-                                               optarg, true);
+                                               qopt[i].u.acpitable.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 acpi_table_add(opts, &error_fatal);
                 break;
-            case QEMU_OPTION_smbios:
+            case QAPI_OPTION_KIND_SMBIOS:
+                check_option_arch(QEMU_ARCH_I386 | QEMU_ARCH_ARM);
                 opts = qemu_opts_parse_noisily(qemu_find_opts("smbios"),
-                                               optarg, false);
+                                               qopt[i].u.smbios.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 smbios_entry_add(opts, &error_fatal);
                 break;
-            case QEMU_OPTION_fwcfg:
+            case QAPI_OPTION_KIND_FW_CFG:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("fw_cfg"),
-                                               optarg, true);
+                                               qopt[i].u.fw_cfg.data, true);
                 if (opts == NULL) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_enable_kvm:
+            case QAPI_OPTION_KIND_ENABLE_KVM:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "accel=kvm", false);
                 break;
-            case QEMU_OPTION_enable_hax:
+            case QAPI_OPTION_KIND_ENABLE_HAX:
+                check_option_arch(QEMU_ARCH_I386);
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "accel=hax", false);
                 break;
-            case QEMU_OPTION_M:
-            case QEMU_OPTION_machine:
+            case QAPI_OPTION_KIND_MACHINE:
                 olist = qemu_find_opts("machine");
-                opts = qemu_opts_parse_noisily(olist, optarg, true);
+                opts = qemu_opts_parse_noisily(olist, qopt[i].u.machine.data,
+                                               true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-             case QEMU_OPTION_no_kvm:
+             case QAPI_OPTION_KIND_NO_KVM:
+                check_option_arch(QEMU_ARCH_I386);
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "accel=tcg", false);
                 break;
-            case QEMU_OPTION_no_kvm_pit: {
+            case QAPI_OPTION_KIND_NO_KVM_PIT: {
+                check_option_arch(QEMU_ARCH_I386);
                 warn_report("ignoring deprecated option");
                 break;
             }
-            case QEMU_OPTION_no_kvm_pit_reinjection: {
+            case QAPI_OPTION_KIND_NO_KVM_PIT_REINJECTION: {
                 static GlobalProperty kvm_pit_lost_tick_policy = {
                     .driver   = "kvm-pit",
                     .property = "lost_tick_policy",
                     .value    = "discard",
                 };
 
+                check_option_arch(QEMU_ARCH_I386);
                 warn_report("deprecated, replaced by "
                             "-global kvm-pit.lost_tick_policy=discard");
                 qdev_prop_register_global(&kvm_pit_lost_tick_policy);
                 break;
             }
-            case QEMU_OPTION_accel:
+            case QAPI_OPTION_KIND_ACCEL:
+            {
+                const char *accel;
                 accel_opts = qemu_opts_parse_noisily(qemu_find_opts("accel"),
-                                                     optarg, true);
-                optarg = qemu_opt_get(accel_opts, "accel");
-                if (!optarg || is_help_option(optarg)) {
+                                                     qopt[i].u.accel.data, true);
+                accel = qemu_opt_get(accel_opts, "accel");
+                if (!accel || is_help_option(qopt[i].u.accel.data)) {
                     error_printf("Possible accelerators: kvm, xen, hax, tcg\n");
                     exit(0);
                 }
                 opts = qemu_opts_create(qemu_find_opts("machine"), NULL,
                                         false, &error_abort);
-                qemu_opt_set(opts, "accel", optarg, &error_abort);
+                qemu_opt_set(opts, "accel", qopt[i].u.accel.data, &error_abort);
                 break;
-            case QEMU_OPTION_usb:
+            }
+            case QAPI_OPTION_KIND_USB:
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "usb=on", false);
                 break;
-            case QEMU_OPTION_usbdevice:
+            case QAPI_OPTION_KIND_USBDEVICE:
                 error_report("'-usbdevice' is deprecated, please use "
                              "'-device usb-...' instead");
                 olist = qemu_find_opts("machine");
                 qemu_opts_parse_noisily(olist, "usb=on", false);
-                add_device_config(DEV_USB, optarg);
+                add_device_config(DEV_USB, qopt[i].u.usbdevice.data);
                 break;
-            case QEMU_OPTION_device:
+            case QAPI_OPTION_KIND_DEVICE:
                 if (!qemu_opts_parse_noisily(qemu_find_opts("device"),
-                                             optarg, true)) {
+                                             qopt[i].u.device.data, true)) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_smp:
+            case QAPI_OPTION_KIND_SMP:
                 if (!qemu_opts_parse_noisily(qemu_find_opts("smp-opts"),
-                                             optarg, true)) {
+                                             qopt[i].u.smp.data, true)) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_vnc:
-                vnc_parse(optarg, &error_fatal);
+            case QAPI_OPTION_KIND_VNC:
+                vnc_parse(qopt[i].u.vnc.data, &error_fatal);
                 break;
-            case QEMU_OPTION_no_acpi:
+            case QAPI_OPTION_KIND_NO_ACPI:
+                check_option_arch(QEMU_ARCH_I386 | QEMU_ARCH_ARM);
                 acpi_enabled = 0;
                 break;
-            case QEMU_OPTION_no_hpet:
+            case QAPI_OPTION_KIND_NO_HPET:
+                check_option_arch(QEMU_ARCH_I386);
                 no_hpet = 1;
                 break;
-            case QEMU_OPTION_balloon:
-                if (balloon_parse(optarg) < 0) {
-                    error_report("unknown -balloon argument %s", optarg);
+            case QAPI_OPTION_KIND_BALLOON:
+                if (balloon_parse(qopt[i].u.balloon.data) < 0) {
+                    error_report("unknown -balloon argument %s",
+                                 qopt[i].u.balloon.data);
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_no_reboot:
+            case QAPI_OPTION_KIND_NO_REBOOT:
                 no_reboot = 1;
                 break;
-            case QEMU_OPTION_no_shutdown:
+            case QAPI_OPTION_KIND_NO_SHUTDOWN:
                 no_shutdown = 1;
                 break;
-            case QEMU_OPTION_show_cursor:
+            case QAPI_OPTION_KIND_SHOW_CURSOR:
                 cursor_hide = 0;
                 break;
-            case QEMU_OPTION_uuid:
-                if (qemu_uuid_parse(optarg, &qemu_uuid) < 0) {
+            case QAPI_OPTION_KIND_UUID:
+                if (qemu_uuid_parse(qopt[i].u.uuid.data, &qemu_uuid) < 0) {
                     error_report("failed to parse UUID string: wrong format");
                     exit(1);
                 }
                 qemu_uuid_set = true;
                 break;
-            case QEMU_OPTION_option_rom:
+            case QAPI_OPTION_KIND_OPTION_ROM:
                 if (nb_option_roms >= MAX_OPTION_ROMS) {
                     error_report("too many option ROMs");
                     exit(1);
                 }
                 opts = qemu_opts_parse_noisily(qemu_find_opts("option-rom"),
-                                               optarg, true);
+                                               qopt[i].u.option_rom.data, true);
                 if (!opts) {
                     exit(1);
                 }
@@ -3966,14 +3953,20 @@ int main(int argc, char **argv, char **envp)
                 }
                 nb_option_roms++;
                 break;
-            case QEMU_OPTION_semihosting:
+            case QAPI_OPTION_KIND_SEMIHOSTING:
+                check_option_arch(QEMU_ARCH_ARM | QEMU_ARCH_M68K
+                                  | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32
+                                  | QEMU_ARCH_MIPS);
                 semihosting.enabled = true;
                 semihosting.target = SEMIHOSTING_TARGET_AUTO;
                 break;
-            case QEMU_OPTION_semihosting_config:
+            case QAPI_OPTION_KIND_SEMIHOSTING_CONFIG:
+                check_option_arch(QEMU_ARCH_ARM | QEMU_ARCH_M68K
+                                  | QEMU_ARCH_XTENSA | QEMU_ARCH_LM32
+                                  | QEMU_ARCH_MIPS);
                 semihosting.enabled = true;
                 opts = qemu_opts_parse_noisily(qemu_find_opts("semihosting-config"),
-                                               optarg, false);
+                                               qopt[i].u.semihosting_config.data, false);
                 if (opts != NULL) {
                     semihosting.enabled = qemu_opt_get_bool(opts, "enable",
                                                             true);
@@ -3987,7 +3980,7 @@ int main(int argc, char **argv, char **envp)
                             semihosting.target = SEMIHOSTING_TARGET_AUTO;
                         } else {
                             error_report("unsupported semihosting-config %s",
-                                         optarg);
+                                         qopt[i].u.semihosting_config.data);
                             exit(1);
                         }
                     } else {
@@ -3997,71 +3990,75 @@ int main(int argc, char **argv, char **envp)
                     qemu_opt_foreach(opts, add_semihosting_arg,
                                      &semihosting, NULL);
                 } else {
-                    error_report("unsupported semihosting-config %s", optarg);
+                    error_report("unsupported semihosting-config %s",
+                                 qopt[i].u.semihosting_config.data);
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_tdf:
+            case QAPI_OPTION_KIND_TDF:
                 warn_report("ignoring deprecated option");
                 break;
-            case QEMU_OPTION_name:
+            case QAPI_OPTION_KIND_NAME:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("name"),
-                                               optarg, true);
+                                               qopt[i].u.name.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_prom_env:
+            case QAPI_OPTION_KIND_PROM_ENV:
+                check_option_arch(QEMU_ARCH_PPC | QEMU_ARCH_SPARC);
                 if (nb_prom_envs >= MAX_PROM_ENVS) {
                     error_report("too many prom variables");
                     exit(1);
                 }
-                prom_envs[nb_prom_envs] = optarg;
+                prom_envs[nb_prom_envs] = qopt[i].u.prom_env.data;
                 nb_prom_envs++;
                 break;
-            case QEMU_OPTION_old_param:
+            case QAPI_OPTION_KIND_OLD_PARAM:
+                check_option_arch(QEMU_ARCH_ARM);
                 old_param = 1;
                 break;
-            case QEMU_OPTION_clock:
+            case QAPI_OPTION_KIND_CLOCK:
                 /* Clock options no longer exist.  Keep this option for
                  * backward compatibility.
                  */
                 break;
-            case QEMU_OPTION_startdate:
-                configure_rtc_date_offset(optarg, 1);
+            case QAPI_OPTION_KIND_STARTDATE:
+                configure_rtc_date_offset(qopt[i].u.startdate.data, 1);
                 break;
-            case QEMU_OPTION_rtc:
-                opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"), optarg,
-                                               false);
+            case QAPI_OPTION_KIND_RTC:
+                opts = qemu_opts_parse_noisily(qemu_find_opts("rtc"),
+                                               qopt[i].u.rtc.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 configure_rtc(opts);
                 break;
-            case QEMU_OPTION_tb_size:
+            case QAPI_OPTION_KIND_TB_SIZE:
 #ifndef CONFIG_TCG
                 error_report("TCG is disabled");
                 exit(1);
 #endif
-                if (qemu_strtoul(optarg, NULL, 0, &tcg_tb_size) < 0) {
+                if (qemu_strtoul(qopt[i].u.tb_size.data, NULL, 0, &tcg_tb_size)
+                    < 0) {
                     error_report("Invalid argument to -tb-size");
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_icount:
+            case QAPI_OPTION_KIND_ICOUNT:
                 icount_opts = qemu_opts_parse_noisily(qemu_find_opts("icount"),
-                                                      optarg, true);
+                                                      qopt[i].u.icount.data, true);
                 if (!icount_opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_incoming:
+            case QAPI_OPTION_KIND_INCOMING:
                 if (!incoming) {
                     runstate_set(RUN_STATE_INMIGRATE);
                 }
-                incoming = optarg;
+                incoming = qopt[i].u.incoming.data;
                 break;
-            case QEMU_OPTION_only_migratable:
+            case QAPI_OPTION_KIND_ONLY_MIGRATABLE:
                 /*
                  * TODO: we can remove this option one day, and we
                  * should all use:
@@ -4070,72 +4067,73 @@ int main(int argc, char **argv, char **envp)
                  */
                 qemu_global_option("migration.only-migratable=true");
                 break;
-            case QEMU_OPTION_nodefaults:
+            case QAPI_OPTION_KIND_NODEFAULTS:
                 has_defaults = 0;
                 break;
-            case QEMU_OPTION_xen_domid:
+            case QAPI_OPTION_KIND_XEN_DOMID:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
-                xen_domid = atoi(optarg);
+                xen_domid = atoi(qopt[i].u.xen_domid.data);
                 break;
-            case QEMU_OPTION_xen_create:
+            case QAPI_OPTION_KIND_XEN_CREATE:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_CREATE;
                 break;
-            case QEMU_OPTION_xen_attach:
+            case QAPI_OPTION_KIND_XEN_ATTACH:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_mode = XEN_ATTACH;
                 break;
-            case QEMU_OPTION_xen_domid_restrict:
+            case QAPI_OPTION_KIND_XEN_DOMID_RESTRICT:
                 if (!(xen_available())) {
                     error_report("Option not supported for this target");
                     exit(1);
                 }
                 xen_domid_restrict = true;
                 break;
-            case QEMU_OPTION_trace:
+            case QAPI_OPTION_KIND_TRACE:
                 g_free(trace_file);
-                trace_file = trace_opt_parse(optarg);
+                trace_file = trace_opt_parse(qopt[i].u.trace.data);
                 break;
-            case QEMU_OPTION_readconfig:
+            case QAPI_OPTION_KIND_READCONFIG:
                 {
-                    int ret = qemu_read_config_file(optarg);
+                    int ret = qemu_read_config_file(qopt[i].u.readconfig.data);
                     if (ret < 0) {
-                        error_report("read config %s: %s", optarg,
-                                     strerror(-ret));
+                        error_report("read config %s: %s",
+                                     qopt[i].u.readconfig.data, strerror(-ret));
                         exit(1);
                     }
                     break;
                 }
-            case QEMU_OPTION_spice:
+            case QAPI_OPTION_KIND_SPICE:
                 olist = qemu_find_opts("spice");
                 if (!olist) {
                     error_report("spice support is disabled");
                     exit(1);
                 }
-                opts = qemu_opts_parse_noisily(olist, optarg, false);
+                opts = qemu_opts_parse_noisily(olist, qopt[i].u.spice.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 display_remote++;
                 break;
-            case QEMU_OPTION_writeconfig:
+            case QAPI_OPTION_KIND_WRITECONFIG:
                 {
                     FILE *fp;
-                    if (strcmp(optarg, "-") == 0) {
+                    if (strcmp(qopt[i].u.writeconfig.data, "-") == 0) {
                         fp = stdout;
                     } else {
-                        fp = fopen(optarg, "w");
+                        fp = fopen(qopt[i].u.writeconfig.data, "w");
                         if (fp == NULL) {
-                            error_report("open %s: %s", optarg,
+                            error_report("open %s: %s",
+                                         qopt[i].u.writeconfig.data,
                                          strerror(errno));
                             exit(1);
                         }
@@ -4146,23 +4144,23 @@ int main(int argc, char **argv, char **envp)
                     }
                     break;
                 }
-            case QEMU_OPTION_qtest:
-                qtest_chrdev = optarg;
+            case QAPI_OPTION_KIND_QTEST:
+                qtest_chrdev = qopt[i].u.qtest.data;
                 break;
-            case QEMU_OPTION_qtest_log:
-                qtest_log = optarg;
+            case QAPI_OPTION_KIND_QTEST_LOG:
+                qtest_log = qopt[i].u.qtest_log.data;
                 break;
-            case QEMU_OPTION_sandbox:
+            case QAPI_OPTION_KIND_SANDBOX:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("sandbox"),
-                                               optarg, true);
+                                               qopt[i].u.sandbox.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_add_fd:
+            case QAPI_OPTION_KIND_ADD_FD:
 #ifndef _WIN32
                 opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
-                                               optarg, false);
+                                               qopt[i].u.add_fd.data, false);
                 if (!opts) {
                     exit(1);
                 }
@@ -4172,46 +4170,52 @@ int main(int argc, char **argv, char **envp)
                 exit(1);
 #endif
                 break;
-            case QEMU_OPTION_object:
+            case QAPI_OPTION_KIND_OBJECT:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("object"),
-                                               optarg, true);
+                                               qopt[i].u.object.data, true);
                 if (!opts) {
                     exit(1);
                 }
                 break;
-            case QEMU_OPTION_realtime:
+            case QAPI_OPTION_KIND_REALTIME:
                 opts = qemu_opts_parse_noisily(qemu_find_opts("realtime"),
-                                               optarg, false);
+                                               qopt[i].u.realtime.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 enable_mlock = qemu_opt_get_bool(opts, "mlock", true);
                 break;
-            case QEMU_OPTION_msg:
-                opts = qemu_opts_parse_noisily(qemu_find_opts("msg"), optarg,
-                                               false);
+            case QAPI_OPTION_KIND_MSG:
+                opts = qemu_opts_parse_noisily(qemu_find_opts("msg"),
+                                               qopt[i].u.msg.data, false);
                 if (!opts) {
                     exit(1);
                 }
                 configure_msg(opts);
                 break;
-            case QEMU_OPTION_dump_vmstate:
+            case QAPI_OPTION_KIND_DUMP_VMSTATE:
                 if (vmstate_dump_file) {
                     error_report("only one '-dump-vmstate' "
                                  "option may be given");
                     exit(1);
                 }
-                vmstate_dump_file = fopen(optarg, "w");
+                vmstate_dump_file = fopen(qopt[i].u.dump_vmstate.data, "w");
                 if (vmstate_dump_file == NULL) {
-                    error_report("open %s: %s", optarg, strerror(errno));
+                    error_report("open %s: %s",
+                                 qopt[i].u.dump_vmstate.data, strerror(errno));
                     exit(1);
                 }
                 break;
             default:
-                os_parse_cmd_args(popt->index, optarg);
+                os_parse_cmd_args(&qopt[i]);
             }
-        }
     }
+
+    for (i = qopt[i].idx; argv[i]; i++) {
+        loc_set_cmdline(argv, i, 1);
+        hda_opts = drive_add(IF_DEFAULT, 0, argv[i], HD_OPTS);
+    }
+
     /*
      * Clear error location left behind by the loop.
      * Best done right after the loop.  Do not insert code here!
@@ -4826,6 +4830,8 @@ int main(int argc, char **argv, char **envp)
         break;
     }
 
+    g_free((void *)qopt);
+
     /* must be after terminal init, SDL library changes signal handlers */
     os_setup_signal_handling();
 
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 29/32] qapi/options: QAPIfy --echr argument type
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (27 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 28/32] vl: QAPIfy command line option definition Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 30/32] qapi/options: QAPIfy --watchdog-action " Markus Armbruster
                   ` (2 subsequent siblings)
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Bonus: more rigorous error checking.  Crap like '-echar 666' and
'-echar 0x' are now rejected.

FIXME the error messages are crap:
qemu-system-x86_64: -echr 666: Parameter 'null' expects int8_t
qemu-system-x86_64: -echr 0x: Parameter '<anonymous>' expects integer

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/options.json |  2 +-
 vl.c              | 10 ++--------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/qapi/options.json b/qapi/options.json
index 5a8fdc04ad..853908560d 100644
--- a/qapi/options.json
+++ b/qapi/options.json
@@ -3892,7 +3892,7 @@
 # !end texinfo
 ##
 { 'option': '--echr',
-  'data': 'str',                # FIXME int
+  'data': 'int8',
   'help': "-echr chr       set terminal escape character instead of ctrl-a" }
 
 ##
diff --git a/vl.c b/vl.c
index b9524f7e11..4af2905c60 100644
--- a/vl.c
+++ b/vl.c
@@ -3574,14 +3574,8 @@ int main(int argc, char **argv, char **envp)
                 }
                 break;
             case QAPI_OPTION_KIND_ECHR:
-                {
-                    char *r;
-                    term_escape_char = strtol(qopt[i].u.echr.data, &r, 0);
-                    if (r == qopt[i].u.echr.data) {
-                        printf("Bad argument to echr\n");
-                    }
-                    break;
-                }
+                term_escape_char = qopt[i].u.echr.data;
+                break;
             case QAPI_OPTION_KIND_MONITOR:
                 default_monitor = 0;
                 if (strncmp(qopt[i].u.monitor.data, "none", 4)) {
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 30/32] qapi/options: QAPIfy --watchdog-action argument type
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (28 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 29/32] qapi/options: QAPIfy --echr argument type Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 31/32] qapi/options: QAPIfy --blockdev " Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd " Markus Armbruster
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/options.json | 2 +-
 vl.c              | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/qapi/options.json b/qapi/options.json
index 853908560d..eb1a3e2dde 100644
--- a/qapi/options.json
+++ b/qapi/options.json
@@ -3868,7 +3868,7 @@
 # !end texinfo
 ##
 { 'option': '--watchdog-action',
-  'data': 'str',                # FIXME enum
+  'data': 'WatchdogAction',
   'help': [
 "-watchdog-action reset|shutdown|poweroff|inject-nmi|pause|debug|none",
 "                action when watchdog fires [default=reset]"] }
diff --git a/vl.c b/vl.c
index 4af2905c60..1814a53337 100644
--- a/vl.c
+++ b/vl.c
@@ -3724,11 +3724,8 @@ int main(int argc, char **argv, char **envp)
                 watchdog = qopt[i].u.watchdog.data;
                 break;
             case QAPI_OPTION_KIND_WATCHDOG_ACTION:
-                if (select_watchdog_action(qopt[i].u.watchdog_action.data)
-                    == -1) {
-                    error_report("unknown -watchdog-action parameter");
-                    exit(1);
-                }
+                qmp_watchdog_set_action(qopt[i].u.watchdog_action.data,
+                                        &error_abort);
                 break;
             case QAPI_OPTION_KIND_VIRTIOCONSOLE:
                 add_device_config(DEV_VIRTCON, qopt[i].u.virtioconsole.data);
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 31/32] qapi/options: QAPIfy --blockdev argument type
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (29 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 30/32] qapi/options: QAPIfy --watchdog-action " Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd " Markus Armbruster
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/options.json |  2 +-
 vl.c              | 42 +++++++-----------------------------------
 2 files changed, 8 insertions(+), 36 deletions(-)

diff --git a/qapi/options.json b/qapi/options.json
index eb1a3e2dde..d55c6bfa81 100644
--- a/qapi/options.json
+++ b/qapi/options.json
@@ -877,7 +877,7 @@
 # !end texinfo
 ##
 { 'option': '--blockdev',
-  'data': 'str',                # FIXME BlockdevOptions
+  'data': 'BlockdevOptions', 'boxed': true,
   'help': [
 "-blockdev [driver=]driver[,node-name=N][,discard=ignore|unmap]",
 "          [,cache.direct=on|off][,cache.no-flush=on|off]",
diff --git a/vl.c b/vl.c
index 1814a53337..32f4b5fef3 100644
--- a/vl.c
+++ b/vl.c
@@ -3083,13 +3083,6 @@ int main(int argc, char **argv, char **envp)
     Error *err = NULL;
     bool list_data_dirs = false;
     char **dirs;
-    typedef struct BlockdevOptions_queue {
-        BlockdevOptions *bdo;
-        Location loc;
-        QSIMPLEQ_ENTRY(BlockdevOptions_queue) entry;
-    } BlockdevOptions_queue;
-    QSIMPLEQ_HEAD(, BlockdevOptions_queue) bdo_queue
-        = QSIMPLEQ_HEAD_INITIALIZER(bdo_queue);
     QAPIOption *qopt;
 
     module_call_init(MODULE_INIT_TRACE);
@@ -3233,25 +3226,8 @@ int main(int argc, char **argv, char **envp)
                 drive_add(IF_DEFAULT, 3, qopt[i].u.hdb.data, HD_OPTS);
                 break;
             case QAPI_OPTION_KIND_BLOCKDEV:
-                {
-                    Visitor *v;
-                    BlockdevOptions_queue *bdo;
-
-                    v = qobject_input_visitor_new_str(qopt[i].u.blockdev.data,
-                                                      "driver", &err);
-                    if (!v) {
-                        error_report_err(err);
-                        exit(1);
-                    }
-
-                    bdo = g_new(BlockdevOptions_queue, 1);
-                    visit_type_BlockdevOptions(v, NULL, &bdo->bdo,
-                                               &error_fatal);
-                    visit_free(v);
-                    loc_save(&bdo->loc);
-                    QSIMPLEQ_INSERT_TAIL(&bdo_queue, bdo, entry);
-                    break;
-                }
+                /* nothing to do */
+                break;
             case QAPI_OPTION_KIND_DRIVE:
                 if (drive_def(qopt[i].u.drive.data) == NULL) {
                     exit(1);
@@ -4651,15 +4627,11 @@ int main(int argc, char **argv, char **envp)
     }
 
     /* open the virtual block devices */
-    while (!QSIMPLEQ_EMPTY(&bdo_queue)) {
-        BlockdevOptions_queue *bdo = QSIMPLEQ_FIRST(&bdo_queue);
-
-        QSIMPLEQ_REMOVE_HEAD(&bdo_queue, entry);
-        loc_push_restore(&bdo->loc);
-        qmp_blockdev_add(bdo->bdo, &error_fatal);
-        loc_pop(&bdo->loc);
-        qapi_free_BlockdevOptions(bdo->bdo);
-        g_free(bdo);
+    for (i = 0; qopt[i].cnt; i++) {
+        if (qopt[i].type == QAPI_OPTION_KIND_BLOCKDEV) {
+            loc_set_cmdline(argv, qopt[i].idx, qopt[i].cnt);
+            qmp_blockdev_add(&qopt[i].u.blockdev, &error_fatal);
+        }
     }
     if (snapshot || replay_mode != REPLAY_MODE_NONE) {
         qemu_opts_foreach(qemu_find_opts("drive"), drive_enable_snapshot,
-- 
2.13.6

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

* [Qemu-devel] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd argument type
  2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
                   ` (30 preceding siblings ...)
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 31/32] qapi/options: QAPIfy --blockdev " Markus Armbruster
@ 2017-10-02 15:25 ` Markus Armbruster
  31 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-02 15:25 UTC (permalink / raw)
  To: qemu-devel; +Cc: mdroth, marcandre.lureau, eblake

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qapi/options.json |  2 +-
 vl.c              | 70 +++++++++++++------------------------------------------
 2 files changed, 17 insertions(+), 55 deletions(-)

diff --git a/qapi/options.json b/qapi/options.json
index d55c6bfa81..c46c3deb10 100644
--- a/qapi/options.json
+++ b/qapi/options.json
@@ -285,7 +285,7 @@
 # !end texinfo
 ##
 { 'option': '--add-fd',
-  'data': 'str',                # FIXME QAPIfy qemu_add_fd_opts
+  'data': { 'fd': 'int', 'set': 'int', '*opaque': 'str' },
   'help': [
 "-add-fd fd=fd,set=set[,opaque=opaque]",
 "                Add 'fd' to fd 'set'"] }
diff --git a/vl.c b/vl.c
index 32f4b5fef3..e769796c11 100644
--- a/vl.c
+++ b/vl.c
@@ -371,27 +371,6 @@ static QemuOptsList qemu_boot_opts = {
     },
 };
 
-static QemuOptsList qemu_add_fd_opts = {
-    .name = "add-fd",
-    .head = QTAILQ_HEAD_INITIALIZER(qemu_add_fd_opts.head),
-    .desc = {
-        {
-            .name = "fd",
-            .type = QEMU_OPT_NUMBER,
-            .help = "file descriptor of which a duplicate is added to fd set",
-        },{
-            .name = "set",
-            .type = QEMU_OPT_NUMBER,
-            .help = "ID of the fd set to add fd to",
-        },{
-            .name = "opaque",
-            .type = QEMU_OPT_STRING,
-            .help = "free-form string used to describe fd",
-        },
-        { /* end of list */ }
-    },
-};
-
 static QemuOptsList qemu_object_opts = {
     .name = "object",
     .implied_opt_name = "qom-type",
@@ -1148,19 +1127,13 @@ bool defaults_enabled(void)
 }
 
 #ifndef _WIN32
-static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
+static int do_add_fd(int fd, int64_t fdset_id, const char *fd_opaque)
 {
-    int fd, dupfd, flags;
-    int64_t fdset_id;
-    const char *fd_opaque = NULL;
+    int dupfd, flags;
     AddfdInfo *fdinfo;
 
-    fd = qemu_opt_get_number(opts, "fd", -1);
-    fdset_id = qemu_opt_get_number(opts, "set", -1);
-    fd_opaque = qemu_opt_get(opts, "opaque");
-
     if (fd < 0) {
-        error_report("fd option is required and must be non-negative");
+        error_report("fd option must be non-negative");
         return -1;
     }
 
@@ -1180,7 +1153,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
     }
 
     if (fdset_id < 0) {
-        error_report("set option is required and must be non-negative");
+        error_report("set option must be non-negative");
         return -1;
     }
 
@@ -1204,16 +1177,6 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
 
     return 0;
 }
-
-static int cleanup_add_fd(void *opaque, QemuOpts *opts, Error **errp)
-{
-    int fd;
-
-    fd = qemu_opt_get_number(opts, "fd", -1);
-    close(fd);
-
-    return 0;
-}
 #endif
 
 /***********************************************************/
@@ -3120,7 +3083,6 @@ int main(int argc, char **argv, char **envp)
     qemu_add_opts(&qemu_smp_opts);
     qemu_add_opts(&qemu_boot_opts);
     qemu_add_opts(&qemu_sandbox_opts);
-    qemu_add_opts(&qemu_add_fd_opts);
     qemu_add_opts(&qemu_object_opts);
     qemu_add_opts(&qemu_tpmdev_opts);
     qemu_add_opts(&qemu_realtime_opts);
@@ -4126,11 +4088,7 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QAPI_OPTION_KIND_ADD_FD:
 #ifndef _WIN32
-                opts = qemu_opts_parse_noisily(qemu_find_opts("add-fd"),
-                                               qopt[i].u.add_fd.data, false);
-                if (!opts) {
-                    exit(1);
-                }
+                /* nothing to do */
 #else
                 error_report("File descriptor passing is disabled on this "
                              "platform");
@@ -4219,14 +4177,18 @@ int main(int argc, char **argv, char **envp)
     }
 
 #ifndef _WIN32
-    if (qemu_opts_foreach(qemu_find_opts("add-fd"),
-                          parse_add_fd, NULL, NULL)) {
-        exit(1);
+    for (i = 0; qopt[i].cnt; i++) {
+        if (qopt[i].type == QAPI_OPTION_KIND_ADD_FD) {
+            if (do_add_fd(qopt[i].u.add_fd.fd, qopt[i].u.add_fd.set,
+                          qopt[i].u.add_fd.opaque) < 0) {
+                exit(1);
+            }
+        }
     }
-
-    if (qemu_opts_foreach(qemu_find_opts("add-fd"),
-                          cleanup_add_fd, NULL, NULL)) {
-        exit(1);
+    for (i = 0; qopt[i].cnt; i++) {
+        if (qopt[i].type == QAPI_OPTION_KIND_ADD_FD) {
+            close(qopt[i].u.add_fd.fd);
+        }
     }
 #endif
 
-- 
2.13.6

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

* Re: [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@'
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@' Markus Armbruster
@ 2017-10-04 10:37   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:37 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Demonstrates a qapi2texi.py bug: it can fail to escape '@'.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  tests/qapi-schema/doc-good.json | 3 +++
>  tests/qapi-schema/doc-good.out  | 3 +++
>  tests/qapi-schema/doc-good.texi | 4 ++++
>  3 files changed, 10 insertions(+)
>
> diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
> index 97ab4625ff..44098d7f1a 100644
> --- a/tests/qapi-schema/doc-good.json
> +++ b/tests/qapi-schema/doc-good.json
> @@ -10,6 +10,7 @@
>  #
>  # *strong* _with emphasis_
>  # @var {in braces}
> +# lone @ BUG: gets passed to Texinfo unescaped
>  # * List item one
>  # - Two, multiple
>  #   lines
> @@ -46,6 +47,7 @@
>  # <- out
>  # Examples:
>  # - *verbatim*
> +# - @at sign
>  # - {braces}
>  ##
>
> @@ -115,6 +117,7 @@
>  # <- out
>  # Examples:
>  # - *verbatim*
> +# - @at sign BUG: gets passed to Texinfo unescaped
>  # - {braces}
>  # Since: 2.10
>  ##
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index 1d2c250527..b732b81119 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -38,6 +38,7 @@ doc freeform
>
>  *strong* _with emphasis_
>  @var {in braces}
> +lone @ BUG: gets passed to Texinfo unescaped
>  * List item one
>  - Two, multiple
>  lines
> @@ -74,6 +75,7 @@ Example:
>  <- out
>  Examples:
>  - *verbatim*
> +- @at sign
>  - {braces}
>  doc symbol=Enum
>      body=
> @@ -136,6 +138,7 @@ Duis aute irure dolor
>  <- out
>      section=Examples
>  - *verbatim*
> +- @at sign BUG: gets passed to Texinfo unescaped
>  - {braces}
>      section=Since
>  2.10
> diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
> index 1778312581..840a492249 100644
> --- a/tests/qapi-schema/doc-good.texi
> +++ b/tests/qapi-schema/doc-good.texi
> @@ -4,6 +4,7 @@
>
>  @strong{strong} @emph{with emphasis}
>  @code{var} @{in braces@}
> +lone @ BUG: gets passed to Texinfo unescaped
>  @itemize @bullet
>  @item
>  List item one
> @@ -69,6 +70,8 @@ Examples:
>  @item
>  @strong{verbatim}
>  @item
> +@code{at} sign
> +@item
>  @{braces@}
>  @end itemize
>
> @@ -206,6 +209,7 @@ Duis aute irure dolor
>  @b{Examples:}
>  @example
>  - *verbatim*
> +- @at sign BUG: gets passed to Texinfo unescaped
>  - @{braces@}
>  @end example
>
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@'
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@' Markus Armbruster
@ 2017-10-04 10:45   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:45 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

Hi

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Instead of quoting example text so that the @example environment shows
> it verbatim, simply use the @verbatim environment.
>

Not sure if this is really worth it, unless we have a real use-case of
@ in examples.

> Examples are no longer indented in output, because makeinfo doesn't
> indent @verbatim, unlike @example.
> TODO keep indentation somehow?
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/qapi2texi.py            | 12 +++++-------
>  tests/qapi-schema/doc-good.json |  2 +-
>  tests/qapi-schema/doc-good.out  |  2 +-
>  tests/qapi-schema/doc-good.texi | 16 ++++++++--------
>  4 files changed, 15 insertions(+), 17 deletions(-)
>
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index 92e2af2cd6..1500afc553 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -52,13 +52,11 @@ def subst_braces(doc):
>
>
>  def texi_example(doc):
> -    """Format @example"""
> -    # TODO: Neglects to escape @ characters.
> -    # We should probably escape them in subst_braces(), and rename the
> -    # function to subst_special() or subs_texi_special().  If we do that, we
> -    # need to delay it until after subst_vars() in texi_format().
> -    doc = subst_braces(doc).strip('\n')
> -    return EXAMPLE_FMT(code=doc)
> +    """Format example text"""
> +    return """@verbatim
> +{code}
> +@end verbatim
> +""".format(code=doc.strip('\n'))
>
>
>  def texi_format(doc):
> diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
> index 44098d7f1a..54a0012d5f 100644
> --- a/tests/qapi-schema/doc-good.json
> +++ b/tests/qapi-schema/doc-good.json
> @@ -117,7 +117,7 @@
>  # <- out
>  # Examples:
>  # - *verbatim*
> -# - @at sign BUG: gets passed to Texinfo unescaped
> +# - @at sign
>  # - {braces}
>  # Since: 2.10
>  ##
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index b732b81119..a62d2d879c 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -138,7 +138,7 @@ Duis aute irure dolor
>  <- out
>      section=Examples
>  - *verbatim*
> -- @at sign BUG: gets passed to Texinfo unescaped
> +- @at sign
>  - {braces}
>      section=Since
>  2.10
> diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
> index 840a492249..3b77f2f675 100644
> --- a/tests/qapi-schema/doc-good.texi
> +++ b/tests/qapi-schema/doc-good.texi
> @@ -201,17 +201,17 @@ Ut enim ad minim veniam
>  Duis aute irure dolor
>
>  @b{Example:}
> -@example
> +@verbatim
>  -> in
>  <- out
> -@end example
> +@end verbatim
>
>  @b{Examples:}
> -@example
> +@verbatim
>  - *verbatim*
> -- @at sign BUG: gets passed to Texinfo unescaped
> -- @{braces@}
> -@end example
> +- @at sign
> +- {braces}
> +@end verbatim
>
>  @b{Since:}
>  2.10
> @@ -227,11 +227,11 @@ If you're bored enough to read this, go see a video of boxed cats
>  @b{Arguments:} the members of @code{Object}
>
>  @b{Example:}
> -@example
> +@verbatim
>  -> in
>
>  <- out
> -@end example
> +@end verbatim
>
>  @end deftypefn
>
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character Markus Armbruster
@ 2017-10-04 10:47   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:47 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi2texi.py            | 22 ++++++++++++----------
>  tests/qapi-schema/doc-good.json |  2 +-
>  tests/qapi-schema/doc-good.out  |  2 +-
>  tests/qapi-schema/doc-good.texi |  2 +-
>  4 files changed, 15 insertions(+), 13 deletions(-)
>
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index 1500afc553..cfcd8a19f0 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -41,14 +41,17 @@ def subst_emph(doc):
>      return re.sub(r'\b_([^_\n]+)_\b', r'@emph{\1}', doc)
>
>
> -def subst_vars(doc):
> -    """Replaces @var by @code{var}"""
> -    return re.sub(r'@([\w-]+)', r'@code{\1}', doc)
> -
> -
> -def subst_braces(doc):
> -    """Replaces {} with @{ @}"""
> -    return doc.replace('{', '@{').replace('}', '@}')
> +def subst_special(doc):
> +    ret = ''
> +    for m in re.finditer(r'([^@{}]*)(@([-\w]*)|[{}])?', doc):
> +        ret += m.group(1)
> +        if m.group(3):
> +            # format @NAME as @code{NAME}
> +            ret += '@code{' + m.group(3) + '}'
> +        elif m.group(2):
> +            # escape Texinfo's special characters
> +            ret += '@' + m.group(2)
> +    return ret
>
>
>  def texi_example(doc):
> @@ -71,8 +74,7 @@ def texi_format(doc):
>      - */-: generates an @itemize list
>      """
>      ret = ''
> -    doc = subst_braces(doc)
> -    doc = subst_vars(doc)
> +    doc = subst_special(doc)
>      doc = subst_emph(doc)
>      doc = subst_strong(doc)
>      inlist = ''
> diff --git a/tests/qapi-schema/doc-good.json b/tests/qapi-schema/doc-good.json
> index 54a0012d5f..274004a8b6 100644
> --- a/tests/qapi-schema/doc-good.json
> +++ b/tests/qapi-schema/doc-good.json
> @@ -10,7 +10,7 @@
>  #
>  # *strong* _with emphasis_
>  # @var {in braces}
> -# lone @ BUG: gets passed to Texinfo unescaped
> +# lone @
>  # * List item one
>  # - Two, multiple
>  #   lines
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index a62d2d879c..46261d5010 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -38,7 +38,7 @@ doc freeform
>
>  *strong* _with emphasis_
>  @var {in braces}
> -lone @ BUG: gets passed to Texinfo unescaped
> +lone @
>  * List item one
>  - Two, multiple
>  lines
> diff --git a/tests/qapi-schema/doc-good.texi b/tests/qapi-schema/doc-good.texi
> index 3b77f2f675..8777cbb7fb 100644
> --- a/tests/qapi-schema/doc-good.texi
> +++ b/tests/qapi-schema/doc-good.texi
> @@ -4,7 +4,7 @@
>
>  @strong{strong} @emph{with emphasis}
>  @code{var} @{in braces@}
> -lone @ BUG: gets passed to Texinfo unescaped
> +lone @@
>  @itemize @bullet
>  @item
>  List item one
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True Markus Armbruster
@ 2017-10-04 10:52   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:52 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> check_command() passes allow_optional=True to check_type().  Useless
> unless you also pass allow_dict=True, which check_command() doesn't.
> Drop the superfluous argument.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 43a54bf40f..248af89b0b 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -695,7 +695,7 @@ def check_command(expr, info):
>          returns_meta += ['built-in', 'alternate', 'enum']
>      check_type(info, "'returns' for command '%s'" % name,
>                 expr.get('returns'), allow_array=True,
> -               allow_optional=True, allow_metas=returns_meta)
> +               allow_metas=returns_meta)
>
>
>  def check_event(expr, info):
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters Markus Armbruster
@ 2017-10-04 10:54   ` Marc-André Lureau
  2017-10-04 10:54   ` Marc-André Lureau
  1 sibling, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:54 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Replace flags @enum_member, @allow_optional by string @meta:
> 'member-enum' implies @enum_member, 'member-struct' implies
> @allow_optional.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 248af89b0b..208010c241 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -593,8 +593,7 @@ valid_name = re.compile(r'^(__[a-zA-Z0-9.-]+_)?'
>                          '[a-zA-Z][a-zA-Z0-9_-]*$')
>
>
> -def check_name(info, source, name, allow_optional=False,
> -               enum_member=False):
> +def check_name(info, source, name, meta):
>      global valid_name
>      membername = name
>
> @@ -602,12 +601,12 @@ def check_name(info, source, name, allow_optional=False,
>          raise QAPISemError(info, "%s requires a string name" % source)
>      if name.startswith('*'):
>          membername = name[1:]
> -        if not allow_optional:
> +        if meta != 'member-struct':
>              raise QAPISemError(info, "%s does not allow optional name '%s'"
>                                 % (source, name))
>      # Enum members can start with a digit, because the generated C
>      # code always prefixes it with the enum name
> -    if enum_member and membername[0].isdigit():
> +    if meta == 'member-enum' and membername[0].isdigit():
>          membername = 'D' + membername
>      # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty'
>      # and 'q_obj_*' implicit type names.
> @@ -618,7 +617,7 @@ def check_name(info, source, name, allow_optional=False,
>
>  def add_name(name, info, meta, implicit=False):
>      global all_names
> -    check_name(info, "'%s'" % meta, name)
> +    check_name(info, "'%s'" % meta, name, meta)
>      # FIXME should reject names that differ only in '_' vs. '.'
>      # vs. '-', because they're liable to clash in generated C.
>      if name in all_names:
> @@ -667,8 +666,7 @@ def check_type(info, source, value, allow_array=False,
>
>      # value is a dictionary, check that each member is okay
>      for (key, arg) in value.items():
> -        check_name(info, "Member of %s" % source, key,
> -                   allow_optional=allow_optional)
> +        check_name(info, "Member of %s" % source, key, 'member-struct')
>          if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'):
>              raise QAPISemError(info, "Member of %s uses reserved name '%s'"
>                                 % (source, key))
> @@ -741,7 +739,7 @@ def check_union(expr, info):
>          # The value of member 'discriminator' must name a non-optional
>          # member of the base struct.
>          check_name(info, "Discriminator of flat union '%s'" % name,
> -                   discriminator)
> +                   discriminator, 'member-union')
>          discriminator_type = base_members.get(discriminator)
>          if not discriminator_type:
>              raise QAPISemError(info,
> @@ -760,7 +758,7 @@ def check_union(expr, info):
>      if len(members) == 0:
>          raise QAPISemError(info, "Union '%s' cannot have empty 'data'" % name)
>      for (key, value) in members.items():
> -        check_name(info, "Member of union '%s'" % name, key)
> +        check_name(info, "Member of union '%s'" % name, key, 'member-union')
>
>          # Each value must name a known type
>          check_type(info, "Member '%s' of union '%s'" % (key, name),
> @@ -794,7 +792,8 @@ def check_alternate(expr, info):
>                             "Alternate '%s' should have at least two branches "
>                             "in 'data'" % name)
>      for (key, value) in members.items():
> -        check_name(info, "Member of alternate '%s'" % name, key)
> +        check_name(info, "Member of alternate '%s'" % name, key,
> +                   'member-alternate')
>
>          # Ensure alternates have no type conflicts.
>          check_type(info, "Member '%s' of alternate '%s'" % (key, name),
> @@ -836,8 +835,7 @@ def check_enum(expr, info):
>          raise QAPISemError(info,
>                             "Enum '%s' requires a string for 'prefix'" % name)
>      for member in members:
> -        check_name(info, "Member of enum '%s'" % name, member,
> -                   enum_member=True)
> +        check_name(info, "Member of enum '%s'" % name, member, 'member-enum')
>
>
>  def check_struct(expr, info):
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters Markus Armbruster
  2017-10-04 10:54   ` Marc-André Lureau
@ 2017-10-04 10:54   ` Marc-André Lureau
  1 sibling, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:54 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Replace flags @enum_member, @allow_optional by string @meta:
> 'member-enum' implies @enum_member, 'member-struct' implies
> @allow_optional.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py | 22 ++++++++++------------
>  1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 248af89b0b..208010c241 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -593,8 +593,7 @@ valid_name = re.compile(r'^(__[a-zA-Z0-9.-]+_)?'
>                          '[a-zA-Z][a-zA-Z0-9_-]*$')
>
>
> -def check_name(info, source, name, allow_optional=False,
> -               enum_member=False):
> +def check_name(info, source, name, meta):
>      global valid_name
>      membername = name
>
> @@ -602,12 +601,12 @@ def check_name(info, source, name, allow_optional=False,
>          raise QAPISemError(info, "%s requires a string name" % source)
>      if name.startswith('*'):
>          membername = name[1:]
> -        if not allow_optional:
> +        if meta != 'member-struct':
>              raise QAPISemError(info, "%s does not allow optional name '%s'"
>                                 % (source, name))
>      # Enum members can start with a digit, because the generated C
>      # code always prefixes it with the enum name
> -    if enum_member and membername[0].isdigit():
> +    if meta == 'member-enum' and membername[0].isdigit():
>          membername = 'D' + membername
>      # Reserve the entire 'q_' namespace for c_name(), and for 'q_empty'
>      # and 'q_obj_*' implicit type names.
> @@ -618,7 +617,7 @@ def check_name(info, source, name, allow_optional=False,
>
>  def add_name(name, info, meta, implicit=False):
>      global all_names
> -    check_name(info, "'%s'" % meta, name)
> +    check_name(info, "'%s'" % meta, name, meta)
>      # FIXME should reject names that differ only in '_' vs. '.'
>      # vs. '-', because they're liable to clash in generated C.
>      if name in all_names:
> @@ -667,8 +666,7 @@ def check_type(info, source, value, allow_array=False,
>
>      # value is a dictionary, check that each member is okay
>      for (key, arg) in value.items():
> -        check_name(info, "Member of %s" % source, key,
> -                   allow_optional=allow_optional)
> +        check_name(info, "Member of %s" % source, key, 'member-struct')
>          if c_name(key, False) == 'u' or c_name(key, False).startswith('has_'):
>              raise QAPISemError(info, "Member of %s uses reserved name '%s'"
>                                 % (source, key))
> @@ -741,7 +739,7 @@ def check_union(expr, info):
>          # The value of member 'discriminator' must name a non-optional
>          # member of the base struct.
>          check_name(info, "Discriminator of flat union '%s'" % name,
> -                   discriminator)
> +                   discriminator, 'member-union')
>          discriminator_type = base_members.get(discriminator)
>          if not discriminator_type:
>              raise QAPISemError(info,
> @@ -760,7 +758,7 @@ def check_union(expr, info):
>      if len(members) == 0:
>          raise QAPISemError(info, "Union '%s' cannot have empty 'data'" % name)
>      for (key, value) in members.items():
> -        check_name(info, "Member of union '%s'" % name, key)
> +        check_name(info, "Member of union '%s'" % name, key, 'member-union')
>
>          # Each value must name a known type
>          check_type(info, "Member '%s' of union '%s'" % (key, name),
> @@ -794,7 +792,8 @@ def check_alternate(expr, info):
>                             "Alternate '%s' should have at least two branches "
>                             "in 'data'" % name)
>      for (key, value) in members.items():
> -        check_name(info, "Member of alternate '%s'" % name, key)
> +        check_name(info, "Member of alternate '%s'" % name, key,
> +                   'member-alternate')
>
>          # Ensure alternates have no type conflicts.
>          check_type(info, "Member '%s' of alternate '%s'" % (key, name),
> @@ -836,8 +835,7 @@ def check_enum(expr, info):
>          raise QAPISemError(info,
>                             "Enum '%s' requires a string for 'prefix'" % name)
>      for member in members:
> -        check_name(info, "Member of enum '%s'" % name, member,
> -                   enum_member=True)
> +        check_name(info, "Member of enum '%s'" % name, member, 'member-enum')
>
>
>  def check_struct(expr, info):
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop Markus Armbruster
@ 2017-10-04 10:55   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 10:55 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 208010c241..8f9c5666bd 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -629,8 +629,7 @@ def add_name(name, info, meta, implicit=False):
>      all_names[name] = meta
>
>
> -def check_type(info, source, value, allow_array=False,
> -               allow_dict=False, allow_optional=False,
> +def check_type(info, source, value, allow_array=False, allow_dict=False,
>                 allow_metas=[]):
>      global all_names
>
> @@ -686,7 +685,7 @@ def check_command(expr, info):
>      if boxed:
>          args_meta += ['union', 'alternate']
>      check_type(info, "'data' for command '%s'" % name,
> -               expr.get('data'), allow_dict=not boxed, allow_optional=True,
> +               expr.get('data'), allow_dict=not boxed,
>                 allow_metas=args_meta)
>      returns_meta = ['union', 'struct']
>      if name in returns_whitelist:
> @@ -704,8 +703,7 @@ def check_event(expr, info):
>      if boxed:
>          meta += ['union', 'alternate']
>      check_type(info, "'data' for event '%s'" % name,
> -               expr.get('data'), allow_dict=not boxed, allow_optional=True,
> -               allow_metas=meta)
> +               expr.get('data'), allow_dict=not boxed, allow_metas=meta)
>
>
>  def check_union(expr, info):
> @@ -728,8 +726,7 @@ def check_union(expr, info):
>      else:
>          # The object must have a string or dictionary 'base'.
>          check_type(info, "'base' for union '%s'" % name,
> -                   base, allow_dict=True, allow_optional=True,
> -                   allow_metas=['struct'])
> +                   base, allow_dict=True, allow_metas=['struct'])
>          if not base:
>              raise QAPISemError(info, "Flat union '%s' must have a base"
>                                 % name)
> @@ -843,7 +840,7 @@ def check_struct(expr, info):
>      members = expr['data']
>
>      check_type(info, "'data' for struct '%s'" % name, members,
> -               allow_dict=True, allow_optional=True)
> +               allow_dict=True)
>      check_type(info, "'base' for struct '%s'" % name, expr.get('base'),
>                 allow_metas=['struct'])
>
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice Markus Armbruster
@ 2017-10-04 11:04   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:04 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> The generators always generate both .c and .h, but they can route one
> of them to the bit bucket.  We run them twice, once to generate .c,
> and once to generate .h.  Probably because the naive make rule
>
>     FOO.c FOO.h: qapi-schema.json
>         RECIPE
>
> runs RECIPE twice, once to generate FOO.c and once to generate FOO.h.
>
> Employ the usual make trick to generate multiple files in one rule:
>
>     .INTERMEDIATE: FOO-gen
>     FOO.c FOO.h: FOO-gen ;
>     FOO-gen: qapi-schema.json
>         RECIPE
>
> When make needs FOO.c or FOO.h, it runs RECIPE once to generate
> intermediate target FOO-gen, then considers both FOO.c and FOO.h
> updated.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

As explained in the following stackoverflow answer:
https://stackoverflow.com/a/10609434/1277510

Nice
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  Makefile               | 58 +++++++++++++++++++++++++++++++++-----------------
>  Makefile.objs          |  2 +-
>  tests/Makefile.include | 36 +++++++++++++++++++++----------
>  3 files changed, 64 insertions(+), 32 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index cee6e28659..784b601247 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -384,24 +384,33 @@ qemu-img-cmds.h: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
>  qemu-ga$(EXESUF): LIBS = $(LIBS_QGA)
>  qemu-ga$(EXESUF): QEMU_CFLAGS += -I qga/qapi-generated
>
> -gen-out-type = $(subst .,-,$(suffix $@))
> -
>  qapi-py = $(SRC_PATH)/scripts/qapi.py $(SRC_PATH)/scripts/ordereddict.py
>
> +.INTERMEDIATE: qga/qapi-generated/qga-qapi-types-gen
>  qga/qapi-generated/qga-qapi-types.c qga/qapi-generated/qga-qapi-types.h :\
> +qga/qapi-generated/qga-qapi-types-gen ;
> +qga/qapi-generated/qga-qapi-types-gen: \
>  $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
> -               $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
> +               -o $(dir $@) -p "qga-" $<, \
>                 "GEN","$@")
> +
> +.INTERMEDIATE: qga/qapi-generated/qga-qapi-visit-gen
>  qga/qapi-generated/qga-qapi-visit.c qga/qapi-generated/qga-qapi-visit.h :\
> +qga/qapi-generated/qga-qapi-visit-gen ;
> +qga/qapi-generated/qga-qapi-visit-gen: \
>  $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
> -               $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
> +               -o $(dir $@) -p "qga-" $<, \
>                 "GEN","$@")
> +
> +.INTERMEDIATE: qga/qapi-generated/qga-qapi-commands-gen
>  qga/qapi-generated/qga-qmp-commands.h qga/qapi-generated/qga-qmp-marshal.c :\
> +qga/qapi-generated/qga-qapi-commands-gen ;
> +qga/qapi-generated/qga-qapi-commands-gen: \
>  $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
> -               $(gen-out-type) -o qga/qapi-generated -p "qga-" $<, \
> +               -o $(dir $@) -p "qga-" $<, \
>                 "GEN","$@")
>
>  qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
> @@ -419,30 +428,39 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>                 $(SRC_PATH)/qapi/transaction.json \
>                 $(SRC_PATH)/qapi/ui.json
>
> -qapi-types.c qapi-types.h :\
> -$(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
> +.INTERMEDIATE: qapi-types-gen
> +qapi-types.c qapi-types.h: qapi-types-gen ;
> +qapi-types-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
> -               $(gen-out-type) -o "." -b $<, \
> +               -b $<, \
>                 "GEN","$@")
> -qapi-visit.c qapi-visit.h :\
> -$(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
> +
> +.INTERMEDIATE: qapi-visit-gen
> +qapi-visit.c qapi-visit.h: qapi-visit-gen ;
> +qapi-visit-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
> -               $(gen-out-type) -o "." -b $<, \
> +               -b $<, \
>                 "GEN","$@")
> -qapi-event.c qapi-event.h :\
> -$(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
> +
> +.INTERMEDIATE: qapi-event-gen
> +qapi-event.c qapi-event.h: qapi-event-gen
> +qapi-event-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
> -               $(gen-out-type) -o "." $<, \
> +               $<, \
>                 "GEN","$@")
> -qmp-commands.h qmp-marshal.c :\
> -$(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
> +
> +.INTERMEDIATE: qapi-commands-gen
> +qmp-commands.h qmp-marshal.c: qapi-commands-gen
> +qapi-commands-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
> -               $(gen-out-type) -o "." $<, \
> +               $<, \
>                 "GEN","$@")
> -qmp-introspect.h qmp-introspect.c :\
> -$(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
> +
> +.INTERMEDIATE: qapi-introspect-gen
> +qmp-introspect.h qmp-introspect.c: qapi-introspect-gen
> +qapi-introspect-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \
> -               $(gen-out-type) -o "." $<, \
> +               $<, \
>                 "GEN","$@")
>
>  QGALIB_GEN=$(addprefix qga/qapi-generated/, qga-qapi-types.h qga-qapi-visit.h qga-qmp-commands.h)
> diff --git a/Makefile.objs b/Makefile.objs
> index bdfa3b6177..cc4f94d77a 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -2,7 +2,7 @@
>  # Common libraries for tools and emulators
>  stub-obj-y = stubs/ crypto/
>  util-obj-y = util/ qobject/ qapi/
> -util-obj-y += qmp-introspect.o qapi-types.o qapi-visit.o qapi-event.o
> +util-obj-y += qapi-types.o qapi-visit.o qapi-event.o
>
>  chardev-obj-y = chardev/
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index de4a713c25..5d53c58506 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -626,30 +626,44 @@ tests/test-logging$(EXESUF): tests/test-logging.o $(test-util-obj-y)
>  tests/test-replication$(EXESUF): tests/test-replication.o $(test-util-obj-y) \
>         $(test-block-obj-y)
>
> -tests/test-qapi-types.c tests/test-qapi-types.h :\
> +.INTERMEDIATE: tests/test-qapi-types-gen
> +tests/test-qapi-types.c tests/test-qapi-types.h: tests/test-qapi-types-gen ;
> +tests/test-qapi-types-gen: \
>  $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
> -               $(gen-out-type) -o tests -p "test-" $<, \
> +               -o tests -p "test-" $<, \
>                 "GEN","$@")
> -tests/test-qapi-visit.c tests/test-qapi-visit.h :\
> +
> +.INTERMEDIATE: tests/test-qapi-visit-gen
> +tests/test-qapi-visit.c tests/test-qapi-visit.h: tests/test-qapi-visit-gen ;
> +tests/test-qapi-visit-gen: \
>  $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
> -               $(gen-out-type) -o tests -p "test-" $<, \
> +               -o tests -p "test-" $<, \
>                 "GEN","$@")
> -tests/test-qmp-commands.h tests/test-qmp-marshal.c :\
> +
> +.INTERMEDIATE: tests/test-qapi-commands-gen
> +tests/test-qmp-commands.h tests/test-qmp-marshal.c: tests/test-qapi-commands-gen ;
> +tests/test-qapi-commands-gen: \
>  $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-commands.py \
> -               $(gen-out-type) -o tests -p "test-" $<, \
> +               -o tests -p "test-" $<, \
>                 "GEN","$@")
> -tests/test-qapi-event.c tests/test-qapi-event.h :\
> +
> +.INTERMEDIATE: tests/test-qapi-event-gen
> +tests/test-qapi-event.c tests/test-qapi-event.h: tests/test-qapi-event-gen ;
> +tests/test-qapi-event-gen: \
>  $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-event.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-event.py \
> -               $(gen-out-type) -o tests -p "test-" $<, \
> +               -o tests -p "test-" $<, \
>                 "GEN","$@")
> -tests/test-qmp-introspect.c tests/test-qmp-introspect.h :\
> +
> +.INTERMEDIATE: tests/test-qapi-introspect-gen
> +tests/test-qmp-introspect.c tests/test-qmp-introspect.h: tests/test-qapi-introspect-gen ;
> +tests/test-qapi-introspect-gen: \
>  $(SRC_PATH)/tests/qapi-schema/qapi-schema-test.json $(SRC_PATH)/scripts/qapi-introspect.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-introspect.py \
> -               $(gen-out-type) -o tests -p "test-" $<, \
> +               -o tests -p "test-" $<, \
>                 "GEN","$@")
>
>  tests/qapi-schema/doc-good.test.texi: $(SRC_PATH)/tests/qapi-schema/doc-good.json $(SRC_PATH)/scripts/qapi2texi.py $(qapi-py)
> @@ -660,7 +674,7 @@ tests/test-string-input-visitor$(EXESUF): tests/test-string-input-visitor.o $(te
>  tests/test-qmp-event$(EXESUF): tests/test-qmp-event.o $(test-qapi-obj-y)
>  tests/test-qobject-output-visitor$(EXESUF): tests/test-qobject-output-visitor.o $(test-qapi-obj-y)
>  tests/test-clone-visitor$(EXESUF): tests/test-clone-visitor.o $(test-qapi-obj-y)
> -tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y)
> +tests/test-qobject-input-visitor$(EXESUF): tests/test-qobject-input-visitor.o $(test-qapi-obj-y) qmp-introspect.o
>  tests/test-qmp-commands$(EXESUF): tests/test-qmp-commands.o tests/test-qmp-marshal.o $(test-qapi-obj-y)
>  tests/test-visitor-serialization$(EXESUF): tests/test-visitor-serialization.o $(test-qapi-obj-y)
>  tests/test-opts-visitor$(EXESUF): tests/test-opts-visitor.o $(test-qapi-obj-y)
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h Markus Armbruster
@ 2017-10-04 11:07   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:07 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi-commands.py   |  4 ++--
>  scripts/qapi-event.py      |  4 ++--
>  scripts/qapi-introspect.py |  4 ++--
>  scripts/qapi-types.py      |  4 ++--
>  scripts/qapi-visit.py      |  4 ++--
>  scripts/qapi.py            | 25 ++++---------------------
>  6 files changed, 14 insertions(+), 31 deletions(-)
>
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index 974d0a4a80..56a1009564 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -253,7 +253,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
>          self._regy += gen_register_command(name, success_response)
>
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = parse_command_line()
> +(input_file, output_dir, prefix, opts) = parse_command_line()
>
>  c_comment = '''
>  /*
> @@ -284,7 +284,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qmp-marshal.c', 'qmp-commands.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
> index 07b4b70199..0a308e6b69 100644
> --- a/scripts/qapi-event.py
> +++ b/scripts/qapi-event.py
> @@ -169,7 +169,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
>          self._event_names.append(name)
>
>
> -(input_file, output_dir, do_c, do_h, prefix, dummy) = parse_command_line()
> +(input_file, output_dir, prefix, dummy) = parse_command_line()
>
>  c_comment = '''
>  /*
> @@ -200,7 +200,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-event.c', 'qapi-event.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index 032bcea491..c2e46182c8 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -169,7 +169,7 @@ const char %(c_name)s[] = %(c_string)s;
>  # We normally mask them, because they're not QMP wire ABI
>  opt_unmask = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('u', ['unmask-non-abi-names'])
>
>  for o, a in opts:
> @@ -199,7 +199,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qmp-introspect.c', 'qmp-introspect.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 7e3051dbb9..dc7dd08512 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -243,7 +243,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>  # QAPISchemaGenTypeVisitor.visit_end().
>  do_builtins = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('b', ['builtins'])
>
>  for o, a in opts:
> @@ -280,7 +280,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-types.c', 'qapi-types.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 7e1cfc13f0..9757911d2d 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -327,7 +327,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>  # QAPISchemaGenVisitVisitor.visit_end().
>  do_builtins = False
>
> -(input_file, output_dir, do_c, do_h, prefix, opts) = \
> +(input_file, output_dir, prefix, opts) = \
>      parse_command_line('b', ['builtins'])
>
>  for o, a in opts:
> @@ -363,7 +363,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, do_c, do_h, prefix,
> +(fdef, fdecl) = open_output(output_dir, prefix,
>                              'qapi-visit.c', 'qapi-visit.h',
>                              c_comment, h_comment)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 8f9c5666bd..5434987108 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1931,8 +1931,6 @@ def parse_command_line(extra_options='', extra_long_options=[]):
>
>      output_dir = ''
>      prefix = ''
> -    do_c = False
> -    do_h = False
>      extra_opts = []
>
>      for oa in opts:
> @@ -1947,30 +1945,22 @@ def parse_command_line(extra_options='', extra_long_options=[]):
>              prefix = a
>          elif o in ('-o', '--output-dir'):
>              output_dir = a + '/'
> -        elif o in ('-c', '--source'):
> -            do_c = True
> -        elif o in ('-h', '--header'):
> -            do_h = True
>          else:
>              extra_opts.append(oa)
>
> -    if not do_c and not do_h:
> -        do_c = True
> -        do_h = True
> -
>      if len(args) != 1:
>          print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
>          sys.exit(1)
>      fname = args[0]
>
> -    return (fname, output_dir, do_c, do_h, prefix, extra_opts)
> +    return (fname, output_dir, prefix, extra_opts)
>
>  #
>  # Generate output files with boilerplate
>  #
>
>
> -def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
> +def open_output(output_dir, prefix, c_file, h_file,
>                  c_comment, h_comment):
>      guard = guardname(prefix + h_file)
>      c_file = output_dir + prefix + c_file
> @@ -1983,15 +1973,8 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file,
>              if e.errno != errno.EEXIST:
>                  raise
>
> -    def maybe_open(really, name, opt):
> -        if really:
> -            return open(name, opt)
> -        else:
> -            import StringIO
> -            return StringIO.StringIO()
> -
> -    fdef = maybe_open(do_c, c_file, 'w')
> -    fdecl = maybe_open(do_h, h_file, 'w')
> +    fdef = open(c_file, 'w')
> +    fdecl = open(h_file, 'w')
>
>      fdef.write(mcgen('''
>  /* AUTOMATICALLY GENERATED, DO NOT MODIFY */
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments Markus Armbruster
@ 2017-10-04 11:13   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:13 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Less code than with getopt, and we get --help for free.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi-commands.py       | 13 +++++-----
>  scripts/qapi-event.py          | 12 ++++-----
>  scripts/qapi-introspect.py     | 22 +++++++---------
>  scripts/qapi-types.py          | 22 ++++++----------
>  scripts/qapi-visit.py          | 24 +++++++----------
>  scripts/qapi.py                | 58 +++++++++++++++---------------------------
>  scripts/qapi2texi.py           | 11 +++++---
>  tests/qapi-schema/test-qapi.py | 10 +++++---
>  8 files changed, 74 insertions(+), 98 deletions(-)
>
> diff --git a/scripts/qapi-commands.py b/scripts/qapi-commands.py
> index 56a1009564..76cc9cc8a4 100644
> --- a/scripts/qapi-commands.py
> +++ b/scripts/qapi-commands.py
> @@ -214,7 +214,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds)
>      QTAILQ_INIT(cmds);
>
>  ''',
> -                c_prefix=c_name(prefix, protect=False))
> +                c_prefix=c_name(args.prefix, protect=False))
>      ret += registry
>      ret += mcgen('''
>  }
> @@ -253,7 +253,7 @@ class QAPISchemaGenCommandVisitor(QAPISchemaVisitor):
>          self._regy += gen_register_command(name, success_response)
>
>
> -(input_file, output_dir, prefix, opts) = parse_command_line()
> +args = common_argument_parser().parse_args()
>
>  c_comment = '''
>  /*
> @@ -284,7 +284,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, prefix,
> +(fdef, fdecl) = open_output(args.output_dir, args.prefix,
>                              'qmp-marshal.c', 'qmp-commands.h',
>                              c_comment, h_comment)
>
> @@ -302,7 +302,7 @@ fdef.write(mcgen('''
>  #include "%(prefix)sqmp-commands.h"
>
>  ''',
> -                 prefix=prefix))
> +                 prefix=args.prefix))
>
>  fdecl.write(mcgen('''
>  #include "%(prefix)sqapi-types.h"
> @@ -312,9 +312,10 @@ fdecl.write(mcgen('''
>
>  void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
>  ''',
> -                  prefix=prefix, c_prefix=c_name(prefix, protect=False)))
> +                  prefix=args.prefix,
> +                  c_prefix=c_name(args.prefix, protect=False)))
>
> -schema = QAPISchema(input_file)
> +schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenCommandVisitor()
>  schema.visit(gen)
>  fdef.write(gen.defn)
> diff --git a/scripts/qapi-event.py b/scripts/qapi-event.py
> index 0a308e6b69..1c61751bc0 100644
> --- a/scripts/qapi-event.py
> +++ b/scripts/qapi-event.py
> @@ -169,7 +169,7 @@ class QAPISchemaGenEventVisitor(QAPISchemaVisitor):
>          self._event_names.append(name)
>
>
> -(input_file, output_dir, prefix, dummy) = parse_command_line()
> +args = common_argument_parser().parse_args()
>
>  c_comment = '''
>  /*
> @@ -200,7 +200,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, prefix,
> +(fdef, fdecl) = open_output(args.output_dir, args.prefix,
>                              'qapi-event.c', 'qapi-event.h',
>                              c_comment, h_comment)
>
> @@ -213,7 +213,7 @@ fdef.write(mcgen('''
>  #include "qapi/qmp-event.h"
>
>  ''',
> -                 prefix=prefix))
> +                 prefix=args.prefix))
>
>  fdecl.write(mcgen('''
>  #include "qapi/error.h"
> @@ -222,11 +222,11 @@ fdecl.write(mcgen('''
>  #include "%(prefix)sqapi-types.h"
>
>  ''',
> -                  prefix=prefix))
> +                  prefix=args.prefix))
>
> -event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
> +event_enum_name = c_name(args.prefix + 'QAPIEvent', protect=False)
>
> -schema = QAPISchema(input_file)
> +schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenEventVisitor()
>  schema.visit(gen)
>  fdef.write(gen.defn)
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index c2e46182c8..ad87fc57e3 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -64,7 +64,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
>          # generate C
>          # TODO can generate awfully long lines
>          jsons.extend(self._jsons)
> -        name = c_name(prefix, protect=False) + 'qmp_schema_json'
> +        name = c_name(args.prefix, protect=False) + 'qmp_schema_json'
>          self.decl = mcgen('''
>  extern const char %(c_name)s[];
>  ''',
> @@ -165,16 +165,12 @@ const char %(c_name)s[] = %(c_string)s;
>          arg_type = arg_type or self._schema.the_empty_object_type
>          self._gen_json(name, 'event', {'arg-type': self._use_type(arg_type)})
>
> +parser = common_argument_parser()
>  # Debugging aid: unmask QAPI schema's type names
>  # We normally mask them, because they're not QMP wire ABI
> -opt_unmask = False
> -
> -(input_file, output_dir, prefix, opts) = \
> -    parse_command_line('u', ['unmask-non-abi-names'])
> -
> -for o, a in opts:
> -    if o in ('-u', '--unmask-non-abi-names'):
> -        opt_unmask = True
> +parser.add_argument('-u', '--unmask-non-abi-names', action='store_true',
> +                    help='unmask non-ABI names')
> +args = parser.parse_args()
>
>  c_comment = '''
>  /*
> @@ -199,7 +195,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, prefix,
> +(fdef, fdecl) = open_output(args.output_dir, args.prefix,
>                              'qmp-introspect.c', 'qmp-introspect.h',
>                              c_comment, h_comment)
>
> @@ -208,10 +204,10 @@ fdef.write(mcgen('''
>  #include "%(prefix)sqmp-introspect.h"
>
>  ''',
> -                 prefix=prefix))
> +                 prefix=args.prefix))
>
> -schema = QAPISchema(input_file)
> -gen = QAPISchemaGenIntrospectVisitor(opt_unmask)
> +schema = QAPISchema(args.schema)
> +gen = QAPISchemaGenIntrospectVisitor(args.unmask_non_abi_names)
>  schema.visit(gen)
>  fdef.write(gen.defn)
>  fdecl.write(gen.decl)
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index dc7dd08512..ed05d828bf 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -185,7 +185,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          self._fwdecl = None
>          # To avoid header dependency hell, we always generate
>          # declarations for built-in types in our header files and
> -        # simply guard them.  See also do_builtins (command line
> +        # simply guard them.  See also args.builtins (command line
>          # option -b).
>          self._btin += guardend('QAPI_TYPES_BUILTIN')
>          self.decl = self._btin + self.decl
> @@ -200,7 +200,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          # TODO use something cleaner than existence of info
>          if not info:
>              self._btin += gen_enum(name, values, prefix)
> -            if do_builtins:
> +            if args.builtins:
>                  self.defn += gen_enum_lookup(name, values, prefix)
>          else:
>              self._fwdecl += gen_enum(name, values, prefix)
> @@ -211,7 +211,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>              self._btin += gen_fwd_object_or_array(name)
>              self._btin += gen_array(name, element_type)
>              self._btin += gen_type_cleanup_decl(name)
> -            if do_builtins:
> +            if args.builtins:
>                  self.defn += gen_type_cleanup(name)
>          else:
>              self._fwdecl += gen_fwd_object_or_array(name)
> @@ -239,16 +239,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>
>  # If you link code generated from multiple schemata, you want only one
>  # instance of the code for built-in types.  Generate it only when
> -# do_builtins, enabled by command line option -b.  See also
> +# args.builtins, enabled by command line option -b.  See also
>  # QAPISchemaGenTypeVisitor.visit_end().
> -do_builtins = False
>
> -(input_file, output_dir, prefix, opts) = \
> -    parse_command_line('b', ['builtins'])
> -
> -for o, a in opts:
> -    if o in ('-b', '--builtins'):
> -        do_builtins = True
> +args = common_argument_parser(builtins=True).parse_args()
>
>  c_comment = '''
>  /*
> @@ -280,7 +274,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, prefix,
> +(fdef, fdecl) = open_output(args.output_dir, args.prefix,
>                              'qapi-types.c', 'qapi-types.h',
>                              c_comment, h_comment)
>
> @@ -290,13 +284,13 @@ fdef.write(mcgen('''
>  #include "%(prefix)sqapi-types.h"
>  #include "%(prefix)sqapi-visit.h"
>  ''',
> -                 prefix=prefix))
> +                 prefix=args.prefix))
>
>  fdecl.write(mcgen('''
>  #include "qapi/util.h"
>  '''))
>
> -schema = QAPISchema(input_file)
> +schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenTypeVisitor()
>  schema.visit(gen)
>  fdef.write(gen.defn)
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 9757911d2d..010d68434f 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -276,7 +276,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>      def visit_end(self):
>          # To avoid header dependency hell, we always generate
>          # declarations for built-in types in our header files and
> -        # simply guard them.  See also do_builtins (command line
> +        # simply guard them.  See also args.builtins (command line
>          # option -b).
>          self._btin += guardend('QAPI_VISIT_BUILTIN')
>          self.decl = self._btin + self.decl
> @@ -287,7 +287,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>          # TODO use something cleaner than existence of info
>          if not info:
>              self._btin += gen_visit_decl(name, scalar=True)
> -            if do_builtins:
> +            if args.builtins:
>                  self.defn += gen_visit_enum(name)
>          else:
>              self.decl += gen_visit_decl(name, scalar=True)
> @@ -298,7 +298,7 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>          defn = gen_visit_list(name, element_type)
>          if isinstance(element_type, QAPISchemaBuiltinType):
>              self._btin += decl
> -            if do_builtins:
> +            if args.builtins:
>                  self.defn += defn
>          else:
>              self.decl += decl
> @@ -323,16 +323,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>
>  # If you link code generated from multiple schemata, you want only one
>  # instance of the code for built-in types.  Generate it only when
> -# do_builtins, enabled by command line option -b.  See also
> +# args.builtins, enabled by command line option -b.  See also
>  # QAPISchemaGenVisitVisitor.visit_end().
> -do_builtins = False
>
> -(input_file, output_dir, prefix, opts) = \
> -    parse_command_line('b', ['builtins'])
> -
> -for o, a in opts:
> -    if o in ('-b', '--builtins'):
> -        do_builtins = True
> +args = common_argument_parser(builtins=True).parse_args()
>
>  c_comment = '''
>  /*
> @@ -363,7 +357,7 @@ h_comment = '''
>   */
>  '''
>
> -(fdef, fdecl) = open_output(output_dir, prefix,
> +(fdef, fdecl) = open_output(args.output_dir, args.prefix,
>                              'qapi-visit.c', 'qapi-visit.h',
>                              c_comment, h_comment)
>
> @@ -373,7 +367,7 @@ fdef.write(mcgen('''
>  #include "qapi/error.h"
>  #include "%(prefix)sqapi-visit.h"
>  ''',
> -                 prefix=prefix))
> +                 prefix=args.prefix))
>
>  fdecl.write(mcgen('''
>  #include "qapi/visitor.h"
> @@ -381,9 +375,9 @@ fdecl.write(mcgen('''
>  #include "%(prefix)sqapi-types.h"
>
>  ''',
> -                  prefix=prefix))
> +                  prefix=args.prefix))
>
> -schema = QAPISchema(input_file)
> +schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenVisitVisitor()
>  schema.visit(gen)
>  fdef.write(gen.defn)
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 5434987108..25f6c81b08 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -11,8 +11,8 @@
>  # This work is licensed under the terms of the GNU GPL, version 2.
>  # See the COPYING file in the top-level directory.
>
> +import argparse
>  import errno
> -import getopt
>  import os
>  import re
>  import string
> @@ -1917,43 +1917,27 @@ def build_params(arg_type, boxed, extra):
>  # Common command line parsing
>  #
>
> +def common_argument_parser(builtins=False):
>
> -def parse_command_line(extra_options='', extra_long_options=[]):
> +    def prefix(string):
> +        match = re.match(r'([a-z_.-][a-z0-9_.-]*)?', string, re.I)
> +        if match.end() != len(string):
> +            raise argparse.ArgumentTypeError("funny character '%s'"
> +                                             % string[match.end()])
> +        return string
>
> -    try:
> -        opts, args = getopt.gnu_getopt(sys.argv[1:],
> -                                       'chp:o:' + extra_options,
> -                                       ['source', 'header', 'prefix=',
> -                                        'output-dir='] + extra_long_options)
> -    except getopt.GetoptError as err:
> -        print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err))
> -        sys.exit(1)
> +    parser = argparse.ArgumentParser(conflict_handler='resolve')
> +    if builtins:
> +        parser.add_argument('-b', '--builtins', action='store_true',
> +                            help='generate builtins')
> +    parser.add_argument('-o', '--output-dir', default='',
> +                        help='output directory')
> +    parser.add_argument('-p', '--prefix', default='', type=prefix,
> +                        help='prefix to add to output files')
> +    parser.add_argument('schema',
> +                        help='QAPI schema source file')
> +    return parser
>
> -    output_dir = ''
> -    prefix = ''
> -    extra_opts = []
> -
> -    for oa in opts:
> -        o, a = oa
> -        if o in ('-p', '--prefix'):
> -            match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
> -            if match.end() != len(a):
> -                print >>sys.stderr, \
> -                    "%s: 'funny character '%s' in argument of --prefix" \
> -                    % (sys.argv[0], a[match.end()])
> -                sys.exit(1)
> -            prefix = a
> -        elif o in ('-o', '--output-dir'):
> -            output_dir = a + '/'
> -        else:
> -            extra_opts.append(oa)
> -
> -    if len(args) != 1:
> -        print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0]
> -        sys.exit(1)
> -    fname = args[0]
> -
> -    return (fname, output_dir, prefix, extra_opts)
>
>  #
>  # Generate output files with boilerplate
> @@ -1963,8 +1947,8 @@ def parse_command_line(extra_options='', extra_long_options=[]):
>  def open_output(output_dir, prefix, c_file, h_file,
>                  c_comment, h_comment):
>      guard = guardname(prefix + h_file)
> -    c_file = output_dir + prefix + c_file
> -    h_file = output_dir + prefix + h_file
> +    c_file = os.path.join(output_dir, prefix + c_file)
> +    h_file = os.path.join(output_dir, prefix + h_file)
>
>      if output_dir:
>          try:
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index bfd1c676e1..fd90d8953e 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -4,6 +4,8 @@
>  # This work is licensed under the terms of the GNU LGPL, version 2+.
>  # See the COPYING file in the top-level directory.
>  """This script produces the documentation of a qapi schema in texinfo format"""
> +
> +import argparse
>  import re
>  import sys
>
> @@ -279,11 +281,12 @@ def texi_schema(schema):
>
>  def main(argv):
>      """Takes schema argument, prints result to stdout"""
> -    if len(argv) != 2:
> -        print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0]
> -        sys.exit(1)
> +    parser = argparse.ArgumentParser()
> +    parser.add_argument('schema',
> +                        help='QAPI schema source file')
> +    args = parser.parse_args()
>
> -    schema = qapi.QAPISchema(argv[1])
> +    schema = qapi.QAPISchema(args.schema)
>      if not qapi.doc_required:
>          print >>sys.stderr, ("%s: need pragma 'doc-required' "
>                               "to generate documentation" % argv[0])
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index fe0ca08d78..a7e21d016f 100644
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -12,8 +12,7 @@
>
>  from qapi import *
>  from pprint import pprint
> -import os
> -import sys
> +import argparse
>
>
>  class QAPISchemaTestVisitor(QAPISchemaVisitor):
> @@ -53,7 +52,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
>              for v in variants.variants:
>                  print '    case %s: %s' % (v.name, v.type.name)
>
> -schema = QAPISchema(sys.argv[1])
> +parser = argparse.ArgumentParser()
> +parser.add_argument('schema',
> +                    help='QAPI schema source file')
> +args = parser.parse_args()
> +
> +schema = QAPISchema(args.schema)
>  schema.visit(QAPISchemaTestVisitor())
>
>  for doc in schema.docs:
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file Markus Armbruster
@ 2017-10-04 11:18   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:18 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> QAPISchema.__init__() opens the schema file.  Since it doesn't bother
> to catch exceptions, an invalid schema argument is reported like this:
>
>     Traceback (most recent call last):
>       File "../scripts/qapi-commands.py", line 318, in <module>
>         schema = QAPISchema(args.schema)
>       File "/work/armbru/qemu/scripts/qapi.py", line 1464, in __init__
>         parser = QAPISchemaParser(open(fname, 'r'))
>     IOError: [Errno 2] No such file or directory: 'nonexistent'
>
> Leave it to argparse, which handles the exception like this:
>
>     usage: qapi-commands.py [-h] [-o OUTPUT_DIR] [-p PREFIX] schema
>     qapi-commands.py: error: argument schema: can't open 'nonexistent': [Errno 2] No such file or directory: 'nonexistent'
>
> Too verbose for my taste, but let's not second-guess the standard
> library.

indeed :)

>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py                | 6 +++---
>  scripts/qapi2texi.py           | 2 +-
>  tests/qapi-schema/test-qapi.py | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 25f6c81b08..a33203e82d 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1450,9 +1450,9 @@ class QAPISchemaEvent(QAPISchemaEntity):
>
>
>  class QAPISchema(object):
> -    def __init__(self, fname):
> +    def __init__(self, file):
>          try:
> -            parser = QAPISchemaParser(open(fname, 'r'))
> +            parser = QAPISchemaParser(file)
>              self.exprs = check_exprs(parser.exprs)
>              self.docs = parser.docs
>              self._entity_dict = {}
> @@ -1934,7 +1934,7 @@ def common_argument_parser(builtins=False):
>                          help='output directory')
>      parser.add_argument('-p', '--prefix', default='', type=prefix,
>                          help='prefix to add to output files')
> -    parser.add_argument('schema',
> +    parser.add_argument('schema', type=argparse.FileType('r'),
>                          help='QAPI schema source file')
>      return parser
>
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index fd90d8953e..d95d7541a3 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -282,7 +282,7 @@ def texi_schema(schema):
>  def main(argv):
>      """Takes schema argument, prints result to stdout"""
>      parser = argparse.ArgumentParser()
> -    parser.add_argument('schema',
> +    parser.add_argument('schema', type=argparse.FileType('r'),
>                          help='QAPI schema source file')
>      args = parser.parse_args()
>
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index a7e21d016f..225417d861 100644
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -53,7 +53,7 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
>                  print '    case %s: %s' % (v.name, v.type.name)
>
>  parser = argparse.ArgumentParser()
> -parser.add_argument('schema',
> +parser.add_argument('schema', type=argparse.FileType('r'),
>                      help='QAPI schema source file')
>  args = parser.parse_args()
>
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types Markus Armbruster
@ 2017-10-04 11:52   ` Marc-André Lureau
  2017-10-05  4:24     ` Markus Armbruster
  0 siblings, 1 reply; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:52 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

Hi

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> qapi-types.py and qapi-visit.py generate some C code for built-in
> types.  To make this work with multiple schemas, we generate code for
> built-ins into .c files only when the user asks for it with -b.  The
> user is responsible for linking exactly one set of files generated
> with -b per program.  We generate code for built-ins into .h
> regardless of -b, but guard it with a preprocessor symbol.
>
> This is cumbersome and inflexible.  Move the code generated for
> built-in types into separate files builtin-qapi-{types,visit}.{c,h}.
> Run qapi-types.py and qapi-visit.py without a schema argument to
> generate them.  Drop their option -b.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>


Good idea!
I think I would still prefer to see a seperate argument to generate
builtin files (rather than absence of schema), but this is minor
detail.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  .gitignore                               |  2 ++
>  Makefile                                 | 18 ++++++++--
>  Makefile.objs                            |  1 +
>  docs/devel/qapi-code-gen.txt             | 24 +++++++++++--
>  qga/Makefile.objs                        |  1 +
>  scripts/qapi-introspect.py               |  4 +--
>  scripts/qapi-types.py                    | 54 ++++++++++------------------
>  scripts/qapi-visit.py                    | 62 ++++++++++++--------------------
>  scripts/qapi.py                          | 57 ++++++++++++++++-------------
>  scripts/qapi2texi.py                     |  2 +-
>  tests/Makefile.include                   |  4 ++-
>  tests/qapi-schema/builtins.err           |  0
>  tests/qapi-schema/builtins.exit          |  1 +
>  tests/qapi-schema/builtins.json          |  1 +
>  tests/qapi-schema/builtins.out           |  3 ++
>  tests/qapi-schema/comments.out           |  3 --
>  tests/qapi-schema/doc-bad-section.out    |  3 --
>  tests/qapi-schema/doc-good.out           |  3 --
>  tests/qapi-schema/empty.out              |  3 --
>  tests/qapi-schema/event-case.out         |  3 --
>  tests/qapi-schema/ident-with-escape.out  |  3 --
>  tests/qapi-schema/include-relpath.out    |  3 --
>  tests/qapi-schema/include-repetition.out |  3 --
>  tests/qapi-schema/include-simple.out     |  3 --
>  tests/qapi-schema/indented-expr.out      |  3 --
>  tests/qapi-schema/qapi-schema-test.out   |  3 --
>  tests/qapi-schema/test-qapi.py           |  4 +--
>  27 files changed, 127 insertions(+), 144 deletions(-)
>  create mode 100644 tests/qapi-schema/builtins.err
>  create mode 100644 tests/qapi-schema/builtins.exit
>  create mode 100644 tests/qapi-schema/builtins.json
>  create mode 100644 tests/qapi-schema/builtins.out
>
> diff --git a/.gitignore b/.gitignore
> index 40acfcb9e2..84a57060ad 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -1,3 +1,5 @@
> +/builtin-qapi-types.[ch]
> +/builtin-qapi-visit.[ch]
>  /config-devices.*
>  /config-all-devices.*
>  /config-all-disas.*
> diff --git a/Makefile b/Makefile
> index 784b601247..421e65d833 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -52,6 +52,8 @@ endif
>  include $(SRC_PATH)/rules.mak
>
>  GENERATED_FILES = qemu-version.h config-host.h qemu-options.def
> +GENERATED_FILES += builtin-qapi-types.h builtin-qapi-types.c
> +GENERATED_FILES += builtin-qapi-visit.h builtin-qapi-visit.c
>  GENERATED_FILES += qmp-commands.h qapi-types.h qapi-visit.h qapi-event.h
>  GENERATED_FILES += qmp-marshal.c qapi-types.c qapi-visit.c qapi-event.c
>  GENERATED_FILES += qmp-introspect.h
> @@ -428,18 +430,30 @@ qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \
>                 $(SRC_PATH)/qapi/transaction.json \
>                 $(SRC_PATH)/qapi/ui.json
>
> +.INTERMEDIATE: builtin-qapi-types-gen
> +builtin-qapi-types.c builtin-qapi-types.h: builtin-qapi-types-gen ;
> +builtin-qapi-types-gen: $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
> +       $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py, \
> +               "GEN","$@")
> +
> +.INTERMEDIATE: builtin-qapi-visit-gen
> +builtin-qapi-visit.c builtin-qapi-visit.h: builtin-qapi-visit-gen ;
> +builtin-qapi-visit-gen: $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
> +       $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py, \
> +               "GEN","$@")
> +
>  .INTERMEDIATE: qapi-types-gen
>  qapi-types.c qapi-types.h: qapi-types-gen ;
>  qapi-types-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-types.py \
> -               -b $<, \
> +               $<, \
>                 "GEN","$@")
>
>  .INTERMEDIATE: qapi-visit-gen
>  qapi-visit.c qapi-visit.h: qapi-visit-gen ;
>  qapi-visit-gen: $(qapi-modules) $(SRC_PATH)/scripts/qapi-visit.py $(qapi-py)
>         $(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi-visit.py \
> -               -b $<, \
> +               $<, \
>                 "GEN","$@")
>
>  .INTERMEDIATE: qapi-event-gen
> diff --git a/Makefile.objs b/Makefile.objs
> index cc4f94d77a..c2c62cb462 100644
> --- a/Makefile.objs
> +++ b/Makefile.objs
> @@ -2,6 +2,7 @@
>  # Common libraries for tools and emulators
>  stub-obj-y = stubs/ crypto/
>  util-obj-y = util/ qobject/ qapi/
> +util-obj-y += builtin-qapi-types.o builtin-qapi-visit.o
>  util-obj-y += qapi-types.o qapi-visit.o qapi-event.o
>
>  chardev-obj-y = chardev/
> diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
> index 579807f6a5..f5b7659caf 100644
> --- a/docs/devel/qapi-code-gen.txt
> +++ b/docs/devel/qapi-code-gen.txt
> @@ -937,7 +937,7 @@ supporting code. The following files are created:
>
>  $(prefix)qapi-types.h - C types corresponding to types defined in
>                          the schema you pass in
> -$(prefix)qapi-types.c - Cleanup functions for the above C types
> +$(prefix)qapi-types.c - Support code for the above C types
>
>  The $(prefix) is an optional parameter used as a namespace to keep the
>  generated code from one schema/code-generation separated from others so code
> @@ -954,7 +954,7 @@ Example:
>      #ifndef EXAMPLE_QAPI_TYPES_H
>      #define EXAMPLE_QAPI_TYPES_H
>
> -[Built-in types omitted...]
> +    #include "builtin-qapi-types.h"
>
>      typedef struct UserDefOne UserDefOne;
>
> @@ -1011,6 +1011,14 @@ Example:
>          visit_free(v);
>      }
>
> +Type definitions for the built-in types are generated separately, into
> +builtin-qapi-types.h and builtin-qapi-types.c.  These are independent
> +of the schema.
> +
> +Example:
> +
> +    $ python scripts/qapi-types.py --output-dir="qapi-generated"
> +
>  === scripts/qapi-visit.py ===
>
>  Used to generate the visitor functions used to walk through and
> @@ -1039,7 +1047,9 @@ Example:
>      #ifndef EXAMPLE_QAPI_VISIT_H
>      #define EXAMPLE_QAPI_VISIT_H
>
> -[Visitors for built-in types omitted...]
> +    #include "builtin-qapi-visit.h"
> +    #include "example-qapi-types.h"
> +
>
>      void visit_type_UserDefOne_members(Visitor *v, UserDefOne *obj, Error **errp);
>      void visit_type_UserDefOne(Visitor *v, const char *name, UserDefOne **obj, Error **errp);
> @@ -1140,6 +1150,14 @@ Example:
>          error_propagate(errp, err);
>      }
>
> +Visitor functions for the built-in types are generated separately,
> +into builtin-qapi-visit.h and builtin-qapi-visit.c.  These are
> +independent of the schema.
> +
> +Example:
> +
> +    $ python scripts/qapi-visit.py --output-dir="qapi-generated"
> +
>  === scripts/qapi-commands.py ===
>
>  Used to generate the marshaling/dispatch functions for the commands
> diff --git a/qga/Makefile.objs b/qga/Makefile.objs
> index 1c5986c0bb..1430655fbe 100644
> --- a/qga/Makefile.objs
> +++ b/qga/Makefile.objs
> @@ -2,6 +2,7 @@ qga-obj-y = commands.o guest-agent-command-state.o main.o
>  qga-obj-$(CONFIG_POSIX) += commands-posix.o channel-posix.o
>  qga-obj-$(CONFIG_WIN32) += commands-win32.o channel-win32.o service-win32.o
>  qga-obj-$(CONFIG_WIN32) += vss-win32.o
> +qga-obj-y += ../builtin-qapi-types.o ../builtin-qapi-visit.o
>  qga-obj-y += qapi-generated/qga-qapi-types.o qapi-generated/qga-qapi-visit.o
>  qga-obj-y += qapi-generated/qga-qmp-marshal.o
>
> diff --git a/scripts/qapi-introspect.py b/scripts/qapi-introspect.py
> index ad87fc57e3..cc4ff01cd4 100644
> --- a/scripts/qapi-introspect.py
> +++ b/scripts/qapi-introspect.py
> @@ -60,7 +60,7 @@ class QAPISchemaGenIntrospectVisitor(QAPISchemaVisitor):
>          jsons = self._jsons
>          self._jsons = []
>          for typ in self._used_types:
> -            typ.visit(self)
> +            typ.visit(self, builtins=True)
>          # generate C
>          # TODO can generate awfully long lines
>          jsons.extend(self._jsons)
> @@ -208,7 +208,7 @@ fdef.write(mcgen('''
>
>  schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenIntrospectVisitor(args.unmask_non_abi_names)
> -schema.visit(gen)
> +schema.visit(gen, builtins=True)
>  fdef.write(gen.defn)
>  fdecl.write(gen.decl)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index ed05d828bf..18fd2a98c0 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -170,7 +170,6 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          self.decl = None
>          self.defn = None
>          self._fwdecl = None
> -        self._btin = None
>
>      def visit_begin(self, schema):
>          # gen_object() is recursive, ensure it doesn't visit the empty type
> @@ -178,45 +177,23 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          self.decl = ''
>          self.defn = ''
>          self._fwdecl = ''
> -        self._btin = guardstart('QAPI_TYPES_BUILTIN')
>
>      def visit_end(self):
>          self.decl = self._fwdecl + self.decl
>          self._fwdecl = None
> -        # To avoid header dependency hell, we always generate
> -        # declarations for built-in types in our header files and
> -        # simply guard them.  See also args.builtins (command line
> -        # option -b).
> -        self._btin += guardend('QAPI_TYPES_BUILTIN')
> -        self.decl = self._btin + self.decl
> -        self._btin = None
>
>      def _gen_type_cleanup(self, name):
>          self.decl += gen_type_cleanup_decl(name)
>          self.defn += gen_type_cleanup(name)
>
>      def visit_enum_type(self, name, info, values, prefix):
> -        # Special case for our lone builtin enum type
> -        # TODO use something cleaner than existence of info
> -        if not info:
> -            self._btin += gen_enum(name, values, prefix)
> -            if args.builtins:
> -                self.defn += gen_enum_lookup(name, values, prefix)
> -        else:
> -            self._fwdecl += gen_enum(name, values, prefix)
> -            self.defn += gen_enum_lookup(name, values, prefix)
> +        self._fwdecl += gen_enum(name, values, prefix)
> +        self.defn += gen_enum_lookup(name, values, prefix)
>
>      def visit_array_type(self, name, info, element_type):
> -        if isinstance(element_type, QAPISchemaBuiltinType):
> -            self._btin += gen_fwd_object_or_array(name)
> -            self._btin += gen_array(name, element_type)
> -            self._btin += gen_type_cleanup_decl(name)
> -            if args.builtins:
> -                self.defn += gen_type_cleanup(name)
> -        else:
> -            self._fwdecl += gen_fwd_object_or_array(name)
> -            self.decl += gen_array(name, element_type)
> -            self._gen_type_cleanup(name)
> +        self._fwdecl += gen_fwd_object_or_array(name)
> +        self.decl += gen_array(name, element_type)
> +        self._gen_type_cleanup(name)
>
>      def visit_object_type(self, name, info, base, members, variants):
>          # Nothing to do for the special empty builtin
> @@ -237,12 +214,12 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          self.decl += gen_object(name, None, [variants.tag_member], variants)
>          self._gen_type_cleanup(name)
>
> -# If you link code generated from multiple schemata, you want only one
> -# instance of the code for built-in types.  Generate it only when
> -# args.builtins, enabled by command line option -b.  See also
> -# QAPISchemaGenTypeVisitor.visit_end().
> -
> -args = common_argument_parser(builtins=True).parse_args()
> +argparser = common_argument_parser(builtins=True)
> +args = argparser.parse_args()
> +if not args.schema:
> +    if args.prefix:
> +        argparser.error('schema required with -p')
> +    args.prefix = 'builtin-'
>
>  c_comment = '''
>  /*
> @@ -286,13 +263,18 @@ fdef.write(mcgen('''
>  ''',
>                   prefix=args.prefix))
>
> -fdecl.write(mcgen('''
> +if args.schema:
> +    fdecl.write(mcgen('''
> +#include "builtin-qapi-types.h"
> +'''))
> +else:
> +    fdecl.write(mcgen('''
>  #include "qapi/util.h"
>  '''))
>
>  schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenTypeVisitor()
> -schema.visit(gen)
> +schema.visit(gen, builtins=not args.schema)
>  fdef.write(gen.defn)
>  fdecl.write(gen.decl)
>
> diff --git a/scripts/qapi-visit.py b/scripts/qapi-visit.py
> index 010d68434f..e756ef98ee 100644
> --- a/scripts/qapi-visit.py
> +++ b/scripts/qapi-visit.py
> @@ -266,43 +266,18 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>      def __init__(self):
>          self.decl = None
>          self.defn = None
> -        self._btin = None
>
>      def visit_begin(self, schema):
>          self.decl = ''
>          self.defn = ''
> -        self._btin = guardstart('QAPI_VISIT_BUILTIN')
> -
> -    def visit_end(self):
> -        # To avoid header dependency hell, we always generate
> -        # declarations for built-in types in our header files and
> -        # simply guard them.  See also args.builtins (command line
> -        # option -b).
> -        self._btin += guardend('QAPI_VISIT_BUILTIN')
> -        self.decl = self._btin + self.decl
> -        self._btin = None
>
>      def visit_enum_type(self, name, info, values, prefix):
> -        # Special case for our lone builtin enum type
> -        # TODO use something cleaner than existence of info
> -        if not info:
> -            self._btin += gen_visit_decl(name, scalar=True)
> -            if args.builtins:
> -                self.defn += gen_visit_enum(name)
> -        else:
> -            self.decl += gen_visit_decl(name, scalar=True)
> -            self.defn += gen_visit_enum(name)
> +        self.decl += gen_visit_decl(name, scalar=True)
> +        self.defn += gen_visit_enum(name)
>
>      def visit_array_type(self, name, info, element_type):
> -        decl = gen_visit_decl(name)
> -        defn = gen_visit_list(name, element_type)
> -        if isinstance(element_type, QAPISchemaBuiltinType):
> -            self._btin += decl
> -            if args.builtins:
> -                self.defn += defn
> -        else:
> -            self.decl += decl
> -            self.defn += defn
> +        self.decl += gen_visit_decl(name)
> +        self.defn += gen_visit_list(name, element_type)
>
>      def visit_object_type(self, name, info, base, members, variants):
>          # Nothing to do for the special empty builtin
> @@ -321,12 +296,12 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
>          self.decl += gen_visit_decl(name)
>          self.defn += gen_visit_alternate(name, variants)
>
> -# If you link code generated from multiple schemata, you want only one
> -# instance of the code for built-in types.  Generate it only when
> -# args.builtins, enabled by command line option -b.  See also
> -# QAPISchemaGenVisitVisitor.visit_end().
> -
> -args = common_argument_parser(builtins=True).parse_args()
> +argparser = common_argument_parser(builtins=True)
> +args = argparser.parse_args()
> +if not args.schema:
> +    if args.prefix:
> +        argparser.error('schema required with -p')
> +    args.prefix = 'builtin-'
>
>  c_comment = '''
>  /*
> @@ -369,17 +344,24 @@ fdef.write(mcgen('''
>  ''',
>                   prefix=args.prefix))
>
> -fdecl.write(mcgen('''
> +if args.schema:
> +    fdecl.write(mcgen('''
> +#include "builtin-qapi-visit.h"
> +#include "%(prefix)sqapi-types.h"
> +
> +''',
> +                      prefix=args.prefix))
> +else:
> +    fdecl.write(mcgen('''
>  #include "qapi/visitor.h"
>  #include "qapi/qmp/qerror.h"
> -#include "%(prefix)sqapi-types.h"
> +#include "builtin-qapi-types.h"
>
> -''',
> -                  prefix=args.prefix))
> +'''))
>
>  schema = QAPISchema(args.schema)
>  gen = QAPISchemaGenVisitVisitor()
> -schema.visit(gen)
> +schema.visit(gen, builtins=not args.schema)
>  fdef.write(gen.defn)
>  fdecl.write(gen.decl)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index a33203e82d..248d650858 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -983,7 +983,7 @@ class QAPISchemaEntity(object):
>      def is_implicit(self):
>          return not self.info
>
> -    def visit(self, visitor):
> +    def visit(self, visitor, builtins):
>          pass
>
>
> @@ -1084,8 +1084,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
>      def doc_type(self):
>          return self.json_type()
>
> -    def visit(self, visitor):
> -        visitor.visit_builtin_type(self.name, self.info, self.json_type())
> +    def visit(self, visitor, builtins):
> +        if builtins:
> +            visitor.visit_builtin_type(self.name, self.info, self.json_type())
>
>
>  class QAPISchemaEnumType(QAPISchemaType):
> @@ -1118,9 +1119,11 @@ class QAPISchemaEnumType(QAPISchemaType):
>      def json_type(self):
>          return 'string'
>
> -    def visit(self, visitor):
> -        visitor.visit_enum_type(self.name, self.info,
> -                                self.member_names(), self.prefix)
> +    def visit(self, visitor, builtins):
> +        # TODO use something cleaner than existence of info
> +        if builtins or self.info:
> +            visitor.visit_enum_type(self.name, self.info,
> +                                    self.member_names(), self.prefix)
>
>
>  class QAPISchemaArrayType(QAPISchemaType):
> @@ -1149,8 +1152,10 @@ class QAPISchemaArrayType(QAPISchemaType):
>              return None
>          return 'array of ' + elt_doc_type
>
> -    def visit(self, visitor):
> -        visitor.visit_array_type(self.name, self.info, self.element_type)
> +    def visit(self, visitor, builtins):
> +        if builtins or not isinstance(self.element_type,
> +                                      QAPISchemaBuiltinType):
> +            visitor.visit_array_type(self.name, self.info, self.element_type)
>
>
>  class QAPISchemaObjectType(QAPISchemaType):
> @@ -1229,11 +1234,13 @@ class QAPISchemaObjectType(QAPISchemaType):
>      def json_type(self):
>          return 'object'
>
> -    def visit(self, visitor):
> -        visitor.visit_object_type(self.name, self.info,
> -                                  self.base, self.local_members, self.variants)
> -        visitor.visit_object_type_flat(self.name, self.info,
> -                                       self.members, self.variants)
> +    def visit(self, visitor, builtins):
> +        # TODO use something cleaner than existence of info
> +        if builtins or self.info:
> +            visitor.visit_object_type(self.name, self.info, self.base,
> +                                      self.local_members, self.variants)
> +            visitor.visit_object_type_flat(self.name, self.info,
> +                                           self.members, self.variants)
>
>
>  class QAPISchemaMember(object):
> @@ -1375,7 +1382,7 @@ class QAPISchemaAlternateType(QAPISchemaType):
>      def json_type(self):
>          return 'value'
>
> -    def visit(self, visitor):
> +    def visit(self, visitor, builtins):
>          visitor.visit_alternate_type(self.name, self.info, self.variants)
>
>      def is_empty(self):
> @@ -1415,7 +1422,7 @@ class QAPISchemaCommand(QAPISchemaEntity):
>              self.ret_type = schema.lookup_type(self._ret_type_name)
>              assert isinstance(self.ret_type, QAPISchemaType)
>
> -    def visit(self, visitor):
> +    def visit(self, visitor, builtins):
>          visitor.visit_command(self.name, self.info,
>                                self.arg_type, self.ret_type,
>                                self.gen, self.success_response, self.boxed)
> @@ -1445,16 +1452,20 @@ class QAPISchemaEvent(QAPISchemaEntity):
>          elif self.boxed:
>              raise QAPISemError(self.info, "Use of 'boxed' requires 'data'")
>
> -    def visit(self, visitor):
> +    def visit(self, visitor, builtins):
>          visitor.visit_event(self.name, self.info, self.arg_type, self.boxed)
>
>
>  class QAPISchema(object):
>      def __init__(self, file):
>          try:
> -            parser = QAPISchemaParser(file)
> -            self.exprs = check_exprs(parser.exprs)
> -            self.docs = parser.docs
> +            if file:
> +                parser = QAPISchemaParser(file)
> +                self.exprs = check_exprs(parser.exprs)
> +                self.docs = parser.docs
> +            else:
> +                self.exprs = []
> +                self.docs = []
>              self._entity_dict = {}
>              self._predefining = True
>              self._def_predefineds()
> @@ -1668,11 +1679,11 @@ class QAPISchema(object):
>          for ent in self._entity_dict.values():
>              ent.check(self)
>
> -    def visit(self, visitor):
> +    def visit(self, visitor, builtins=False):
>          visitor.visit_begin(self)
>          for (name, entity) in sorted(self._entity_dict.items()):
>              if visitor.visit_needed(entity):
> -                entity.visit(visitor)
> +                entity.visit(visitor, builtins)
>          visitor.visit_end()
>
>
> @@ -1927,14 +1938,12 @@ def common_argument_parser(builtins=False):
>          return string
>
>      parser = argparse.ArgumentParser(conflict_handler='resolve')
> -    if builtins:
> -        parser.add_argument('-b', '--builtins', action='store_true',
> -                            help='generate builtins')
>      parser.add_argument('-o', '--output-dir', default='',
>                          help='output directory')
>      parser.add_argument('-p', '--prefix', default='', type=prefix,
>                          help='prefix to add to output files')
>      parser.add_argument('schema', type=argparse.FileType('r'),
> +                        nargs='?' if builtins else None,
>                          help='QAPI schema source file')
>      return parser
>
> diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py
> index d95d7541a3..071abc9d5d 100755
> --- a/scripts/qapi2texi.py
> +++ b/scripts/qapi2texi.py
> @@ -257,7 +257,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
>          if self.out:
>              self.out += '\n'
>          self.cur_doc = doc
> -        entity.visit(self)
> +        entity.visit(self, builtins=False)
>          self.cur_doc = None
>
>      def freeform(self, doc):
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 5d53c58506..2ef5dc51f1 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -371,6 +371,7 @@ check-qtest-s390x-y += tests/drive_del-test$(EXESUF)
>  check-qtest-generic-y += tests/qom-test$(EXESUF)
>  check-qtest-generic-y += tests/test-hmp$(EXESUF)
>
> +qapi-schema += builtins.json
>  qapi-schema += alternate-any.json
>  qapi-schema += alternate-array.json
>  qapi-schema += alternate-base.json
> @@ -910,7 +911,8 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF)
>  $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
>         $(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \
>                 $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
> -               $^ >$*.test.out 2>$*.test.err; \
> +               `echo "$^" | sed '/builtins/d'` \
> +               >$*.test.out 2>$*.test.err; \
>                 echo $$? >$*.test.exit, \
>                 "TEST","$*.out")
>         @diff -q $(SRC_PATH)/$*.out $*.test.out
> diff --git a/tests/qapi-schema/builtins.err b/tests/qapi-schema/builtins.err
> new file mode 100644
> index 0000000000..e69de29bb2
> diff --git a/tests/qapi-schema/builtins.exit b/tests/qapi-schema/builtins.exit
> new file mode 100644
> index 0000000000..573541ac97
> --- /dev/null
> +++ b/tests/qapi-schema/builtins.exit
> @@ -0,0 +1 @@
> +0
> diff --git a/tests/qapi-schema/builtins.json b/tests/qapi-schema/builtins.json
> new file mode 100644
> index 0000000000..c4088f6792
> --- /dev/null
> +++ b/tests/qapi-schema/builtins.json
> @@ -0,0 +1 @@
> +# This file exists to simplify make's job, it's not actually read
> diff --git a/tests/qapi-schema/builtins.out b/tests/qapi-schema/builtins.out
> new file mode 100644
> index 0000000000..40b886ddae
> --- /dev/null
> +++ b/tests/qapi-schema/builtins.out
> @@ -0,0 +1,3 @@
> +enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> +    prefix QTYPE
> +object q_empty
> diff --git a/tests/qapi-schema/comments.out b/tests/qapi-schema/comments.out
> index 17e652535c..6161b90e91 100644
> --- a/tests/qapi-schema/comments.out
> +++ b/tests/qapi-schema/comments.out
> @@ -1,4 +1 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  enum Status ['good', 'bad', 'ugly']
> -object q_empty
> diff --git a/tests/qapi-schema/doc-bad-section.out b/tests/qapi-schema/doc-bad-section.out
> index 089bde1381..a2f0842130 100644
> --- a/tests/qapi-schema/doc-bad-section.out
> +++ b/tests/qapi-schema/doc-bad-section.out
> @@ -1,7 +1,4 @@
>  enum Enum ['one', 'two']
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
> -object q_empty
>  doc symbol=Enum
>      body=
>  == Produces *invalid* texinfo
> diff --git a/tests/qapi-schema/doc-good.out b/tests/qapi-schema/doc-good.out
> index f0ba51db4b..f609c5d5f5 100644
> --- a/tests/qapi-schema/doc-good.out
> +++ b/tests/qapi-schema/doc-good.out
> @@ -6,8 +6,6 @@ object Object
>      tag base1
>      case one: Variant1
>      case two: Variant2
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  object SugaredUnion
>      member type: SugaredUnionKind optional=False
>      tag type
> @@ -21,7 +19,6 @@ command cmd q_obj_cmd-arg -> Object
>     gen=True success_response=True boxed=False
>  command cmd-boxed Object -> None
>     gen=True success_response=True boxed=True
> -object q_empty
>  object q_obj_Variant1-wrapper
>      member data: Variant1 optional=False
>  object q_obj_Variant2-wrapper
> diff --git a/tests/qapi-schema/empty.out b/tests/qapi-schema/empty.out
> index 40b886ddae..e69de29bb2 100644
> --- a/tests/qapi-schema/empty.out
> +++ b/tests/qapi-schema/empty.out
> @@ -1,3 +0,0 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
> -object q_empty
> diff --git a/tests/qapi-schema/event-case.out b/tests/qapi-schema/event-case.out
> index 313c0fe7be..0c3a3b5ba2 100644
> --- a/tests/qapi-schema/event-case.out
> +++ b/tests/qapi-schema/event-case.out
> @@ -1,5 +1,2 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  event oops None
>     boxed=False
> -object q_empty
> diff --git a/tests/qapi-schema/ident-with-escape.out b/tests/qapi-schema/ident-with-escape.out
> index b5637cb2e0..89fe61f9e9 100644
> --- a/tests/qapi-schema/ident-with-escape.out
> +++ b/tests/qapi-schema/ident-with-escape.out
> @@ -1,7 +1,4 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  command fooA q_obj_fooA-arg -> None
>     gen=True success_response=True boxed=False
> -object q_empty
>  object q_obj_fooA-arg
>      member bar1: str optional=False
> diff --git a/tests/qapi-schema/include-relpath.out b/tests/qapi-schema/include-relpath.out
> index 17e652535c..6161b90e91 100644
> --- a/tests/qapi-schema/include-relpath.out
> +++ b/tests/qapi-schema/include-relpath.out
> @@ -1,4 +1 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  enum Status ['good', 'bad', 'ugly']
> -object q_empty
> diff --git a/tests/qapi-schema/include-repetition.out b/tests/qapi-schema/include-repetition.out
> index 17e652535c..6161b90e91 100644
> --- a/tests/qapi-schema/include-repetition.out
> +++ b/tests/qapi-schema/include-repetition.out
> @@ -1,4 +1 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  enum Status ['good', 'bad', 'ugly']
> -object q_empty
> diff --git a/tests/qapi-schema/include-simple.out b/tests/qapi-schema/include-simple.out
> index 17e652535c..6161b90e91 100644
> --- a/tests/qapi-schema/include-simple.out
> +++ b/tests/qapi-schema/include-simple.out
> @@ -1,4 +1 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  enum Status ['good', 'bad', 'ugly']
> -object q_empty
> diff --git a/tests/qapi-schema/indented-expr.out b/tests/qapi-schema/indented-expr.out
> index 586795f44d..bfdc976854 100644
> --- a/tests/qapi-schema/indented-expr.out
> +++ b/tests/qapi-schema/indented-expr.out
> @@ -1,7 +1,4 @@
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  command eins None -> None
>     gen=True success_response=True boxed=False
> -object q_empty
>  command zwei None -> None
>     gen=True success_response=True boxed=False
> diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
> index 3b1e9082d3..4b42db23b2 100644
> --- a/tests/qapi-schema/qapi-schema-test.out
> +++ b/tests/qapi-schema/qapi-schema-test.out
> @@ -50,8 +50,6 @@ object NestedEnumsOne
>      member enum4: EnumOne optional=True
>  enum QEnumTwo ['value1', 'value2']
>      prefix QENUM_TWO
> -enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
> -    prefix QTYPE
>  object TestStruct
>      member integer: int optional=False
>      member boolean: bool optional=False
> @@ -162,7 +160,6 @@ command guest-get-time q_obj_guest-get-time-arg -> int
>     gen=True success_response=True boxed=False
>  command guest-sync q_obj_guest-sync-arg -> any
>     gen=True success_response=True boxed=False
> -object q_empty
>  object q_obj_EVENT_C-arg
>      member a: int optional=True
>      member b: UserDefOne optional=True
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index 225417d861..0294a66619 100644
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -53,12 +53,12 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
>                  print '    case %s: %s' % (v.name, v.type.name)
>
>  parser = argparse.ArgumentParser()
> -parser.add_argument('schema', type=argparse.FileType('r'),
> +parser.add_argument('schema', type=argparse.FileType('r'), nargs='?',
>                      help='QAPI schema source file')
>  args = parser.parse_args()
>
>  schema = QAPISchema(args.schema)
> -schema.visit(QAPISchemaTestVisitor())
> +schema.visit(QAPISchemaTestVisitor(), builtins=not args.schema)
>
>  for doc in schema.docs:
>      if doc.symbol:
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings Markus Armbruster
@ 2017-10-04 11:58   ` Marc-André Lureau
  2017-10-05  4:41     ` Markus Armbruster
  0 siblings, 1 reply; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:58 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> The QAPI schema parser has always accepted only single-quoted strings,
> even though JSON strings are double-quoted.  Accept double-quoted
> strings as well, so you can write strings containing single quotes
> without backslash escapes.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

What's the motivation to allow both? If we were to switch from single
to double quote only, that would make more sense.
otherwise, patch looks good

> ---
>  docs/devel/qapi-code-gen.txt            | 2 +-
>  scripts/qapi.py                         | 8 +++++---
>  tests/qapi-schema/qapi-schema-test.json | 2 +-
>  3 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
> index 3186c36460..835c641ea8 100644
> --- a/docs/devel/qapi-code-gen.txt
> +++ b/docs/devel/qapi-code-gen.txt
> @@ -32,7 +32,7 @@ differences:
>
>  * No JSON numbers
>
> -* Strings use 'single quotes' instead of "double quotes"
> +* Strings can use 'single quotes' in addition to "double quotes"
>
>  * The input character set is plain ASCII
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 477402b7f8..18c8175866 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -382,14 +382,15 @@ class QAPISchemaParser(object):
>                      return
>              elif self.tok in '{}:,[]':
>                  return
> -            elif self.tok == "'":
> +            elif self.tok == "'" or self.tok == '"':
>                  string = ''
>                  esc = False
>                  while True:
>                      ch = self.src[self.cursor]
>                      self.cursor += 1
>                      if ch == '\n':
> -                        raise QAPIParseError(self, 'Missing terminating "\'"')
> +                        raise QAPIParseError(
> +                            self, 'Missing terminating %r' % self.tok)
>                      if esc:
>                          if ch == 'b':
>                              string += '\b'
> @@ -429,8 +430,9 @@ class QAPISchemaParser(object):
>                          esc = False
>                      elif ch == '\\':
>                          esc = True
> -                    elif ch == "'":
> +                    elif ch == self.tok:
>                          self.val = string
> +                        self.tok = "'"
>                          return
>                      else:
>                          string += ch
> diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
> index ac8aefc924..c74d5632a5 100644
> --- a/tests/qapi-schema/qapi-schema-test.json
> +++ b/tests/qapi-schema/qapi-schema-test.json
> @@ -11,7 +11,7 @@
>          'guest-sync' ] } }
>
>  { 'struct': 'TestStruct',
> -  'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }
> +  'data': { 'integer': 'int', 'boolean': 'bool', 'string': "str" } }
>
>  # for testing enums
>  { 'struct': 'NestedEnumsOne',
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax Markus Armbruster
@ 2017-10-04 11:59   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 11:59 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Section "QMP/Guest agent schema" is one big paragraph, encumbered with
> more detail than necessary.  It also claims JSON null isn't supported,
> which is untrue since commit e53188a, v2.4.0.  Rewrite it.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  docs/devel/qapi-code-gen.txt | 36 ++++++++++++++++++------------------
>  1 file changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt
> index f5b7659caf..3186c36460 100644
> --- a/docs/devel/qapi-code-gen.txt
> +++ b/docs/devel/qapi-code-gen.txt
> @@ -25,24 +25,24 @@ how the schemas, scripts, and resulting code are used.
>
>  == QMP/Guest agent schema ==
>
> -A QAPI schema file is designed to be loosely based on JSON
> -(http://www.ietf.org/rfc/rfc7159.txt) with changes for quoting style
> -and the use of comments; a QAPI schema file is then parsed by a python
> -code generation program.  A valid QAPI schema consists of a series of
> -top-level expressions, with no commas between them.  Where
> -dictionaries (JSON objects) are used, they are parsed as python
> -OrderedDicts so that ordering is preserved (for predictable layout of
> -generated C structs and parameter lists).  Ordering doesn't matter
> -between top-level expressions or the keys within an expression, but
> -does matter within dictionary values for 'data' and 'returns' members
> -of a single expression.  QAPI schema input is written using 'single
> -quotes' instead of JSON's "double quotes" (in contrast, Client JSON
> -Protocol uses no comments, and while input accepts 'single quotes' as
> -an extension, output is strict JSON using only "double quotes").  As
> -in JSON, trailing commas are not permitted in arrays or dictionaries.
> -Input must be ASCII (although QMP supports full Unicode strings, the
> -QAPI parser does not).  At present, there is no place where a QAPI
> -schema requires the use of JSON numbers or null.
> +Schema syntax is based on JSON (RFC 7159), with the following
> +differences:
> +
> +* Comments (see below)
> +
> +* No JSON numbers
> +
> +* Strings use 'single quotes' instead of "double quotes"
> +
> +* The input character set is plain ASCII
> +
> +  Unicode characters need to be escaped.  In contrast, the Client JSON
> +  Protocol uses UTF-8.
> +
> +A QAPI schema consists of a sequence of JSON values (top-level
> +expressions), with no commas between them.  The order of top-level
> +expressions doesn't matter.  The order of keys in JSON objects is
> +generally relevant.
>
>
>  === Comments ===
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type()
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type() Markus Armbruster
@ 2017-10-04 12:00   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 12:00 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi.py | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 248d650858..4871eb7740 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1552,6 +1552,11 @@ class QAPISchema(object):
>                                                    members, None))
>          return name
>
> +    def _make_implicit_wrapper_type(self, typ, info):
> +        return self._make_implicit_object_type(
> +            typ, info, None, 'wrapper',
> +            [self._make_member('data', typ, info)])
> +
>      def _def_enum_type(self, expr, info, doc):
>          name = expr['enum']
>          data = expr['data']
> @@ -1588,8 +1593,7 @@ class QAPISchema(object):
>          if isinstance(typ, list):
>              assert len(typ) == 1
>              typ = self._make_array_type(typ[0], info)
> -        typ = self._make_implicit_object_type(
> -            typ, info, None, 'wrapper', [self._make_member('data', typ, info)])
> +        typ = self._make_implicit_wrapper_type(typ, info)
>          return QAPISchemaObjectTypeVariant(case, typ)
>
>      def _def_union_type(self, expr, info, doc):
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage Markus Armbruster
@ 2017-10-04 12:02   ` Marc-André Lureau
  2017-10-05  4:29     ` Markus Armbruster
  0 siblings, 1 reply; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 12:02 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> This demonstrates a bug in the lowering of simple unions: if more than
> one schema uses the same built-in type T for a simple union member,
> they all generate the same q_obj_T_wrapper into their qapi-types.h.
> They clash when you include more than one schema's qapi-types.h.

Ah, I don't remember seeing that when I splitted the schema in my
qapi-if / conditional series.

Could it happen with non-built-in types ?

> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  tests/qapi-schema/qapi-schema-test.json |  6 ++++++
>  tests/qapi-schema/qapi-schema-test.out  | 10 ++++++++++
>  2 files changed, 16 insertions(+)
>
> diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
> index c72dbd8050..c091626635 100644
> --- a/tests/qapi-schema/qapi-schema-test.json
> +++ b/tests/qapi-schema/qapi-schema-test.json
> @@ -82,6 +82,12 @@
>    'base': 'UserDefZero',
>    'data': { 'string': 'str', 'enum1': 'EnumOne' } }
>
> +{ 'union': 'UserDefSimpleUnion',
> +  'data': { 'value1': 'UserDefA',
> +# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's
> +#           'value2': 'int',
> +            'value3': 'UserDefB' } }
> +
>  # this variant of UserDefFlatUnion defaults to a union that uses members with
>  # allocated types to test corner cases in the cleanup/dealloc visitor
>  { 'union': 'UserDefFlatUnion2',
> diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
> index 4b42db23b2..97bb02f2fd 100644
> --- a/tests/qapi-schema/qapi-schema-test.out
> +++ b/tests/qapi-schema/qapi-schema-test.out
> @@ -108,6 +108,12 @@ object UserDefOptions
>      member u16: uint16List optional=True
>      member i64x: int optional=True
>      member u64x: uint64 optional=True
> +object UserDefSimpleUnion
> +    member type: UserDefSimpleUnionKind optional=False
> +    tag type
> +    case value1: q_obj_UserDefA-wrapper
> +    case value3: q_obj_UserDefB-wrapper
> +enum UserDefSimpleUnionKind ['value1', 'value3']
>  object UserDefTwo
>      member string0: str optional=False
>      member dict1: UserDefTwoDict optional=False
> @@ -169,6 +175,10 @@ object q_obj_EVENT_D-arg
>      member b: str optional=False
>      member c: str optional=True
>      member enum3: EnumOne optional=True
> +object q_obj_UserDefA-wrapper
> +    member data: UserDefA optional=False
> +object q_obj_UserDefB-wrapper
> +    member data: UserDefB optional=False
>  object q_obj_UserDefFlatUnion2-base
>      member integer: int optional=True
>      member string: str optional=False
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas Markus Armbruster
@ 2017-10-04 12:04   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 12:04 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> If more than one schema uses the same built-in type T for a simple
> union member, they all generate the same q_obj_T_wrapper into their
> qapi-types.h.  They clash when you include more than one schema's
> qapi-types.h.
>
> Fix by generating them into builtin-qapi-types.h instead.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  scripts/qapi-types.py                   | 12 ++++++++----
>  scripts/qapi.py                         |  2 ++
>  tests/qapi-schema/builtins.out          | 30 ++++++++++++++++++++++++++++++
>  tests/qapi-schema/qapi-schema-test.json |  3 +--
>  tests/qapi-schema/qapi-schema-test.out  |  5 ++---
>  5 files changed, 43 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py
> index 18fd2a98c0..c058540e4d 100644
> --- a/scripts/qapi-types.py
> +++ b/scripts/qapi-types.py
> @@ -53,7 +53,10 @@ def gen_struct_members(members):
>      return ret
>
>
> -def gen_object(name, base, members, variants):
> +def gen_object(name, info, base, members, variants):
> +    # TODO use something cleaner than existence of info
> +    if not info and args.schema:
> +        return ''               # suppress built-in
>      if name in objects_seen:
>          return ''
>      objects_seen.add(name)
> @@ -62,7 +65,7 @@ def gen_object(name, base, members, variants):
>      if variants:
>          for v in variants.variants:
>              if isinstance(v.type, QAPISchemaObjectType):
> -                ret += gen_object(v.type.name, v.type.base,
> +                ret += gen_object(v.type.name, v.type.info, v.type.base,
>                                    v.type.local_members, v.type.variants)
>
>      ret += mcgen('''
> @@ -200,7 +203,7 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>          if name == 'q_empty':
>              return
>          self._fwdecl += gen_fwd_object_or_array(name)
> -        self.decl += gen_object(name, base, members, variants)
> +        self.decl += gen_object(name, info, base, members, variants)
>          if base and not base.is_implicit():
>              self.decl += gen_upcast(name, base)
>          # TODO Worth changing the visitor signature, so we could
> @@ -211,7 +214,8 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
>
>      def visit_alternate_type(self, name, info, variants):
>          self._fwdecl += gen_fwd_object_or_array(name)
> -        self.decl += gen_object(name, None, [variants.tag_member], variants)
> +        self.decl += gen_object(name, info, None,
> +                                [variants.tag_member], variants)
>          self._gen_type_cleanup(name)
>
>  argparser = common_argument_parser(builtins=True)
> diff --git a/scripts/qapi.py b/scripts/qapi.py
> index 4871eb7740..477402b7f8 100644
> --- a/scripts/qapi.py
> +++ b/scripts/qapi.py
> @@ -1499,6 +1499,8 @@ class QAPISchema(object):
>          # would be to use lazy instantiation, while figuring out how to
>          # avoid compilation issues with multiple qapi-types.h.
>          self._make_array_type(name, None)
> +        # TODO same for wrapper types
> +        self._make_implicit_wrapper_type(name, None)
>
>      def _def_predefineds(self):
>          for t in [('str',    'string',  'char' + pointer_suffix),
> diff --git a/tests/qapi-schema/builtins.out b/tests/qapi-schema/builtins.out
> index 40b886ddae..d289bfe919 100644
> --- a/tests/qapi-schema/builtins.out
> +++ b/tests/qapi-schema/builtins.out
> @@ -1,3 +1,33 @@
>  enum QType ['none', 'qnull', 'qnum', 'qstring', 'qdict', 'qlist', 'qbool']
>      prefix QTYPE
>  object q_empty
> +object q_obj_any-wrapper
> +    member data: any optional=False
> +object q_obj_bool-wrapper
> +    member data: bool optional=False
> +object q_obj_int-wrapper
> +    member data: int optional=False
> +object q_obj_int16-wrapper
> +    member data: int16 optional=False
> +object q_obj_int32-wrapper
> +    member data: int32 optional=False
> +object q_obj_int64-wrapper
> +    member data: int64 optional=False
> +object q_obj_int8-wrapper
> +    member data: int8 optional=False
> +object q_obj_null-wrapper
> +    member data: null optional=False
> +object q_obj_number-wrapper
> +    member data: number optional=False
> +object q_obj_size-wrapper
> +    member data: size optional=False
> +object q_obj_str-wrapper
> +    member data: str optional=False
> +object q_obj_uint16-wrapper
> +    member data: uint16 optional=False
> +object q_obj_uint32-wrapper
> +    member data: uint32 optional=False
> +object q_obj_uint64-wrapper
> +    member data: uint64 optional=False
> +object q_obj_uint8-wrapper
> +    member data: uint8 optional=False
> diff --git a/tests/qapi-schema/qapi-schema-test.json b/tests/qapi-schema/qapi-schema-test.json
> index c091626635..ac8aefc924 100644
> --- a/tests/qapi-schema/qapi-schema-test.json
> +++ b/tests/qapi-schema/qapi-schema-test.json
> @@ -84,8 +84,7 @@
>
>  { 'union': 'UserDefSimpleUnion',
>    'data': { 'value1': 'UserDefA',
> -# FIXME generated q_obj_int_wrapper clashes with qapi-schema.json's
> -#           'value2': 'int',
> +            'value2': 'int',
>              'value3': 'UserDefB' } }
>
>  # this variant of UserDefFlatUnion defaults to a union that uses members with
> diff --git a/tests/qapi-schema/qapi-schema-test.out b/tests/qapi-schema/qapi-schema-test.out
> index 97bb02f2fd..fff25e26d0 100644
> --- a/tests/qapi-schema/qapi-schema-test.out
> +++ b/tests/qapi-schema/qapi-schema-test.out
> @@ -112,8 +112,9 @@ object UserDefSimpleUnion
>      member type: UserDefSimpleUnionKind optional=False
>      tag type
>      case value1: q_obj_UserDefA-wrapper
> +    case value2: q_obj_int-wrapper
>      case value3: q_obj_UserDefB-wrapper
> -enum UserDefSimpleUnionKind ['value1', 'value3']
> +enum UserDefSimpleUnionKind ['value1', 'value2', 'value3']
>  object UserDefTwo
>      member string0: str optional=False
>      member dict1: UserDefTwoDict optional=False
> @@ -211,8 +212,6 @@ object q_obj_numberList-wrapper
>      member data: numberList optional=False
>  object q_obj_sizeList-wrapper
>      member data: sizeList optional=False
> -object q_obj_str-wrapper
> -    member data: str optional=False
>  object q_obj_strList-wrapper
>      member data: strList optional=False
>  object q_obj_uint16List-wrapper
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment Markus Armbruster
@ 2017-10-04 12:10   ` Marc-André Lureau
  0 siblings, 0 replies; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-04 12:10 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth, qemu trival

CC qemu-trivial

On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
> Comments explaining why we include a header tend to go bad.  This
> one's almost comical: not only doesn't qemu-options.hx use
> MAP_POPULATE anymore (since commit ef36fa1, v2.0.0, 2013), even the
> include it applies to got moved away in commit 02d0e09 (v2.7.0).
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


> ---
>  os-posix.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/os-posix.c b/os-posix.c
> index 92e9d85215..b9c2343b1e 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -25,7 +25,6 @@
>
>  #include "qemu/osdep.h"
>  #include <sys/wait.h>
> -/*needed for MAP_POPULATE before including qemu-options.h */
>  #include <pwd.h>
>  #include <grp.h>
>  #include <libgen.h>
> --
> 2.13.6
>
>



-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types
  2017-10-04 11:52   ` Marc-André Lureau
@ 2017-10-05  4:24     ` Markus Armbruster
  0 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-05  4:24 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Michael Roth

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> Hi
>
> On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> qapi-types.py and qapi-visit.py generate some C code for built-in
>> types.  To make this work with multiple schemas, we generate code for
>> built-ins into .c files only when the user asks for it with -b.  The
>> user is responsible for linking exactly one set of files generated
>> with -b per program.  We generate code for built-ins into .h
>> regardless of -b, but guard it with a preprocessor symbol.
>>
>> This is cumbersome and inflexible.  Move the code generated for
>> built-in types into separate files builtin-qapi-{types,visit}.{c,h}.
>> Run qapi-types.py and qapi-visit.py without a schema argument to
>> generate them.  Drop their option -b.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
>
> Good idea!
> I think I would still prefer to see a seperate argument to generate
> builtin files (rather than absence of schema), but this is minor
> detail.

An option to generate built-ins would have to conflict with -p and the
positional argument.  I tried the stupidest solution that could possibly
work first.

> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage
  2017-10-04 12:02   ` Marc-André Lureau
@ 2017-10-05  4:29     ` Markus Armbruster
  0 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-05  4:29 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Michael Roth

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> This demonstrates a bug in the lowering of simple unions: if more than
>> one schema uses the same built-in type T for a simple union member,
>> they all generate the same q_obj_T_wrapper into their qapi-types.h.
>> They clash when you include more than one schema's qapi-types.h.
>
> Ah, I don't remember seeing that when I splitted the schema in my
> qapi-if / conditional series.

Simple union members of built-in type are rare.  I spotted the problem
with options, then realized it's already possible with simple unions.

> Could it happen with non-built-in types ?

Yes, but multiple q_obj_T_wrapper can clash only when their T also
clash.  Name your types more wisely then.

>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Thanks!

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-04 11:58   ` Marc-André Lureau
@ 2017-10-05  4:41     ` Markus Armbruster
  2017-10-05 14:13       ` Marc-André Lureau
  2017-10-05 15:16       ` Eric Blake
  0 siblings, 2 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-05  4:41 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Michael Roth

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
>> The QAPI schema parser has always accepted only single-quoted strings,
>> even though JSON strings are double-quoted.  Accept double-quoted
>> strings as well, so you can write strings containing single quotes
>> without backslash escapes.
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>
> What's the motivation to allow both? If we were to switch from single
> to double quote only, that would make more sense.

Abandoning single quotes now would require us to touch pretty much every
line of code in the schemas.  I don't think correcting quotes is worth
wrecking git-blame.

Sadly, the schema language is neither JSON, nor an established extension
of JSON, nor Python.  This commit brings the schema language one step
closer to a superset of JSON.  I feel "homegrown superset" is a slightly
less bad idea than "homegrown with large overlap".

Naming the schema files .json was in bad taste.

> otherwise, patch looks good

Ready to upgrade to R-by now?

Want me to work more of my rationale into the commit message?

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-05  4:41     ` Markus Armbruster
@ 2017-10-05 14:13       ` Marc-André Lureau
  2017-10-06  5:29         ` Markus Armbruster
  2017-10-05 15:16       ` Eric Blake
  1 sibling, 1 reply; 61+ messages in thread
From: Marc-André Lureau @ 2017-10-05 14:13 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU, Michael Roth

On Thu, Oct 5, 2017 at 6:41 AM, Markus Armbruster <armbru@redhat.com> wrote:
> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>
>> On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
>>> The QAPI schema parser has always accepted only single-quoted strings,
>>> even though JSON strings are double-quoted.  Accept double-quoted
>>> strings as well, so you can write strings containing single quotes
>>> without backslash escapes.
>>>
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>
>> What's the motivation to allow both? If we were to switch from single
>> to double quote only, that would make more sense.
>
> Abandoning single quotes now would require us to touch pretty much every
> line of code in the schemas.  I don't think correcting quotes is worth
> wrecking git-blame.
>

Recent (and upcoming) changes to the schema are already quite
invasive. I think we could do it, convert all strings to double-quote,
and it would help with getting the schema closer to a valid json.

Fwiw, there are tools like
https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
to skip commits in git-blame. It's also fairly easy to run git blame
before the reformatting commit.

> Sadly, the schema language is neither JSON, nor an established extension
> of JSON, nor Python.  This commit brings the schema language one step
> closer to a superset of JSON.  I feel "homegrown superset" is a slightly
> less bad idea than "homegrown with large overlap".
>
> Naming the schema files .json was in bad taste.
>
>> otherwise, patch looks good
>
> Ready to upgrade to R-by now?
>
> Want me to work more of my rationale into the commit message?

-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment
  2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment Markus Armbruster
@ 2017-10-05 14:58   ` Eric Blake
  2017-10-06  5:24     ` Markus Armbruster
  0 siblings, 1 reply; 61+ messages in thread
From: Eric Blake @ 2017-10-05 14:58 UTC (permalink / raw)
  To: Markus Armbruster, qemu-devel; +Cc: mdroth, marcandre.lureau

[-- Attachment #1: Type: text/plain, Size: 1034 bytes --]

On 10/02/2017 10:25 AM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  scripts/texi2pod.pl | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

My perl is a bit rusty, but I think I can handle this one.

> 
> diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
> index 39ce584a32..2171f8b819 100755
> --- a/scripts/texi2pod.pl
> +++ b/scripts/texi2pod.pl
> @@ -85,6 +85,13 @@ if (defined $out) {
>  
>  while(defined $inf) {
>  while(<$inf>) {
> +    # Verbatim environment
> +    if (defined $endw and $endw eq "verbatim"
> +	and not (/^\@end\s+([a-z]+)/ and $1 eq $endw)) {

You anchored to the beginning, but not the end, of the line; that means
you accept '@end verbatim garbage' as an end marker.  Worth adding $?

If that's the only change, I'm okay with adding:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-05  4:41     ` Markus Armbruster
  2017-10-05 14:13       ` Marc-André Lureau
@ 2017-10-05 15:16       ` Eric Blake
  2017-10-06  5:27         ` Markus Armbruster
  1 sibling, 1 reply; 61+ messages in thread
From: Eric Blake @ 2017-10-05 15:16 UTC (permalink / raw)
  To: Markus Armbruster, Marc-André Lureau; +Cc: QEMU, Michael Roth

[-- Attachment #1: Type: text/plain, Size: 860 bytes --]

On 10/04/2017 11:41 PM, Markus Armbruster wrote:

> Sadly, the schema language is neither JSON, nor an established extension
> of JSON, nor Python.  This commit brings the schema language one step
> closer to a superset of JSON.  I feel "homegrown superset" is a slightly
> less bad idea than "homegrown with large overlap".
> 
> Naming the schema files .json was in bad taste.

Would it make sense to rename all of our files from .json to .qapi?
Then it is obvious that we are using a homegrown syntax; and it is also
easy enough to tweak things like .dir-locals.el to recognize that suffix
as triggering specific formatting rules.  Git rename detection means it
is still reasonable to blame across file renames.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

* Re: [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment
  2017-10-05 14:58   ` Eric Blake
@ 2017-10-06  5:24     ` Markus Armbruster
  2017-10-06 13:40       ` Eric Blake
  0 siblings, 1 reply; 61+ messages in thread
From: Markus Armbruster @ 2017-10-06  5:24 UTC (permalink / raw)
  To: Eric Blake; +Cc: qemu-devel, marcandre.lureau, mdroth

Eric Blake <eblake@redhat.com> writes:

> On 10/02/2017 10:25 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  scripts/texi2pod.pl | 11 +++++++++--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> My perl is a bit rusty, but I think I can handle this one.
>
>> 
>> diff --git a/scripts/texi2pod.pl b/scripts/texi2pod.pl
>> index 39ce584a32..2171f8b819 100755
>> --- a/scripts/texi2pod.pl
>> +++ b/scripts/texi2pod.pl
>> @@ -85,6 +85,13 @@ if (defined $out) {
>>  
>>  while(defined $inf) {
>>  while(<$inf>) {
>> +    # Verbatim environment
>> +    if (defined $endw and $endw eq "verbatim"
>> +	and not (/^\@end\s+([a-z]+)/ and $1 eq $endw)) {
>
> You anchored to the beginning, but not the end, of the line; that means
> you accept '@end verbatim garbage' as an end marker.  Worth adding $?

Cribbed from

    # End-block handler goes up here because it needs to operate even
    # if we are skipping.
    /^\@end\s+([a-z]+)/ and do {
	# Ignore @end foo, where foo is not an operation which may
	# cause us to skip, if we are presently skipping.
	my $ended = $1;
	next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/;

	die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
	die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;

	$endw = pop @endwstack;

I'd prefer to stick to this regexp.

texi2pod.pl parses quite sloppily in general.

> If that's the only change, I'm okay with adding:
>
> Reviewed-by: Eric Blake <eblake@redhat.com>

Does this apply to the unchanged patch, too?

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-05 15:16       ` Eric Blake
@ 2017-10-06  5:27         ` Markus Armbruster
  0 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-06  5:27 UTC (permalink / raw)
  To: Eric Blake; +Cc: Marc-André Lureau, QEMU, Michael Roth

Eric Blake <eblake@redhat.com> writes:

> On 10/04/2017 11:41 PM, Markus Armbruster wrote:
>
>> Sadly, the schema language is neither JSON, nor an established extension
>> of JSON, nor Python.  This commit brings the schema language one step
>> closer to a superset of JSON.  I feel "homegrown superset" is a slightly
>> less bad idea than "homegrown with large overlap".
>> 
>> Naming the schema files .json was in bad taste.
>
> Would it make sense to rename all of our files from .json to .qapi?
> Then it is obvious that we are using a homegrown syntax; and it is also
> easy enough to tweak things like .dir-locals.el to recognize that suffix
> as triggering specific formatting rules.  Git rename detection means it
> is still reasonable to blame across file renames.

I don't know.  I'm always reluctant to rename files.  Probably too
reluctant.  Opinions?

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

* Re: [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings
  2017-10-05 14:13       ` Marc-André Lureau
@ 2017-10-06  5:29         ` Markus Armbruster
  0 siblings, 0 replies; 61+ messages in thread
From: Markus Armbruster @ 2017-10-06  5:29 UTC (permalink / raw)
  To: Marc-André Lureau; +Cc: QEMU, Michael Roth

Marc-André Lureau <marcandre.lureau@gmail.com> writes:

> On Thu, Oct 5, 2017 at 6:41 AM, Markus Armbruster <armbru@redhat.com> wrote:
>> Marc-André Lureau <marcandre.lureau@gmail.com> writes:
>>
>>> On Mon, Oct 2, 2017 at 5:25 PM, Markus Armbruster <armbru@redhat.com> wrote:
>>>> The QAPI schema parser has always accepted only single-quoted strings,
>>>> even though JSON strings are double-quoted.  Accept double-quoted
>>>> strings as well, so you can write strings containing single quotes
>>>> without backslash escapes.
>>>>
>>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>>
>>> What's the motivation to allow both? If we were to switch from single
>>> to double quote only, that would make more sense.
>>
>> Abandoning single quotes now would require us to touch pretty much every
>> line of code in the schemas.  I don't think correcting quotes is worth
>> wrecking git-blame.
>>
>
> Recent (and upcoming) changes to the schema are already quite
> invasive. I think we could do it, convert all strings to double-quote,
> and it would help with getting the schema closer to a valid json.

Is the recent (and upcoming) churn *that* bad?  Got numbers?

> Fwiw, there are tools like
> https://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/git-hyper-blame.html
> to skip commits in git-blame. It's also fairly easy to run git blame
> before the reformatting commit.

Both techniques add friction...

>> Sadly, the schema language is neither JSON, nor an established extension
>> of JSON, nor Python.  This commit brings the schema language one step
>> closer to a superset of JSON.  I feel "homegrown superset" is a slightly
>> less bad idea than "homegrown with large overlap".
>>
>> Naming the schema files .json was in bad taste.
>>
>>> otherwise, patch looks good
>>
>> Ready to upgrade to R-by now?
>>
>> Want me to work more of my rationale into the commit message?

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

* Re: [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment
  2017-10-06  5:24     ` Markus Armbruster
@ 2017-10-06 13:40       ` Eric Blake
  0 siblings, 0 replies; 61+ messages in thread
From: Eric Blake @ 2017-10-06 13:40 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-devel, marcandre.lureau, mdroth

[-- Attachment #1: Type: text/plain, Size: 1527 bytes --]

On 10/06/2017 12:24 AM, Markus Armbruster wrote:
> Eric Blake <eblake@redhat.com> writes:
> 
>> On 10/02/2017 10:25 AM, Markus Armbruster wrote:
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>> ---
>>>  scripts/texi2pod.pl | 11 +++++++++--
>>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>

>>> +	and not (/^\@end\s+([a-z]+)/ and $1 eq $endw)) {
>>
>> You anchored to the beginning, but not the end, of the line; that means
>> you accept '@end verbatim garbage' as an end marker.  Worth adding $?
> 
> Cribbed from
> 
>     # End-block handler goes up here because it needs to operate even
>     # if we are skipping.
>     /^\@end\s+([a-z]+)/ and do {
> 	# Ignore @end foo, where foo is not an operation which may
> 	# cause us to skip, if we are presently skipping.
> 	my $ended = $1;
> 	next if $skipping && $ended !~ /^(?:ifset|ifclear|ignore|menu|iftex|copying)$/;
> 
> 	die "\@end $ended without \@$ended at line $.\n" unless defined $endw;
> 	die "\@$endw ended by \@end $ended at line $.\n" unless $ended eq $endw;
> 
> 	$endw = pop @endwstack;
> 
> I'd prefer to stick to this regexp.

Consistency makes sense.

> 
> texi2pod.pl parses quite sloppily in general.
> 
>> If that's the only change, I'm okay with adding:
>>
>> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
> Does this apply to the unchanged patch, too?

Yes.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]

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

end of thread, other threads:[~2017-10-06 13:40 UTC | newest]

Thread overview: 61+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-02 15:25 [Qemu-devel] [RFC PATCH 00/32] Command line QAPIfication Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 01/32] tests/qapi-schema: Improve coverage of '@' Markus Armbruster
2017-10-04 10:37   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 02/32] texi2pod: Support @verbatim environment Markus Armbruster
2017-10-05 14:58   ` Eric Blake
2017-10-06  5:24     ` Markus Armbruster
2017-10-06 13:40       ` Eric Blake
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 03/32] qapi2texi: Fix for examples containing '@' Markus Armbruster
2017-10-04 10:45   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 04/32] qapi2texi: Fix for '@' not followed by \w character Markus Armbruster
2017-10-04 10:47   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 05/32] qapi2texi: Provide access to Texinfo markup Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 06/32] qapi2texi: Drop | example markup Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 07/32] qapi: Drop superfluous allow_optional=True Markus Armbruster
2017-10-04 10:52   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 08/32] qapi: Simplify check_name() parameters Markus Armbruster
2017-10-04 10:54   ` Marc-André Lureau
2017-10-04 10:54   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 09/32] qapi: check_type() parameter allow_optional is now unused, drop Markus Armbruster
2017-10-04 10:55   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 10/32] qapi: Don't run generators twice Markus Armbruster
2017-10-04 11:04   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 11/32] qapi: Drop the options to generate only .c or .h Markus Armbruster
2017-10-04 11:07   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 12/32] qapi: Use argparse to parse command line arguments Markus Armbruster
2017-10-04 11:13   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 13/32] qapi: Use argparse to open schema file Markus Armbruster
2017-10-04 11:18   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 14/32] qapi: Rework generated code for built-in types Markus Armbruster
2017-10-04 11:52   ` Marc-André Lureau
2017-10-05  4:24     ` Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 15/32] tests/qapi-schema: Improve simple union coverage Markus Armbruster
2017-10-04 12:02   ` Marc-André Lureau
2017-10-05  4:29     ` Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 16/32] qapi: Factor out _make_implicit_wrapper_type() Markus Armbruster
2017-10-04 12:00   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 17/32] qapi: Fix simple union lowering with multiple schemas Markus Armbruster
2017-10-04 12:04   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 18/32] docs/devel/qapi-code-gen.txt: Rewrite section on schema syntax Markus Armbruster
2017-10-04 11:59   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 19/32] qapi: Accept double-quoted strings Markus Armbruster
2017-10-04 11:58   ` Marc-André Lureau
2017-10-05  4:41     ` Markus Armbruster
2017-10-05 14:13       ` Marc-André Lureau
2017-10-06  5:29         ` Markus Armbruster
2017-10-05 15:16       ` Eric Blake
2017-10-06  5:27         ` Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 20/32] qapi: Frontend for defining command line options Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 21/32] qapi: Define QAPIOptionKind and QAPIOption automatically Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 22/32] qapi: New helper c_string() Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 23/32] qapi-options: Command line option backend Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 24/32] qapi-options: Generate help string Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 25/32] qapi-introspect: Include command line options information Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 26/32] qapi2texi: " Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 27/32] os-posix: Drop misleading comment Markus Armbruster
2017-10-04 12:10   ` Marc-André Lureau
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 28/32] vl: QAPIfy command line option definition Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 29/32] qapi/options: QAPIfy --echr argument type Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 30/32] qapi/options: QAPIfy --watchdog-action " Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 31/32] qapi/options: QAPIfy --blockdev " Markus Armbruster
2017-10-02 15:25 ` [Qemu-devel] [RFC PATCH 32/32] qapi/options: QAPIfy --add-fd " Markus Armbruster

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.