1. 16 Mar, 2017 3 commits
    • Markus Armbruster's avatar
      qapi2texi: Implement boxed argument documentation · c2dd311c
      Markus Armbruster authored
      This replaces manual references like "For the arguments, see the
      documentation of ..." by a generated reference "Arguments: the members
      of ...".
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1489582656-31133-25-git-send-email-armbru@redhat.com>
      c2dd311c
    • Markus Armbruster's avatar
      qapi: The #optional tag is redundant, drop · 1d8bda12
      Markus Armbruster authored
      We traditionally mark optional members #optional in the doc comment.
      Before commit 3313b612, this was entirely manual.
      
      Commit 3313b612 added some automation because its qapi2texi.py relied
      on #optional to determine whether a member is optional.  This is no
      longer the case since the previous commit: the only thing qapi2texi.py
      still does with #optional is stripping it out.  We still reject bogus
      qapi-schema.json and six places for qga/qapi-schema.json.
      
      Thus, you can't actually rely on #optional to see whether something is
      optional.  Yet we still make people add it manually.  That's just
      busy-work.
      
      Drop the code to check, fix up and strip out #optional, along with all
      instances of #optional.  To keep it out, add code to reject it, to be
      dropped again once the dust settles.
      
      No change to generated documentation.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1489582656-31133-18-git-send-email-armbru@redhat.com>
      1d8bda12
    • Markus Armbruster's avatar
      qapi/rocker: Fix up doc comment notes on optional members · 8c0aa613
      Markus Armbruster authored
      Talking about #optional like this
      
          # Note: fields are marked #optional to indicate that they may or may
          # not appear ...
      
      doesn't work so well in generated documentation, because the #optional
      tag is not visible there.  Replace by
      
          # Note: optional members may or may not appear ...
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarMarc-André Lureau <marcandre.lureau@redhat.com>
      Message-Id: <1489582656-31133-13-git-send-email-armbru@redhat.com>
      8c0aa613
  2. 13 Mar, 2017 1 commit
  3. 07 Mar, 2017 9 commits
    • Markus Armbruster's avatar
      keyval: Support lists · 0b2c1bee
      Markus Armbruster authored
      Additionally permit non-negative integers as key components.  A
      dictionary's keys must either be all integers or none.  If all keys
      are integers, convert the dictionary to a list.  The set of keys must
      be [0,N].
      
      Examples:
      
      * list.1=goner,list.0=null,list.1=eins,list.2=zwei
        is equivalent to JSON [ "null", "eins", "zwei" ]
      
      * a.b.c=1,a.b.0=2
        is inconsistent: a.b.c clashes with a.b.0
      
      * list.0=null,list.2=eins,list.2=zwei
        has a hole: list.1 is missing
      
      Similar design flaw as for objects: there is no way to denote an empty
      list.  While interpreting "key absent" as empty list seems natural
      (removing a list member from the input string works when there are
      multiple ones, so why not when there's just one), it doesn't work:
      "key absent" already means "optional list absent", which isn't the
      same as "empty list present".
      
      Update the keyval object visitor to use this a.0 syntax in error
      messages rather than the usual a[0].
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1488317230-26248-25-git-send-email-armbru@redhat.com>
      [Off-by-one fix squashed in, as per Kevin's review]
      Reviewed-by: 's avatarKevin Wolf <kwolf@redhat.com>
      0b2c1bee
    • Markus Armbruster's avatar
      qapi: Improve how keyval input visitor reports unexpected dicts · 31478f26
      Markus Armbruster authored
      Incorrect option
      
          -blockdev node-name=foo,driver=file,filename=foo.img,aio.unmap=on
      
      is rejected with "Invalid parameter type for 'aio', expected: string".
      To make sense of this, you almost have to translate it into the
      equivalent QMP command
      
          { "execute": "blockdev-add", "arguments": { "node-name": "foo", "driver": "file", "filename": "foo.img", "aio": { "unmap": true } } }
      
      Improve the error message to "Parameters 'aio.*' are unexpected".
      Take care not to confuse the case "unexpected nested parameters"
      (i.e. the object is a QDict or QList) with the case "non-string scalar
      parameter".  The latter is a misuse of the visitor, and should perhaps
      be an assertion.  Note that test-qobject-input-visitor exercises this
      misuse in test_visitor_in_int_keyval(), test_visitor_in_bool_keyval()
      and test_visitor_in_number_keyval().
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <1488317230-26248-23-git-send-email-armbru@redhat.com>
      31478f26
    • Markus Armbruster's avatar
      qapi: New qobject_input_visitor_new_str() for convenience · 9d1eab4b
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1488317230-26248-21-git-send-email-armbru@redhat.com>
      9d1eab4b
    • Markus Armbruster's avatar
      qapi: New parse_qapi_name() · 069b64e3
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488317230-26248-19-git-send-email-armbru@redhat.com>
      069b64e3
    • Markus Armbruster's avatar
      qapi: Factor out common qobject_input_get_keyval() · e3934b42
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488317230-26248-8-git-send-email-armbru@redhat.com>
      e3934b42
    • Markus Armbruster's avatar
      qapi: Factor out common part of qobject input visitor creation · abe81bc2
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <1488317230-26248-7-git-send-email-armbru@redhat.com>
      abe81bc2
    • Daniel P. Berrange's avatar
      qapi: qobject input visitor variant for use with keyval_parse() · cbd8acf3
      Daniel P. Berrange authored
      Currently the QObjectInputVisitor assumes that all scalar values are
      directly represented as the final types declared by the thing being
      visited. i.e. it assumes an 'int' is using QInt, and a 'bool' is using
      QBool, etc.  This is good when QObjectInputVisitor is fed a QObject
      that came from a JSON document on the QMP monitor, as it will strictly
      validate correctness.
      
      To allow QObjectInputVisitor to be reused for visiting a QObject
      originating from keyval_parse(), an alternative mode is needed where
      all the scalars types are represented as QString and converted on the
      fly to the final desired type.
      Signed-off-by: 's avatarDaniel P. Berrange <berrange@redhat.com>
      Message-Id: <1475246744-29302-8-git-send-email-berrange@redhat.com>
      
      Rebased, conflicts resolved, commit message updated to refer to
      keyval_parse().  autocast replaced by keyval in identifiers,
      noautocast replaced by fail in tests.
      
      Fix qobject_input_type_uint64_keyval() not to reject '-', for QemuOpts
      compatibility: replace parse_uint_full() by open-coded
      parse_option_number().  The next commit will add suitable tests.
      Leave out the fancy ERANGE error reporting for now, but add a TODO
      comment.  Add it qobject_input_type_int64_keyval() and
      qobject_input_type_number_keyval(), too.
      
      Open code parse_option_bool() and parse_option_size() so we have to
      call qobject_input_get_name() only when actually needed.  Again, leave
      out ERANGE error reporting for now.
      
      QAPI/QMP downstream extension prefixes __RFQDN_ don't work, because
      keyval_parse() splits them at '.'.  This will be addressed later in
      the series.
      
      qobject_input_type_int64_keyval(), qobject_input_type_uint64_keyval(),
      qobject_input_type_number_keyval() tweaked for style.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarKevin Wolf <kwolf@redhat.com>
      Message-Id: <1488317230-26248-5-git-send-email-armbru@redhat.com>
      cbd8acf3
    • Markus Armbruster's avatar
      sheepdog: Support blockdev-add · d282f34e
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      d282f34e
    • Markus Armbruster's avatar
      qapi-schema: Rename GlusterServer to SocketAddressFlat · 2b733709
      Markus Armbruster authored
      As its documentation says, it's not specific to Gluster.  Rename it,
      as I'm going to use it for something else.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Signed-off-by: 's avatarKevin Wolf <kwolf@redhat.com>
      2b733709
  4. 05 Mar, 2017 13 commits
    • Markus Armbruster's avatar
      qapi: Fix object input visit beyond end of list · 1f41a645
      Markus Armbruster authored
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-28-git-send-email-armbru@redhat.com>
      1f41a645
    • Markus Armbruster's avatar
      qapi: Make input visitors detect unvisited list tails · a4a1c70d
      Markus Armbruster authored
      Fix the design flaw demonstrated in the previous commit: new method
      check_list() lets input visitors report that unvisited input remains
      for a list, exactly like check_struct() lets them report that
      unvisited input remains for a struct or union.
      
      Implement the method for the qobject input visitor (straightforward),
      and the string input visitor (less so, due to the magic list syntax
      there).  The opts visitor's list magic is even more impenetrable, and
      all I can do there today is a stub with a FIXME comment.  No worse
      than before.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1488544368-30622-26-git-send-email-armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      a4a1c70d
    • Markus Armbruster's avatar
      qapi: Drop unused non-strict qobject input visitor · 048abb7b
      Markus Armbruster authored
      The split between tests/test-qobject-input-visitor.c and
      tests/test-qobject-input-strict.c now makes less sense than ever.  The
      next commit will take care of that.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-20-git-send-email-armbru@redhat.com>
      048abb7b
    • Markus Armbruster's avatar
      qapi: Make string input and opts visitor require non-null input · f332e830
      Markus Armbruster authored
      The string input visitor tries to cope with null input.  Null input
      isn't used anywhere, and isn't covered by tests.  Unsurprisingly, it
      doesn't fully work: start_list() crashes because it passes the input
      via parse_str() to strtoll() unchecked.
      
      Make string_input_visitor_new() assert its argument isn't null, and
      drop the code trying to deal with null input.
      
      The opts visitor crashes when you try to actually visit something with
      null input.  Make opts_visitor_new() assert its argument isn't null,
      mostly for clarity.
      
      qobject_input_visitor_new() already asserts its argument isn't null.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-17-git-send-email-armbru@redhat.com>
      f332e830
    • Markus Armbruster's avatar
      qapi: Drop string input visitor method optional() · a8aec6de
      Markus Armbruster authored
      visit_optional() is to be called only between visit_start_struct() and
      visit_end_struct().  Visitors that don't support struct visits,
      i.e. don't implement start_struct(), end_struct(), have no use for it.
      Clarify documentation.
      
      The string input visitor doesn't support struct visits.  Its
      parse_optional() is therefore useless.  Drop it.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-16-git-send-email-armbru@redhat.com>
      a8aec6de
    • Markus Armbruster's avatar
      qapi: Improve qobject input visitor error reporting · a9fc37f6
      Markus Armbruster authored
      Error messages refer to nodes of the QObject being visited by name.
      Trouble is the names are sometimes less than helpful:
      
      * The name of the root QObject is whatever @name argument got passed
        to the visitor, except NULL gets mapped to "null".  We commonly pass
        NULL.  Not good.
      
        Avoiding errors "at the root" mitigates.  For instance,
        visit_start_struct() can only fail when the visited object is not a
        dictionary, and we commonly ensure it is beforehand.
      
      * The name of a QDict's member is the member key.  Good enough only
        when this happens to be unique.
      
      * The name of a QList's member is "null".  Not good.
      
      Improve error messages by referring to nodes by path instead, as
      follows:
      
      * The path of the root QObject is whatever @name argument got passed
        to the visitor, except NULL gets mapped to "<anonymous>".
      
      * The path of a root QDict's member is the member key.
      
      * The path of a root QList's member is "[%u]", where %u is the list
        index, starting at zero.
      
      * The path of a non-root QDict's member is the path of the QDict
        concatenated with "." and the member key.
      
      * The path of a non-root QList's member is the path of the QList
        concatenated with "[%u]", where %u is the list index.
      
      For example, the incorrect QMP command
      
          { "execute": "blockdev-add", "arguments": { "node-name": "foo", "driver": "raw", "file": {"driver": "file" } } }
      
      now fails with
      
          {"error": {"class": "GenericError", "desc": "Parameter 'file.filename' is missing"}}
      
      instead of
      
          {"error": {"class": "GenericError", "desc": "Parameter 'filename' is missing"}}
      
      and
      
          { "execute": "input-send-event", "arguments": { "device": "bar", "events": [ [] ] } }
      
      now fails with
      
          {"error": {"class": "GenericError", "desc": "Invalid parameter type for 'events[0]', expected: object"}}
      
      instead of
      
          {"error": {"class": "GenericError", "desc": "Invalid parameter type for 'null', expected: QDict"}}
      
      Aside: calling the thing "parameter" is suboptimal for QMP, because
      the root object is "arguments" there.
      
      The qobject output visitor doesn't have this problem because it should
      not fail.  Same for dealloc and clone visitors.
      
      The string visitors don't have this problem because they visit just
      one value, whose name needs to be passed to the visitor as @name.  The
      string output visitor shouldn't fail anyway.
      
      The options visitor uses QemuOpts names.  Their name space is flat, so
      the use of QDict member keys as names is fine.  NULL names used with
      roots and lists could conceivably result in bad error messages.  Left
      for another day.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-15-git-send-email-armbru@redhat.com>
      a9fc37f6
    • Markus Armbruster's avatar
      qapi: Make QObject input visitor set *list reliably · 58561c27
      Markus Armbruster authored
      qobject_input_start_struct() sets *list, except when it fails because
      qobject_input_get_object() fails, i.e. the input object doesn't exist.
      
      All the other input visitor start_struct(), start_list(),
      start_alternate() always set *obj / *list.
      
      Change qobject_input_start_struct() to match.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-14-git-send-email-armbru@redhat.com>
      Reviewed-by: 's avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
      58561c27
    • Markus Armbruster's avatar
      qapi: Clean up after commit 3d344c2a · b8874fbf
      Markus Armbruster authored
      Drop unused QIV_STACK_SIZE and unused qobject_input_start_struct()
      parameter errp.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-13-git-send-email-armbru@redhat.com>
      b8874fbf
    • Markus Armbruster's avatar
      qapi: Improve a QObject input visitor error message · 910f738b
      Markus Armbruster authored
      The QObject input visitor has three error message formats:
      
      * Parameter '%s' is missing
      * "Invalid parameter type for '%s', expected: %s"
      * "QMP input object member '%s' is unexpected"
      
      The '%s' are member names (or "null", but I'll fix that later).
      
      The last error message calls the thing "QMP input object member"
      instead of "parameter".  Misleading when the visitor is used on
      QObjects that don't come from QMP.  Change it to "Parameter '%s' is
      unexpected".
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-12-git-send-email-armbru@redhat.com>
      910f738b
    • Markus Armbruster's avatar
      qmp: Eliminate silly QERR_QMP_* macros · 99fb0c53
      Markus Armbruster authored
      The QERR_ macros are leftovers from the days of "rich" error objects.
      
      QERR_QMP_BAD_INPUT_OBJECT, QERR_QMP_BAD_INPUT_OBJECT_MEMBER,
      QERR_QMP_EXTRA_MEMBER are used in just one place now, except for one
      use that has crept into qobject-input-visitor.c.
      
      Drop these macros, to make the (bad) error messages more visible.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-10-git-send-email-armbru@redhat.com>
      99fb0c53
    • Markus Armbruster's avatar
      qmp: Drop duplicated QMP command object checks · 104fc302
      Markus Armbruster authored
      qmp_check_input_obj() duplicates qmp_dispatch_check_obj(), except the
      latter screws up an error message.  handle_qmp_command() runs first
      the former, then the latter via qmp_dispatch(), masking the screwup.
      
      qemu-ga also masks the screwup, because it also duplicates checks,
      just differently.
      
      qmp_check_input_obj() exists because handle_qmp_command() needs to
      examine the command before dispatching it.  The previous commit got
      rid of this need, except for a tracepoint, and a bit of "id" code that
      relies on qdict not being null.
      
      Fix up the error message in qmp_dispatch_check_obj(), drop
      qmp_check_input_obj() and the tracepoint.  Protect the "id" code with
      a conditional.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-9-git-send-email-armbru@redhat.com>
      104fc302
    • Markus Armbruster's avatar
      qapi: Support multiple command registries per program · 1527badb
      Markus Armbruster authored
      The command registry encapsulates a single command list.  Give the
      functions using it a parameter instead.  Define suitable command lists
      in monitor, guest agent and test-qmp-commands.
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <1488544368-30622-6-git-send-email-armbru@redhat.com>
      [Debugging turds buried]
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      1527badb
    • Markus Armbruster's avatar
      qga: Fix crash on non-dictionary QMP argument · 74d8c9d9
      Markus Armbruster authored
      The value of key 'arguments' must be a JSON object.  qemu-ga neglects
      to check, and crashes.  To reproduce, send
      
          { 'execute': 'guest-sync', 'arguments': [] }
      
      to qemu-ga.
      
      do_qmp_dispatch() uses qdict_get_qdict() to get the arguments.  When
      not a JSON object, this gets a null pointer, which flows through the
      generated marshalling function to qobject_input_visitor_new(), where
      it fails the assertion.  qmp_dispatch_check_obj() needs to catch this
      error.
      
      QEMU isn't affected, because it runs qmp_check_input_obj() first,
      which basically duplicates qmp_dispatch_check_obj()'s checks, plus the
      missing one.
      
      Fix by copying the missing one from qmp_check_input_obj() to
      qmp_dispatch_check_obj().
      Signed-off-by: 's avatarMarkus Armbruster <armbru@redhat.com>
      Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
      Reviewed-by: 's avatarEric Blake <eblake@redhat.com>
      Message-Id: <1488544368-30622-2-git-send-email-armbru@redhat.com>
      74d8c9d9
  5. 03 Mar, 2017 1 commit
  6. 02 Mar, 2017 1 commit
  7. 28 Feb, 2017 4 commits
  8. 23 Feb, 2017 4 commits
  9. 22 Feb, 2017 1 commit
  10. 21 Feb, 2017 2 commits
  11. 16 Feb, 2017 1 commit