1. 13 6月, 2019 1 次提交
    • K
      qapi: Add feature flags to struct types · 6a8c0b51
      Kevin Wolf 提交于
      Sometimes, the behaviour of QEMU changes without a change in the QMP
      syntax (usually by allowing values or operations that previously
      resulted in an error). QMP clients may still need to know whether
      they can rely on the changed behavior.
      
      Let's add feature flags to the QAPI schema language, so that we can make
      such changes visible with schema introspection.
      
      An example for a schema definition using feature flags looks like this:
      
          { 'struct': 'TestType',
            'data': { 'number': 'int' },
            'features': [ 'allow-negative-numbers' ] }
      
      Introspection information then looks like this:
      
          { "name": "TestType", "meta-type": "object",
            "members": [
                { "name": "number", "type": "int" } ],
            "features": [ "allow-negative-numbers" ] }
      
      This patch implements feature flags only for struct types. We'll
      implement them more widely as needed.
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Message-Id: <20190606153803.5278-2-armbru@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      6a8c0b51
  2. 05 3月, 2019 3 次提交
    • M
      qapi: Fix array first used in a different module · 56a46895
      Markus Armbruster 提交于
      We generally put implicitly defined types in whatever module triggered
      their definition.  This is wrong for array types, as the included test
      case demonstrates.  Let's have a closer look at it.
      
      Type 'Status' is defined sub-sub-module.json.  Array type ['Status']
      occurs in main module qapi-schema-test.json and in
      include/sub-module.json.  The main module's use is first, so the array
      type gets put into the main module.
      
      The generated C headers define StatusList in qapi-types.h.  But
      include/qapi-types-sub-module.h uses it without including
      qapi-types.h.  Oops.
      
      To fix that, put the array type into its element type's module.
      
      Now StatusList gets generated into qapi-types-sub-module.h, which all
      its users include.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190301154051.23317-8-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      56a46895
    • M
      qapi: Fix code generation for sub-modules in other directories · 709395f8
      Markus Armbruster 提交于
      The #include directives to pull in sub-modules use file names relative
      to the main module.  Works only when all modules are in the same
      directory, or the main module's output directory is in the compiler's
      include path.  Use relative file names instead.
      
      The dummy variable we generate to avoid empty .o files has an invalid
      name for sub-modules in other directories.  Fix that.
      
      Both messed up in commit 252dc310 "qapi: Generate separate .h, .c
      for each module".  Escaped testing because tests/qapi-schema-test.json
      doesn't cover sub-modules in other directories, only
      tests/qapi-schema/include-relpath.json does, and we generate and
      compile C code only for the former, not the latter.  Fold the latter
      into the former.  This would have caught the mistakes fixed in this
      commit.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190301154051.23317-5-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      709395f8
    • M
      qapi: Pass file name to QAPIGen constructor instead of methods · dddee4d7
      Markus Armbruster 提交于
      Not much of an improvement now, but the next commit will profit.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190301154051.23317-4-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      dddee4d7
  3. 18 2月, 2019 2 次提交
    • M
      qapi: Prepare for system modules other than 'builtin' · c2e196a9
      Markus Armbruster 提交于
      The next commit wants to generate qapi-emit-events.{c.h}.  To enable
      that, extend QAPISchemaModularCVisitor to support additional "system
      modules", i.e. modules that don't correspond to a (user-defined) QAPI
      schema module.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20190214152251.2073-5-armbru@redhat.com>
      c2e196a9
    • M
      qapi: Clean up modular built-in code generation a bit · dcac6471
      Markus Armbruster 提交于
      We neglect to call .visit_module() for the special module we use for
      built-ins.  Harmless, but clean it up anyway.  The
      tests/qapi-schema/*.out now show the built-in module as 'module None'.
      
      Subclasses of QAPISchemaModularCVisitor need to ._add_module() this
      special module to enable code generation for built-ins.  When this
      hasn't been done, QAPISchemaModularCVisitor.visit_module() does
      nothing for the special module.  That looks like built-ins could
      accidentally be generated into the wrong module when a subclass
      neglects to call ._add_module().  Can't happen, because built-ins are
      all visited before any other module.  But that's non-obvious.  Switch
      off code generation explicitly.
      
      Rename QAPISchemaModularCVisitor._begin_module() to
      ._begin_user_module().
      
      New QAPISchemaModularCVisitor._is_builtin_module(), for clarity.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <20190214152251.2073-4-armbru@redhat.com>
      dcac6471
  4. 18 12月, 2018 1 次提交
  5. 14 12月, 2018 12 次提交
  6. 29 8月, 2018 2 次提交
  7. 15 8月, 2018 1 次提交
    • M
      qapi: Fix some pycodestyle-3 complaints · b736e25a
      Markus Armbruster 提交于
      Fix the following issues:
      
          common.py:873:13: E129 visually indented line with same indent as next logical line
          common.py:1766:5: E741 ambiguous variable name 'l'
          common.py:1784:1: E305 expected 2 blank lines after class or function definition, found 1
          common.py:1833:1: E305 expected 2 blank lines after class or function definition, found 1
          common.py:1843:1: E305 expected 2 blank lines after class or function definition, found 1
          visit.py:181:18: E127 continuation line over-indented for visual indent
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
      Message-Id: <20180621083551.775-1-armbru@redhat.com>
      [Fixup squashed in:]
      Message-ID: <871sd0nzw9.fsf@dusky.pond.sub.org>
      Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
      b736e25a
  8. 04 7月, 2018 6 次提交
  9. 22 6月, 2018 2 次提交
  10. 09 6月, 2018 1 次提交
  11. 31 5月, 2018 1 次提交
    • I
      qapi: introduce new cmd option "allow-preconfig" · d6fe3d02
      Igor Mammedov 提交于
      New option will be used to allow commands, which are prepared/need
      to run, during preconfig state. Other commands that should be able
      to run in preconfig state, should be amended to not expect machine
      in initialized state or deal with it.
      
      For compatibility reasons, commands that don't use new flag
      'allow-preconfig' explicitly are not permitted to run in
      preconfig state but allowed in all other states like they used
      to be.
      
      Within this patch allow following commands in preconfig state:
         qmp_capabilities
         query-qmp-schema
         query-commands
         query-command-line-options
         query-status
         exit-preconfig
      to allow qmp connection, basic introspection and moving to the next
      state.
      
      PS:
      set-numa-node and query-hotpluggable-cpus will be enabled later in
      a separate patches.
      Signed-off-by: NIgor Mammedov <imammedo@redhat.com>
      Message-Id: <1526057503-39287-1-git-send-email-imammedo@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [ehabkost: Changed "since 2.13" to "since 3.0"]
      Signed-off-by: NEduardo Habkost <ehabkost@redhat.com>
      d6fe3d02
  12. 04 5月, 2018 1 次提交
    • L
      qapi: add SysEmuTarget to "common.json" · 9a801c7d
      Laszlo Ersek 提交于
      We'll soon need an enumeration type that lists all the softmmu targets
      that QEMU (the project) supports. Introduce @SysEmuTarget to
      "common.json".
      
      The enum constant @x86_64 doesn't match the QAPI convention of preferring
      hyphen ("-") over underscore ("_"). This is intentional; the @SysEmuTarget
      constants are supposed to produce QEMU executable names when stringified
      and appended to the "qemu-system-" prefix. Put differently, the
      replacement text of the TARGET_NAME preprocessor macro must be possible to
      look up in the list of (stringified) enum constants.
      
      Like other enum types, @SysEmuTarget too can be used for discriminator
      fields in unions. For the @i386 constant, a C-language union member called
      "i386" would be generated. On mingw build hosts, "i386" is a macro
      however. Add "i386" to "polluted_words" at once.
      
      Cc: "Daniel P. Berrange" <berrange@redhat.com>
      Cc: Eric Blake <eblake@redhat.com>
      Cc: Markus Armbruster <armbru@redhat.com>
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Message-Id: <20180427192852.15013-3-lersek@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9a801c7d
  13. 27 3月, 2018 1 次提交
  14. 20 3月, 2018 1 次提交
  15. 03 3月, 2018 5 次提交
    • M
      qapi: Move qapi-schema.json to qapi/, rename generated files · eb815e24
      Markus Armbruster 提交于
      Move qapi-schema.json to qapi/, so it's next to its modules, and all
      files get generated to qapi/, not just the ones generated for modules.
      
      Consistently name the generated files qapi-MODULE.EXT:
      qmp-commands.[ch] become qapi-commands.[ch], qapi-event.[ch] become
      qapi-events.[ch], and qmp-introspect.[ch] become qapi-introspect.[ch].
      This gets rid of the temporary hacks in scripts/qapi/commands.py,
      scripts/qapi/events.py, and scripts/qapi/common.py.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-28-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [eblake: Fix trailing dot in tpm.c, undo temporary hack for OSX toolchain]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      eb815e24
    • M
      qapi: Generate separate .h, .c for each module · 252dc310
      Markus Armbruster 提交于
      Our qapi-schema.json is composed of modules connected by include
      directives, but the generated code is monolithic all the same: one
      qapi-types.h with all the types, one qapi-visit.h with all the
      visitors, and so forth.  These monolithic headers get included all
      over the place.  In my "build everything" tree, adding a QAPI type
      recompiles about 4800 out of 5100 objects.
      
      We wouldn't write such monolithic headers by hand.  It stands to
      reason that we shouldn't generate them, either.
      
      Split up generated qapi-types.h to mirror the schema's modular
      structure: one header per module.  Name the main module's header
      qapi-types.h, and sub-module D/B.json's header D/qapi-types-B.h.
      
      Mirror the schema's includes in the headers, so that qapi-types.h gets
      you everything exactly as before.  If you need less, you can include
      one or more of the sub-module headers.  To be exploited shortly.
      
      Split up qapi-types.c, qapi-visit.h, qapi-visit.c, qmp-commands.h,
      qmp-commands.c, qapi-event.h, qapi-event.c the same way.
      qmp-introspect.h, qmp-introspect.c and qapi.texi remain monolithic.
      
      The split of qmp-commands.c duplicates static helper function
      qmp_marshal_output_str() in qapi-commands-char.c and
      qapi-commands-misc.c.  This happens when commands returning the same
      type occur in multiple modules.  Not worth avoiding.
      
      Since I'm going to rename qapi-event.[ch] to qapi-events.[ch], and
      qmp-commands.[ch] to qapi-commands.[ch], name the shards that way
      already, to reduce churn.  This requires temporary hacks in
      commands.py and events.py.  Similarly, c_name() must temporarily
      be taught to munge '/' in common.py.  They'll go away with the rename.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-23-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      [eblake: declare a dummy variable in each .c file, to shut up OSX
      toolchain warnings about empty .o files, including hacking c_name()]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      252dc310
    • M
      qapi/common: Fix guardname() for funny filenames · f9c14639
      Markus Armbruster 提交于
      guardname() fails to return a valid C identifier for arguments
      containing anything but [A-Za-z0-9_.-'].  Fix that.  Don't bother
      protecting ticklish identifiers; header guards are all-caps, and no
      ticklish identifiers are.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Message-Id: <20180211093607.27351-22-armbru@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      f9c14639
    • M
      qapi/types qapi/visit: Generate built-in stuff into separate files · cdb6610a
      Markus Armbruster 提交于
      Linking code from multiple separate QAPI schemata into the same
      program is possible, but involves some weirdness around built-in
      types:
      
      * We generate code for built-in types into .c only with option
        --builtins.  The user is responsible for generating code for exactly
        one QAPI schema per program with --builtins.
      
      * We generate code for built-in types into .h regardless of
        --builtins, but guarded by #ifndef QAPI_VISIT_BUILTIN.  Because all
        copies of this code are exactly the same, including any combination
        of these headers works.
      
      Replace this contraption by something more conventional: generate code
      for built-in types into their very own files: qapi-builtin-types.c,
      qapi-builtin-visit.c, qapi-builtin-types.h, qapi-builtin-visit.h, but
      only with --builtins.  Obey --output-dir, but ignore --prefix for
      them.
      
      Make qapi-types.h include qapi-builtin-types.h.  With multiple
      schemata you now have multiple qapi-types.[ch], but only one
      qapi-builtin-types.[ch].  Same for qapi-visit.[ch] and
      qapi-builtin-visit.[ch].
      
      Bonus: if all you need is built-in stuff, you can include a much
      smaller header.  To be exploited shortly.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-21-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [eblake: fix octal constant for python 3]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      cdb6610a
    • M
      qapi: Make code-generating visitors use QAPIGen more · 71b3f045
      Markus Armbruster 提交于
      The use of QAPIGen is rather shallow so far: most of the output
      accumulation is not converted.  Take the next step: convert output
      accumulation in the code-generating visitor classes.  Helper functions
      outside these classes are not converted.
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20180211093607.27351-20-armbru@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarc-André Lureau <marcandre.lureau@redhat.com>
      Reviewed-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      [eblake: rebase to earlier guardstart cleanup]
      Signed-off-by: NEric Blake <eblake@redhat.com>
      71b3f045