1. 05 1月, 2015 1 次提交
    • M
      qapi: add visit_start_union and visit_end_union · 96c6cf6d
      Michael Roth 提交于
      In some cases an input visitor might bail out on filling out a
      struct for various reasons, such as missing fields when running
      in strict mode. In the case of a QAPI Union type, this may lead
      to cases where the .kind field which encodes the union type
      is uninitialized. Subsequently, other visitors, such as the
      dealloc visitor, may use this .kind value as if it were
      initialized, leading to assumptions about the union type which
      in this case may lead to segfaults. For example, freeing an
      integer value.
      
      However, we can generally rely on the fact that the always-present
      .data void * field that we generate for these union types will
      always be NULL in cases where .kind is uninitialized (at least,
      there shouldn't be a reason where we'd do this purposefully).
      
      So pass this information on to Visitor implementation via these
      optional start_union/end_union interfaces so this information
      can be used to guard against the situation above. We will make
      use of this information in a subsequent patch for the dealloc
      visitor.
      
      Cc: qemu-stable@nongnu.org
      Reported-by: NFam Zheng <famz@redhat.com>
      Suggested-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NPaolo Bonzini <pbonzini@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NLuiz Capitulino <lcapitulino@redhat.com>
      (cherry picked from commit cee2dedb)
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      96c6cf6d
  2. 23 6月, 2014 1 次提交
  3. 16 5月, 2014 6 次提交
  4. 09 5月, 2014 1 次提交
  5. 11 3月, 2014 2 次提交
  6. 04 3月, 2014 3 次提交
  7. 11 11月, 2013 1 次提交
  8. 11 10月, 2013 2 次提交
  9. 27 7月, 2013 4 次提交
    • K
      qapi: Anonymous unions · 69dd62df
      Kevin Wolf 提交于
      The discriminator for anonymous unions is the data type. This allows to
      have a union type that allows both of these:
      
          { 'file': 'my_existing_block_device_id' }
          { 'file': { 'filename': '/tmp/mydisk.qcow2', 'read-only': true } }
      
      Unions like this are specified in the schema with an empty dict as
      discriminator. For this example you could take:
      
          { 'union': 'BlockRef',
            'discriminator': {},
            'data': { 'definition': 'BlockOptions',
                      'reference': 'str' } }
          { 'type': 'ExampleObject',
            'data: { 'file': 'BlockRef' } }
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      69dd62df
    • K
      qapi: Flat unions with arbitrary discriminator · 50f2bdc7
      Kevin Wolf 提交于
      Instead of the rather verbose syntax that distinguishes base and
      subclass fields...
      
        { "type": "file",
          "read-only": true,
          "data": {
              "filename": "test"
          } }
      
      ...we can now have both in the same namespace, allowing a more direct
      mapping of the command line, and moving fields between the common base
      and subclasses without breaking the API:
      
        { "driver": "file",
          "read-only": true,
          "filename": "test" }
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      50f2bdc7
    • K
      qapi-visit.py: Implement 'base' for unions · 0aef92b9
      Kevin Wolf 提交于
      This implements the visitor part of base types for unions. Parsed into
      QMP, this example schema definition...
      
          { 'type': 'BlockOptionsBase', 'data': { 'read-only': 'bool' } }
          { 'type': 'BlockOptionsQcow2, 'data': { 'lazy-refcounts': 'bool' } }
      
          { 'union': 'BlockOptions',
            'base': 'BlockOptionsBase',
            'data': {
                'raw': 'BlockOptionsRaw'
                'qcow2': 'BlockOptionsQcow2'
            } }
      
      ...would describe the following JSON object:
      
          { "type": "qcow2",
            "read-only": true,
            "data": { "lazy-refcounts": false } }
      Signed-off-by: NKevin Wolf <kwolf@redhat.com>
      Reviewed-by: NEric Blake <eblake@redhat.com>
      0aef92b9
    • K
      d131c897
  10. 23 5月, 2013 2 次提交
  11. 19 12月, 2012 2 次提交
  12. 26 9月, 2012 1 次提交
  13. 06 9月, 2012 2 次提交
  14. 23 7月, 2012 1 次提交
    • P
      qapi: fix error propagation · d195325b
      Paolo Bonzini 提交于
      Don't overwrite / leak previously set errors.
      Make traversal cope with missing mandatory sub-structs.
      Don't try to end a container that could not be started.
      
      v1->v2:
      - unchanged
      
      v2->v3:
      - instead of examining, assert that we never overwrite errors with
        error_set()
      - allow visitors to set a NULL struct pointer successfully, so traversal
        of incomplete objects can continue
      - check for a NULL "obj" before accessing "(*obj)->has_XXX" (this is not a
        typo, "obj != NULL" implies "*obj != NULL" here)
      - fix start_struct / end_struct balance for unions as well
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
      d195325b
  15. 27 3月, 2012 4 次提交
  16. 12 3月, 2012 1 次提交
  17. 13 1月, 2012 1 次提交
    • A
      Fix qapi code generation fix · 19bf7c87
      Avi Kivity 提交于
      The fixes to qapi code generation had multiple bugs:
      - the Null class used to drop output was missing some methods
      - in some scripts it was never instantiated, leading to a None return,
        which is missing even more methods
      - the --source and --header options were swapped
      
      Luckily, all those bugs were hidden by a makefile bug which caused the
      old behaviour (with the race) to be invoked.
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      19bf7c87
  18. 27 12月, 2011 1 次提交
    • A
      Fix qapi code generation wrt parallel build · 8d3bc517
      Avi Kivity 提交于
      Make's multiple output syntax
      
        x.c x.h: x.template
             gen < x.template
      
      actually invokes the command once for x.c and once for x.h (with differing $@
      in each invocation).  During a parallel build, the two commands may be invoked
      in parallel; this opens up a race, where the second invocation trashes a file
      supposedly produced during the first, and now in use by a dependent command.
      
      The various qapi code generators are susceptible to this; fix by making them
      generate just one file per invocation.
      Signed-off-by: NAvi Kivity <avi@redhat.com>
      Signed-off-by: NAnthony Liguori <aliguori@us.ibm.com>
      8d3bc517
  19. 04 10月, 2011 1 次提交
  20. 22 7月, 2011 1 次提交
    • M
      qapi: add qapi-visit.py code generator · 06d64c62
      Michael Roth 提交于
      This is the code generator for qapi visiter functions used to
      marshal/unmarshal/dealloc qapi types. It generates the following 2
      files:
      
        $(prefix)qapi-visit.c: visiter function for a particular c type, used
                               to automagically convert qobjects into the
                               corresponding C type and vice-versa, and well
                               as for deallocation memory for an existing C
                               type
      
        $(prefix)qapi-visit.h: declarations for previously mentioned visiter
                               functions
      
      $(prefix) is used as decribed for qapi-types.py
      Signed-off-by: NMichael Roth <mdroth@linux.vnet.ibm.com>
      Signed-off-by: NLuiz Capitulino <lcapitulino@gmail.com>
      06d64c62