1. 08 5月, 2015 10 次提交
  2. 06 5月, 2015 30 次提交
    • L
      migration: Split save_zero_page from ram_save_page · e2102428
      Liang Li 提交于
      Split the function save_zero_page from ram_save_page so that we can
      reuse it later.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      e2102428
    • L
      arch_init: Add and free data struct for decompression · 3caf633d
      Liang Li 提交于
      Define the data structure and variables used to do multiple thread
      decompression, and add the code to initialize and free them.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NDr.David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      3caf633d
    • L
      arch_init: Alloc and free data struct for compression · 474ddaf6
      Liang Li 提交于
      Define the data structure and variables used to do multiple thread
      compression, and add the code to initialize and free them.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NDr.David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      474ddaf6
    • L
      qemu-file: Add compression functions to QEMUFile · 44f0eadc
      Liang Li 提交于
      qemu_put_compression_data() compress the data and put it to QEMUFile.
      qemu_put_qemu_file() put the data in the buffer of source QEMUFile to
      destination QEMUFile.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      44f0eadc
    • L
      migration: Add the framework of multi-thread decompression · 3fcb38c2
      Liang Li 提交于
      Add the code to create and destroy the multiple threads those will be
      used to do data decompression. Left some functions empty just to keep
      clearness, and the code will be added later.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NDr.David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      3fcb38c2
    • L
      migration: Add the framework of multi-thread compression · 8706d2d5
      Liang Li 提交于
      Add the code to create and destroy the multiple threads those will
      be used to do data compression. Left some functions empty to keep
      clearness, and the code will be added later.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NDr.David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      8706d2d5
    • L
      docs: Add a doc about multiple thread compression · 263170e6
      Liang Li 提交于
      Give some details about the multiple thread (de)compression and
      how to use it in live migration.
      Signed-off-by: NLiang Li <liang.z.li@intel.com>
      Signed-off-by: NYang Zhang <yang.z.zhang@intel.com>
      Reviewed-by: NDr.David Alan Gilbert <dgilbert@redhat.com>
      Reviewed-by: NJuan Quintela <quintela@redhat.com>
      Signed-off-by: NJuan Quintela <quintela@redhat.com>
      263170e6
    • P
      Merge remote-tracking branch 'remotes/rth/tags/tcg-next-20150505' into staging · 38003aee
      Peter Maydell 提交于
      size reduction merge
      
      # gpg: Signature made Wed May  6 00:21:43 2015 BST using RSA key ID 4DD0279B
      # gpg: Good signature from "Richard Henderson <rth7680@gmail.com>"
      # gpg:                 aka "Richard Henderson <rth@redhat.com>"
      # gpg:                 aka "Richard Henderson <rth@twiddle.net>"
      
      * remotes/rth/tags/tcg-next-20150505:
        tcg: optimise memory layout of TCGTemp
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      38003aee
    • P
      Merge remote-tracking branch 'remotes/armbru/tags/pull-qmp-2015-05-05' into staging · 233353ec
      Peter Maydell 提交于
      drop qapi nested structs
      
      # gpg: Signature made Tue May  5 17:40:40 2015 BST using RSA key ID EB918653
      # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
      # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
      
      * remotes/armbru/tags/pull-qmp-2015-05-05: (40 commits)
        qapi: Check for member name conflicts with a base class
        qapi: Support (subset of) \u escapes in strings
        qapi: Tweak doc references to QMP when QGA is also meant
        qapi: Drop dead visitor code related to nested structs
        qapi: Drop support for inline nested types
        qapi: Drop inline nested structs in query-pci
        qapi: Drop inline nested struct in query-version
        qapi: Drop tests for inline nested structs
        qapi: Merge UserDefTwo and UserDefNested in tests
        qapi: Forbid 'type' in schema
        qapi: Use 'struct' instead of 'type' in schema
        qapi: Document 'struct' metatype
        qapi: Prefer 'struct' over 'type' in generator
        qapi: More rigorous checking for type safety bypass
        qapi: Whitelist commands that don't return dictionary
        qapi: Require valid names
        qapi: More rigourous checking of types
        qapi: Add some type check tests
        qapi: Unify type bypass and add tests
        qapi: Allow true, false and null in schema json
        ...
      Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
      233353ec
    • E
      qapi: Check for member name conflicts with a base class · ff55d72e
      Eric Blake 提交于
      Our type inheritance for both 'struct' and for flat 'union' merges
      key/value pairs from the base class with those from the type in
      question.  Although the C code currently boxes things so that there
      is a distinction between which member is referred to, the QMP wire
      format does not allow passing a key more than once in a single
      object.  Besides, if we ever change the generated C code to not be
      quite so boxy, we'd want to avoid duplicate member names there,
      too.
      
      Fix a testsuite entry added in an earlier patch, as well as adding
      a couple more tests to ensure we have appropriate coverage.  Ensure
      that collisions are detected, regardless of whether there is a
      difference in opinion on whether the member name is optional.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      ff55d72e
    • E
      qapi: Support (subset of) \u escapes in strings · a7f5966b
      Eric Blake 提交于
      The handling of \ inside QAPI strings was less than ideal, and
      really only worked JSON's \/, \\, \", and our extension of \'
      (an obvious extension, when you realize we use '' instead of ""
      for strings).  For other things, like '\n', it resulted in a
      literal 'n' instead of a newline.
      
      Of course, at the moment, we really have no use for escaped
      characters, as QAPI has to map to C identifiers, and we currently
      support ASCII only for that.  But down the road, we may add
      support for default values for string parameters to a command
      or struct; if that happens, it would be nice to correctly support
      all JSON escape sequences, such as \n or \uXXXX.  This gets us
      closer, by supporting Unicode escapes in the ASCII range.
      
      Since JSON does not require \OCTAL or \xXX escapes, and our QMP
      implementation does not understand them either, I intentionally
      reject it here, but it would be an easy addition if we desired it.
      Likewise, intentionally refusing the NUL byte means we don't have
      to worry about C strings being shorter than the qapi input.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      a7f5966b
    • E
      qapi: Tweak doc references to QMP when QGA is also meant · 363b4262
      Eric Blake 提交于
      We have more than one qapi schema in use by more than one protocol.
      Add a new term 'Client JSON Protocol' for use throughout the
      document, to avoid confusion on whether something refers only to
      QMP and not QGA.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      363b4262
    • E
      qapi: Drop dead visitor code related to nested structs · a82b982e
      Eric Blake 提交于
      Now that we no longer have nested structs to visit, the use of
      prefix strings is no longer required.  Remove the code that is
      no longer reachable.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      a82b982e
    • E
      qapi: Drop support for inline nested types · 6b5abc7d
      Eric Blake 提交于
      A future patch will be using a 'name':{dictionary} entry in the
      QAPI schema to specify a default value for an optional argument
      (see previous commit messages for more details why); but existing
      use of inline nested structs conflicts with that goal. Now that
      all commands have been changed to avoid inline nested structs,
      nuke support for them, and turn it into a hard error. Update the
      testsuite to reflect tighter parsing rules.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      6b5abc7d
    • E
      qapi: Drop inline nested structs in query-pci · 9fa02cd1
      Eric Blake 提交于
      A future patch will be using a 'name':{dictionary} entry in the
      QAPI schema to specify a default value for an optional argument
      (see previous commit message for more details why); but existing
      use of inline nested structs conflicts with that goal. This patch
      fixes one of only two commands relying on nested types, by
      breaking the nesting into an explicit type; it means that the
      type is now boxed instead of unboxed in C code, but the QMP wire
      format is unaffected by this change.
      
      Prefer the safer g_new0() while making the conversion, and reduce
      some long lines.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      9fa02cd1
    • E
      qapi: Drop inline nested struct in query-version · 4752cdbb
      Eric Blake 提交于
      A future patch will be using a 'name':{dictionary} entry in the
      QAPI schema to specify a default value for an optional argument
      (see previous commit message for more details why); but existing
      use of inline nested structs conflicts with that goal. This patch
      fixes one of only two commands relying on nested types, by
      breaking the nesting into an explicit type; it means that the
      type is now boxed instead of unboxed in C code, but the QMP wire
      format is unaffected by this change.
      
      Prefer the safer g_new0() while making the conversion.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      4752cdbb
    • E
      qapi: Drop tests for inline nested structs · 6446a592
      Eric Blake 提交于
      A future patch will be using a 'name':{dictionary} entry in the
      QAPI schema to specify a default value for an optional argument;
      but existing use of inline nested structs conflicts with that goal.
      
      More precisely, a definition in the QAPI schema associates a name
      with a set of properties:
      
      Example 1: { 'struct': 'Foo', 'data': { MEMBERS... } }
      associates the global name 'Foo' with properties (meta-type struct)
      and MEMBERS...
      
      Example 2: 'mumble': TYPE
      within MEMBERS... above associates 'mumble' with properties (type
      TYPE) and (optional false) within type Foo
      
      The syntax of example 1 is extensible; if we need another property,
      we add another name/value pair to the dictionary (such as
      'base':TYPE).  The syntax of example 2 is not extensible, because
      the right hand side can only be a type.
      
      We have used name encoding to add a property: "'*mumble': 'int'"
      associates 'mumble' with (type int) and (optional true).  Nice,
      but doesn't scale.  So the solution is to change our existing uses
      to be syntactic sugar to an extensible form:
      
         NAME: TYPE   --> NAME:  { 'type': TYPE, 'optional': false }
         *ONAME: TYPE --> ONAME: { 'type': TYPE, 'optional': true }
      
      This patch fixes the testsuite to avoid inline nested types, by
      breaking the nesting into explicit types; it means that the type
      is now boxed instead of unboxed in C code, but makes no difference
      on the wire (and if desired, a later patch could change the
      generator to not do so much boxing in C).  When touching code to
      add new allocations, also convert existing allocations to
      consistently prefer typesafe g_new0 over g_malloc0 when a type
      name is involved.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      6446a592
    • E
      qapi: Merge UserDefTwo and UserDefNested in tests · b6fcf32d
      Eric Blake 提交于
      In the testsuite, UserDefTwo and UserDefNested were identical
      structs other than the member names.  Reduce code duplication by
      having just one type, and choose names that also favor reuse.
      This will also make it easier for a later patch to get rid of
      inline nested types in QAPI.  When touching code related to
      allocations, convert g_malloc0(sizeof(Type)) to the more typesafe
      g_new0(Type, 1).
      
      Ensure that 'make check-qapi-schema check-unit' still passes.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      b6fcf32d
    • E
      qapi: Forbid 'type' in schema · 3e391d35
      Eric Blake 提交于
      Referring to "type" as both a meta-type (built-in, enum, union,
      alternate, or struct) and a specific type (the name that the
      schema uses for declaring structs) is confusing.  Finish up the
      conversion to using "struct" in qapi schema by removing the hack
      in the generator that allowed 'type'.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      3e391d35
    • E
      qapi: Use 'struct' instead of 'type' in schema · 895a2a80
      Eric Blake 提交于
      Referring to "type" as both a meta-type (built-in, enum, union,
      alternate, or struct) and a specific type (the name that the
      schema uses for declaring structs) is confusing.  Do the bulk of
      the conversion to "struct" in qapi schema, with a fairly
      mechanical:
      
      for f in `find -name '*.json'; do sed -i "s/'type'/'struct'/"; done
      
      followed by manually filtering out the places where we have a
      'type' embedded in 'data'.  Then tweak a couple of tests whose
      output changes slightly due to longer lines.
      
      I also verified that the generated files for QMP and QGA (such
      as qmp-commands.h) are the same before and after, as assurance
      that I didn't leave in any accidental member name changes.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      895a2a80
    • E
      qapi: Document 'struct' metatype · 3b2a8b85
      Eric Blake 提交于
      Referring to "type" as both a meta-type (built-in, enum, union,
      alternate, or struct) and a specific type (the name that the
      schema uses for declaring structs) is confusing.  Now that the
      generator accepts 'struct' as a synonym for 'type', update all
      documentation to use saner wording.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      3b2a8b85
    • E
      qapi: Prefer 'struct' over 'type' in generator · fd41dd4e
      Eric Blake 提交于
      Referring to "type" as both a meta-type (built-in, enum, union,
      alternate, or struct) and a specific type (the name that the
      schema uses for declaring structs) is confusing.  The confusion
      is only made worse by the fact that the generator mostly already
      refers to struct even when dealing with expr['type'].  This
      commit changes the generator to consistently refer to it as
      struct everywhere, plus a single back-compat tweak that allows
      accepting the existing .json files as-is, so that the meat of
      this change is separate from the mindless churn of that change.
      
      Fix the testsuite fallout for error messages that change, and
      in some cases, become more legible.  Improve comments to better
      match our intentions where a struct (rather than any complex
      type) is required.  Note that in some cases, an error message
      now refers to 'struct' while the schema still refers to 'type';
      that will be cleaned up in the later commit to the schema.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      fd41dd4e
    • E
      qapi: More rigorous checking for type safety bypass · 2cbf0992
      Eric Blake 提交于
      Now that we have a way to validate every type, we can also be
      stricter about enforcing that callers that want to bypass
      type safety in generated code.  Prior to this patch, it didn't
      matter what value was associated with the key 'gen', but it
      looked odd that 'gen':'yes' could result in bypassing the
      generated code.  These changes also enforce the changes made
      earlier in the series for documentation and consolidation of
      using '**' as the wildcard type, as well as 'gen':false as the
      canonical spelling for requesting type bypass.
      
      Note that 'gen':false is a one-way switch away from the default;
      we do not support 'gen':true (similar for 'success-response').
      In practice, this doesn't matter.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      2cbf0992
    • E
      qapi: Whitelist commands that don't return dictionary · 10d4d997
      Eric Blake 提交于
      ...or an array of dictionaries.  Although we have to cater to
      existing commands, returning a non-dictionary means the command
      is not extensible (no new name/value pairs can be added if more
      information must be returned in parallel).  By making the
      whitelist explicit, any new command that falls foul of this
      practice will have to be self-documenting, which will encourage
      developers to either justify the action or rework the design to
      use a dictionary after all.
      
      It's a little bit sloppy that we share a single whitelist among
      three clients (it's too permissive for each).  If this is a
      problem, a future patch could tighten things by having the
      generator take the whitelist as an argument (as in
      scripts/qapi-commands.py --legacy-returns=...), or by having
      the generator output C code that requires explicit use of the
      whitelist (as in:
       #ifndef FROBNICATE_LEGACY_RETURN_OK
       # error Command 'frobnicate' should return a dictionary
       #endif
      then having the callers define appropriate macros).  But until
      we need such fine-grained separation (if ever), this patch does
      the job just fine.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      10d4d997
    • E
      qapi: Require valid names · c9e0a798
      Eric Blake 提交于
      Previous commits demonstrated that the generator overlooked various
      bad naming situations:
      - types, commands, and events need a valid name
      - enum members must be valid names, when combined with prefix
      - union and alternate branches cannot be marked optional
      
      Valid upstream names match [a-zA-Z][a-zA-Z0-9_-]*; valid downstream
      names match __[a-zA-Z][a-zA-Z0-9._-]*.  Enumerations match the
      weaker [a-zA-Z0-9._-]+ (in part thanks to QKeyCode picking an enum
      that starts with a digit, which we can't change now due to
      backwards compatibility).  Rather than call out three separate
      regex, this patch just uses a broader combination that allows both
      upstream and downstream names, as well as a small hack that
      realizes that any enum name is merely a suffix to an already valid
      name prefix (that is, any enum name is valid if prepending _ fits
      the normal rules).
      
      We could reject new enumeration names beginning with a digit by
      whitelisting existing exceptions.  We could also be stricter
      about the distinction between upstream names (no leading
      underscore, no use of dot) and downstream (mandatory leading
      double underscore), but it is probably not worth the bother.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      c9e0a798
    • E
      qapi: More rigourous checking of types · dd883c6f
      Eric Blake 提交于
      Now that we know every expression is valid with regards to
      its keys, we can add further tests that those keys refer to
      valid types.  With this patch, all uses of a type (the 'data':
      of command, type, union, alternate, and event; the 'returns':
      of command; the 'base': of type and union) must resolve to an
      appropriate subset of metatypes  declared by the current qapi
      parse; this includes recursing into each member of a data
      dictionary.  Dealing with '**' and nested anonymous structs
      will be done in later patches.
      
      Update the testsuite to match improved output.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      dd883c6f
    • E
      qapi: Add some type check tests · 0d8b9fb5
      Eric Blake 提交于
      Demonstrate that the qapi generator silently parses confusing
      types, which may cause other errors later on. Later patches
      will update the expected results as the generator is made stricter.
      
      Most of the new tests focus on blatant errors.  But
      returns-whitelist is a case where we have historically allowed
      returning something other than a JSON object from particular
      commands; we have to keep that behavior to avoid breaking clients,
      but it would be nicer to avoid adding such commands in the future,
      because any return that is not an (array of) object cannot be
      easily extended if future qemu wants to return additional
      information.  The QMP protocol already documents that clients
      should ignore unknown dictionary keys, but does not require
      clients to have to handle more than one type of JSON object.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      0d8b9fb5
    • E
      qapi: Unify type bypass and add tests · d708cdbe
      Eric Blake 提交于
      For a few QMP commands, we are forced to pass an arbitrary type
      without tracking it properly in QAPI.  Among the existing clients,
      this unnamed type was spelled 'dict', 'visitor', and '**'; this
      patch standardizes on '**', matching the documentation changes
      earlier in the series.
      
      Meanwhile, for the 'gen' key, we have been ignoring the value,
      although the schema consistently used "'no'" ('success-response'
      was hard-coded to checking for 'no').  But now that we can support
      a literal "false" in the schema, we might as well use that rather
      than ignoring the value or special-casing a random string.  Note
      that these are one-way switches (use of 'gen':true is not the same
      as omitting 'gen'). Also, the use of '**' requires 'gen':false,
      but the use of 'gen':false does not mandate the use of '**'.
      
      There is no difference to the generated code.  Add some tests on
      what we'd like to guarantee, although it will take later patches
      to clean up test results and actually enforce the use of a bool
      parameter.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      d708cdbe
    • F
      qapi: Allow true, false and null in schema json · e53188ad
      Fam Zheng 提交于
      In the near term, we will use it for a sensible-looking
      'gen':false inside command declarations, instead of the
      current ugly 'gen':'no'.
      
      In the long term, it will allow conversion from shorthand
      with defaults mentioned only in side-band documentation:
       'data':{'*flag':'bool', '*string':'str'}
      into an explicit default value documentation, as in:
       'data':{'flag':{'type':'bool', 'optional':true, 'default':true},
               'string':{'type':'str', 'optional':true, 'default':null}}
      
      We still don't parse integer values (also necessary before
      we can allow explicit defaults), but that can come in a later
      series.
      
      Update the testsuite to match an improved error message.
      Signed-off-by: NFam Zheng <famz@redhat.com>
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      e53188ad
    • E
      qapi: Better error messages for duplicated expressions · 4dc2e690
      Eric Blake 提交于
      The previous commit demonstrated that the generator overlooked
      duplicate expressions:
      - a complex type or command reusing a built-in type name
      - redeclaration of a type name, whether by the same or different
      metatype
      - redeclaration of a command or event
      - collision of a type with implicit 'Kind' enum for a union
      - collision with an implicit MAX enum constant
      
      Since the c_type() function in the generator treats all names
      as being in the same namespace, this patch adds a global array
      to track all known names and their source, to prevent collisions
      before it can cause further problems.  While valid .json files
      won't trigger any of these cases, we might as well be nicer to
      developers that make a typo while trying to add new QAPI code.
      Signed-off-by: NEric Blake <eblake@redhat.com>
      Reviewed-by: NMarkus Armbruster <armbru@redhat.com>
      Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
      4dc2e690