Commits on Apr 24, 2023

  1. qapi: Fix error message format regression

    Commit 52a4741 changed reporting of errors connected to a source
    location without mentioning it in the commit message.  For instance,
    
        $ python scripts/qapi-gen.py tests/qapi-schema/unknown-escape.json
        tests/qapi-schema/unknown-escape.json:3:21: unknown escape \x
    
    became
    
        scripts/qapi-gen.py: tests/qapi-schema/unknown-escape.json:3:21: unknown escape \x
    
    This is not how compilers report such errors, and Emacs doesn't
    recognize the format.  Revert this change.
    
    Fixes: 52a4741 (qapi-gen: Separate arg-parsing from generation)
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-2-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    bc5d303 View commit details
    Browse the repository at this point in the history
  2. qapi/schema: Use super()

    Commit 2cae67b (qapi: Use super() now we have Python 3) converted
    the code to super().  Shortly after, commit f965e8f (qapi: New
    special feature flag "deprecated") neglected to use super().  Convert
    it now.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-3-armbru@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    ecee568 View commit details
    Browse the repository at this point in the history
  3. qapi: Clean up after removal of simple unions

    Commit 4e99f4b (qapi: Drop simple unions) missed a bit of code
    dealing with simple union branches.  Drop it.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-4-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    607045b View commit details
    Browse the repository at this point in the history
  4. qapi: Split up check_type()

    check_type() can check type names, arrays, and implicit struct types.
    Callers pass flags to select from this menu.  This makes the function
    somewhat hard to read.  Moreover, a few minor bugs are hiding in
    there, as we'll see shortly.
    
    Split it into check_type_name(), check_type_name_or_array(), and
    check_type_name_or_implicit().  Each of them is a copy of the original
    specialized to a certain set of flags.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-5-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    [Commit message corrected]
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    06cc46e View commit details
    Browse the repository at this point in the history
  5. qapi: Improve error message for unexpected array types

    We reject array types in certain places with "cannot be an array".
    Deleting this check improves the error message to "should be a type
    name" or "should be an object or type name", depending on context, so
    do that.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-6-armbru@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    2a0c975 View commit details
    Browse the repository at this point in the history
  6. qapi: Simplify code a bit after previous commits

    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-7-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    [Commit message corrected]
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    7c40751 View commit details
    Browse the repository at this point in the history
  7. qapi: Fix error message when type name or array is expected

    We incorrectly report "FOO should be a type name" when it could also
    be an array.  Fix that.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-8-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    6f2ab60 View commit details
    Browse the repository at this point in the history
  8. qapi: Fix to reject 'data': 'mumble' in struct

    A struct's 'data' must be a JSON object defining the struct's members.
    The QAPI code generator incorrectly accepts a JSON string instead, and
    then crashes in QAPISchema._make_members() called from
    ._def_struct_type().
    
    Fix to reject it: factor check_type_implicit() out of
    check_type_name_or_implicit(), and switch check_struct() to use it
    instead.  Also add a test case.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-9-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    [More detailed commit message]
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    e2050ef View commit details
    Browse the repository at this point in the history
  9. tests/qapi-schema: Improve union discriminator coverage

    A union's 'discriminator' must name one of the common members.
    QAPISchemaVariants.check() looks it up by its c_name(), then checks
    the name matches exactly (because c_name() is not injective).
    
    Tests union-base-empty and union-invalid-discriminator both cover the
    case where lookup fails.  Repurpose the latter to cover the case where
    it succeeds and the name check fails.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-10-armbru@redhat.com
    Reviewed-by: Eric Blake <eblake@redhat.com>
    [Commit message typo fixed]
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    8fba2f7 View commit details
    Browse the repository at this point in the history
  10. tests/qapi-schema: Rename a few conditionals

    Positive test case
    
        { 'enum': 'TestIfEnum',
          'data': [ 'foo', { 'name' : 'bar', 'if': 'TEST_IF_ENUM_BAR' } ],
          'if': 'TEST_IF_ENUM' }
    
    generates
    
        #if defined(TEST_IF_ENUM)
        typedef enum TestIfEnum {
    	TEST_IF_ENUM_FOO,
        #if defined(TEST_IF_ENUM_BAR)
    	TEST_IF_ENUM_BAR,
        #endif /* defined(TEST_IF_ENUM_BAR) */
    	TEST_IF_ENUM__MAX,
        } TestIfEnum;
    
    Macro TEST_IF_ENUM_BAR clashes with the enumeration constant.
    Wouldn't compile with -DTEST_IF_BAR.
    
    Rename the macro to TEST_IF_ENUM_MEMBER.  For consistency, rename
    similar macros elsewhere as well.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-11-armbru@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    40e350f View commit details
    Browse the repository at this point in the history
  11. tests/qapi-schema: Clean up positive test for conditionals

    Union TestIfUnion is conditional on macros TEST_IF_UNION and
    TEST_IF_STRUCT.  It uses TestIfEnum, which is conditional on macro
    TEST_IF_ENUM.  If TEST_IF_UNION and TEST_IF_STRUCT are defined, but
    TEST_IF_ENUM isn't, the generated code won't compile.
    
    Command test-if-cmd is conditional an macros TEST_IF_CMD and
    TEST_IF_STRUCT, and uses TestIfEnum.  Similar issue.
    
    Event TEST_IF_EVENT is conditional an macros TEST_IF_EVT and
    TEST_IF_STRUCT, and uses TestIfEnum.  Similar issue.
    
    Replace the uses of TestIfEnum in the latter two by str.
    
    TestIfUnion is now TestIfEnum's only user.  Change TestIfEnum's
    condition to TEST_IF_UNION.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-12-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    [Commit message corrected]
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    39d2cc8 View commit details
    Browse the repository at this point in the history
  12. tests/qapi-schema: Cover optional conditional struct member

    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-13-armbru@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    fa32eb9 View commit details
    Browse the repository at this point in the history
  13. qapi: Fix code generated for optional conditional struct member

    The generated member visit neglects to emit #if around a conditional
    struct member's has_ variable.  For instance,
    tests/qapi-schema/qapi-schema-test.json generates
    
        #if defined(TEST_IF_STRUCT)
        bool visit_type_TestIfStruct_members(Visitor *v, TestIfStruct *obj, Error **errp)
        {
    --->	bool has_baz = !!obj->baz;
    
    	if (!visit_type_int(v, "foo", &obj->foo, errp)) {
    	    return false;
    	}
        #if defined(TEST_IF_STRUCT_MEMBER)
    	if (!visit_type_int(v, "bar", &obj->bar, errp)) {
    	    return false;
    	}
        #endif /* defined(TEST_IF_STRUCT_MEMBER) */
        #if defined(TEST_IF_STRUCT_MEMBER)
    	if (visit_optional(v, "baz", &has_baz)) {
    	    if (!visit_type_str(v, "baz", &obj->baz, errp)) {
    		return false;
    	    }
    	}
        #endif /* defined(TEST_IF_STRUCT_MEMBER) */
    	return true;
        }
        [...]
        #endif /* defined(TEST_IF_STRUCT) */
    
    Won't compile when TEST_IF_STRUCT is defined and TEST_IF_STRUCT_MEMBER
    isn't.
    
    Fix that the obvious way:
    
        #if defined(TEST_IF_STRUCT_MEMBER)
    	bool has_baz = !!obj->baz;
        #endif /* defined(TEST_IF_STRUCT_MEMBER) */
    
    Fixes: 44ea9d9 (qapi: Start to elide redundant has_FOO in generated C)
    Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-14-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    713d921 View commit details
    Browse the repository at this point in the history
  14. qapi: Require boxed for conditional command and event arguments

    The C code generator fails to honor 'if' conditions of command and
    event arguments.
    
    For instance, tests/qapi-schema/qapi-schema-test.json has
    
        { 'event': 'TEST_IF_EVENT',
          'data': { 'foo': 'TestIfStruct',
    		'bar': { 'type': ['str'], 'if': 'TEST_IF_EVT_ARG' } },
          'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } }
    
    Generated tests/test-qapi-events.h fails to honor the TEST_IF_EVT_ARG
    condition:
    
        #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
        void qapi_event_send_test_if_event(TestIfStruct *foo, strList *bar);
        #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */
    
    Only uses so far are in tests/.
    
    We could fix the generator to emit something like
    
        #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
        void qapi_event_send_test_if_event(TestIfStruct *foo
        #if defined(TEST_IF_EVT_ARG)
                        , strList *bar
        #endif
                        );
        #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */
    
    Ugly.  Calls become similarly ugly.  Not worth fixing.
    
    Conditional arguments work fine with 'boxed': true, simply because
    complex types with conditional members work fine.  Not worth breaking.
    
    Reject conditional arguments unless boxed.
    
    Move the tests cases covering unboxed conditional arguments out of
    tests/qapi-schema/qapi-schema-test.json.  Cover boxed conditional
    arguments there instead.
    
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Message-Id: <20230316071325.492471-15-armbru@redhat.com>
    Reviewed-by: Eric Blake <eblake@redhat.com>
    Markus Armbruster committed Apr 24, 2023
    Copy the full SHA
    de3b3f5 View commit details
    Browse the repository at this point in the history

Commits on Apr 25, 2023

  1. block: make BlockBackend->quiesce_counter atomic

    The main loop thread increments/decrements BlockBackend->quiesce_counter
    when drained sections begin/end. The counter is read in the I/O code
    path. Therefore this field is used to communicate between threads
    without a lock.
    
    Acquire/release are not necessary because the BlockBackend->in_flight
    counter already uses sequentially consistent accesses and running I/O
    requests hold that counter when blk_wait_while_drained() is called.
    qatomic_read() can be used.
    
    Use qatomic_fetch_inc()/qatomic_fetch_dec() for modifications even
    though sequentially consistent atomic accesses are not strictly required
    here. They are, however, nicer to read than multiple calls to
    qatomic_read() and qatomic_set(). Since beginning and ending drain is
    not a hot path the extra cost doesn't matter.
    
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230307210427.269214-2-stefanha@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    c4d5bf9 View commit details
    Browse the repository at this point in the history
  2. block: make BlockBackend->disable_request_queuing atomic

    This field is accessed by multiple threads without a lock. Use explicit
    qatomic_read()/qatomic_set() calls. There is no need for acquire/release
    because blk_set_disable_request_queuing() doesn't provide any
    guarantees (it helps that it's used at BlockBackend creation time and
    not when there is I/O in flight).
    
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
    Message-Id: <20230307210427.269214-3-stefanha@redhat.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    ef80ec5 View commit details
    Browse the repository at this point in the history
  3. block: protect BlockBackend->queued_requests with a lock

    The CoQueue API offers thread-safety via the lock argument that
    qemu_co_queue_wait() and qemu_co_enter_next() take. BlockBackend
    currently does not make use of the lock argument. This means that
    multiple threads submitting I/O requests can corrupt the CoQueue's
    QSIMPLEQ.
    
    Add a QemuMutex and pass it to CoQueue APIs so that the queue is
    protected. While we're at it, also assert that the queue is empty when
    the BlockBackend is deleted.
    
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
    Message-Id: <20230307210427.269214-4-stefanha@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    407ae2a View commit details
    Browse the repository at this point in the history
  4. block: don't acquire AioContext lock in bdrv_drain_all()

    There is no need for the AioContext lock in bdrv_drain_all() because
    nothing in AIO_WAIT_WHILE() needs the lock and the condition is atomic.
    
    AIO_WAIT_WHILE_UNLOCKED() has no use for the AioContext parameter other
    than performing a check that is nowadays already done by the
    GLOBAL_STATE_CODE()/IO_CODE() macros. Set the ctx argument to NULL here
    to help us keep track of all converted callers. Eventually all callers
    will have been converted and then the argument can be dropped entirely.
    
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-2-stefanha@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    d5eab43 View commit details
    Browse the repository at this point in the history
  5. block: convert blk_exp_close_all_type() to AIO_WAIT_WHILE_UNLOCKED()

    There is no change in behavior. Switch to AIO_WAIT_WHILE_UNLOCKED()
    instead of AIO_WAIT_WHILE() to document that this code has already been
    audited and converted. The AioContext argument is already NULL so
    aio_context_release() is never called anyway.
    
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-3-stefanha@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    e5568a6 View commit details
    Browse the repository at this point in the history
  6. block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED()

    The following conversion is safe and does not change behavior:
    
         GLOBAL_STATE_CODE();
         ...
      -  AIO_WAIT_WHILE(qemu_get_aio_context(), ...);
      +  AIO_WAIT_WHILE_UNLOCKED(NULL, ...);
    
    Since we're in GLOBAL_STATE_CODE(), qemu_get_aio_context() is our home
    thread's AioContext. Thus AIO_WAIT_WHILE() does not unlock the
    AioContext:
    
      if (ctx_ && in_aio_context_home_thread(ctx_)) {                \
          while ((cond)) {                                           \
              aio_poll(ctx_, true);                                  \
              waited_ = true;                                        \
          }                                                          \
    
    And that means AIO_WAIT_WHILE_UNLOCKED(NULL, ...) can be substituted.
    
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-4-stefanha@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    d805d8a View commit details
    Browse the repository at this point in the history
  7. block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED()

    Since the AioContext argument was already NULL, AIO_WAIT_WHILE() was
    never going to unlock the AioContext. Therefore it is possible to
    replace AIO_WAIT_WHILE() with AIO_WAIT_WHILE_UNLOCKED().
    
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-5-stefanha@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    263d5e1 View commit details
    Browse the repository at this point in the history
  8. hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED()

    The HMP monitor runs in the main loop thread. Calling
    AIO_WAIT_WHILE(qemu_get_aio_context(), ...) from the main loop thread is
    equivalent to AIO_WAIT_WHILE_UNLOCKED(NULL, ...) because neither unlocks
    the AioContext and the latter's assertion that we're in the main loop
    succeeds.
    
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Markus Armbruster <armbru@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-6-stefanha@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    6bb6855 View commit details
    Browse the repository at this point in the history
  9. monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED()

    monitor_cleanup() is called from the main loop thread. Calling
    AIO_WAIT_WHILE(qemu_get_aio_context(), ...) from the main loop thread is
    equivalent to AIO_WAIT_WHILE_UNLOCKED(NULL, ...) because neither unlocks
    the AioContext and the latter's assertion that we're in the main loop
    succeeds.
    
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Markus Armbruster <armbru@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230309190855.414275-7-stefanha@redhat.com>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    9612aa4 View commit details
    Browse the repository at this point in the history
  10. include/block: fixup typos

    Fixup a few minor typos
    
    Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Message-Id: <20230313003744.55476-1-wilfred.mallawa@opensource.wdc.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    twilfredo authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    04ae220 View commit details
    Browse the repository at this point in the history
  11. block: add missing coroutine_fn to bdrv_sum_allocated_file_size()

    Not a coroutine_fn, you say?
    
      static int64_t bdrv_sum_allocated_file_size(BlockDriverState *bs)
      {
          BdrvChild *child;
          int64_t child_size, sum = 0;
    
          QLIST_FOREACH(child, &bs->children, next) {
              if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
                                 BDRV_CHILD_FILTERED))
              {
                  child_size = bdrv_co_get_allocated_file_size(child->bs);
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    Well what do we have here?!
    
    I rest my case, your honor.
    
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230308211435.346375-1-stefanha@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Stefan Hajnoczi authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    e95200c View commit details
    Browse the repository at this point in the history
  12. linux-aio: use LinuxAioState from the running thread

    Remove usage of aio_context_acquire by always submitting asynchronous
    AIO to the current thread's LinuxAioState.
    
    In order to prevent mistakes from the caller side, avoid passing LinuxAioState
    in laio_io_{plug/unplug} and laio_co_submit, and document the functions
    to make clear that they work in the current thread's AioContext.
    
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230203131731.851116-2-eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    esposem authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    ab50533 View commit details
    Browse the repository at this point in the history
  13. io_uring: use LuringState from the running thread

    Remove usage of aio_context_acquire by always submitting asynchronous
    AIO to the current thread's LuringState.
    
    In order to prevent mistakes from the caller side, avoid passing LuringState
    in luring_io_{plug/unplug} and luring_co_submit, and document the functions
    to make clear that they work in the current thread's AioContext.
    
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230203131731.851116-3-eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    esposem authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    a75e4e4 View commit details
    Browse the repository at this point in the history
  14. thread-pool: use ThreadPool from the running thread

    Use qemu_get_current_aio_context() where possible, since we always
    submit work to the current thread anyways.
    
    We want to also be sure that the thread submitting the work is
    the same as the one processing the pool, to avoid adding
    synchronization to the pool list.
    
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230203131731.851116-4-eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    esposem authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    0fdb731 View commit details
    Browse the repository at this point in the history
  15. thread-pool: avoid passing the pool parameter every time

    thread_pool_submit_aio() is always called on a pool taken from
    qemu_get_current_aio_context(), and that is the only intended
    use: each pool runs only in the same thread that is submitting
    work to it, it can't run anywhere else.
    
    Therefore simplify the thread_pool_submit* API and remove the
    ThreadPool function parameter.
    
    Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Message-Id: <20230203131731.851116-5-eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    esposem authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    aef04fc View commit details
    Browse the repository at this point in the history
  16. vvfat: mark various functions as coroutine_fn

    Functions that can do I/O are prime candidates for being coroutine_fns.  Make the
    change for those that are themselves called only from coroutine_fns.
    
    In addition, coroutine_fns should do I/O using bdrv_co_*() functions, for
    which it is required to hold the BlockDriverState graph lock.  So also nnotate
    functions on the I/O path with TSA attributes, making it possible to
    switch them to use bdrv_co_*() functions.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-2-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    eab76d5 View commit details
    Browse the repository at this point in the history
  17. blkdebug: add missing coroutine_fn annotation

    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-3-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    2f1fabd View commit details
    Browse the repository at this point in the history
  18. mirror: make mirror_flush a coroutine_fn, do not use co_wrappers

    mirror_flush calls a mixed function blk_flush but it is only called
    from mirror_run; so call the coroutine version and make mirror_flush
    a coroutine_fn too.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-4-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    26bef10 View commit details
    Browse the repository at this point in the history
  19. nbd: mark more coroutine_fns, do not use co_wrappers

    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    d2223cd View commit details
    Browse the repository at this point in the history
  20. 9pfs: mark more coroutine_fns

    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-6-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    c3b21fb View commit details
    Browse the repository at this point in the history
  21. qemu-pr-helper: mark more coroutine_fns

    do_sgio can suspend via the coroutine function thread_pool_submit_co, so it
    has to be coroutine_fn as well---and the same is true of all its direct and
    indirect callers.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-7-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    70bd77b View commit details
    Browse the repository at this point in the history
  22. tests: mark more coroutine_fns

    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-8-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    10bf10a View commit details
    Browse the repository at this point in the history
  23. qcow2: mark various functions as coroutine_fn and GRAPH_RDLOCK

    Functions that can do I/O (including calling bdrv_is_allocated
    and bdrv_block_status functions) are prime candidates for being
    coroutine_fns.  Make the change for those that are themselves called
    only from coroutine_fns.  Also annotate that they are called with the
    graph rdlock taken, thus allowing them to call bdrv_co_*() functions
    for I/O.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-9-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    a39bae4 View commit details
    Browse the repository at this point in the history
  24. vmdk: make vmdk_is_cid_valid a coroutine_fn

    Functions that can do I/O are prime candidates for being coroutine_fns.  Make the
    change for the one that is itself called only from coroutine_fns.  Unfortunately
    vmdk does not use a coroutine_fn for the bulk of the open (like qcow2 does) so
    vmdk_read_cid cannot have the same treatment.
    
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20230309084456.304669-10-pbonzini@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    bonzini authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    5a5a9fd View commit details
    Browse the repository at this point in the history
  25. block/monitor: Fix crash when executing HMP commit

    hmp_commit() calls blk_is_available() from a non-coroutine context (and
    in the main loop). blk_is_available() is a co_wrapper_mixed_bdrv_rdlock
    function, and in the non-coroutine context it calls AIO_WAIT_WHILE(),
    which crashes if the aio_context lock is not taken before.
    
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1615
    Signed-off-by: Wang Liang <wangliangzz@inspur.com>
    Message-Id: <20230424103902.45265-1-wangliangzz@126.com>
    Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
    Reviewed-by: Kevin Wolf <kwolf@redhat.com>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>
    Wang Liang authored and Kevin Wolf committed Apr 25, 2023
    Copy the full SHA
    8c1e8fb View commit details
    Browse the repository at this point in the history
  26. qapi: support updating expected test output via make

    It is possible to pass --update to tests/qapi-schema/test-qapi.py
    to make it update the output files on error. This is inconvenient
    to achieve though when test-qapi.py is run indirectly by make/meson.
    
    Instead simply allow for an env variable to be set:
    
     $ QAPI_TEST_UPDATE= make check-qapi-schema
    
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20230420102619.348173-2-berrange@redhat.com>
    Reviewed-by: Markus Armbruster <armbru@redhat.com>
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    berrange authored and Markus Armbruster committed Apr 25, 2023
    Copy the full SHA
    7ce54db View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2023

  1. qapi: Improve specificity of type/member descriptions

    Error messages describe object members, enumeration values, features,
    and variants like ROLE 'NAME', where ROLE is "member", "value",
    "feature", or "branch", respectively.  When the member is defined in
    another type, e.g. inherited from a base type, we add "of type
    'TYPE'".  Example: test case struct-base-clash-deep reports a member
    of type 'Sub' clashing with a member of its base type 'Base' as
    
        struct-base-clash-deep.json: In struct 'Sub':
        struct-base-clash-deep.json:10: member 'name' collides with member 'name' of type 'Base'
    
    Members of implicitly defined types need special treatment.  We don't
    want to add "of type 'TYPE'" for them, because their named are made up
    and mean nothing to the user.  Instead, we describe members of an
    implicitly defined base type as "base member 'NAME'", and command and
    event parameters as "parameter 'NAME'".  Example: test case
    union-bad-base reports member of a variant's type clashing with a
    member of its implicitly defined base type as
    
        union-bad-base.json: In union 'TestUnion':
        union-bad-base.json:8: member 'string' of type 'TestTypeA' collides with base member 'string'
    
    The next commit will permit unions as variant types.  "base member
    'NAME' would then be ambigious: is it the union's base, or is it the
    union's variant's base?  One of its test cases would report a clash
    between two such bases as "base member 'type' collides with base
    member 'type'".  Confusing.
    
    Refine the special treatment: add "of TYPE" even for implicitly
    defined types, but massage TYPE and ROLE so they make sense for the
    user.
    
    Message-Id: <20230420102619.348173-3-berrange@redhat.com>
    Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    Markus Armbruster committed Apr 26, 2023
    Copy the full SHA
    1e148b5 View commit details
    Browse the repository at this point in the history
  2. qapi: allow unions to contain further unions

    This extends the QAPI schema validation to permit unions inside unions,
    provided the checks for clashing fields pass.
    
    Reviewed-by: Markus Armbruster <armbru@redhat.com>
    Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
    Message-Id: <20230420102619.348173-4-berrange@redhat.com>
    Signed-off-by: Markus Armbruster <armbru@redhat.com>
    berrange authored and Markus Armbruster committed Apr 26, 2023
    Copy the full SHA
    a17dbc4 View commit details
    Browse the repository at this point in the history
  3. Merge tag 'for-upstream' of https://repo.or.cz/qemu/kevin into staging

    Block layer patches
    
    - Protect BlockBackend.queued_requests with its own lock
    - Switch to AIO_WAIT_WHILE_UNLOCKED() where possible
    - AioContext removal: LinuxAioState/LuringState/ThreadPool
    - Add more coroutine_fn annotations, use bdrv/blk_co_*
    - Fix crash when execute hmp_commit
    
    # -----BEGIN PGP SIGNATURE-----
    #
    # iQJFBAABCAAvFiEE3D3rFZqa+V09dFb+fwmycsiPL9YFAmRH0b0RHGt3b2xmQHJl
    # ZGhhdC5jb20ACgkQfwmycsiPL9Y0yw/6A/vzA4TGgFUP3WIvH/sQri4/V3gyR+PT
    # u3hOQUCYZ99nioTpKV91TSuUPuU/Mdspy/0NKM+K92yIXqxa9172A2zLOsGOu21l
    # qKpse+nBf1zqEgB8YzUHyCBdetPz916C/f9RS26SNUCW85GCHYGHA3u7nKvWLMyV
    # oKIoTlA8QOglOuEKlRoYh7hCFm7ET51NOSEftm8GsYbsW/I2Vzl8a1SHN1lHufjd
    # We3+898zUrmFqNMp6Rjdhn+yZmmoGzoZqV4YQi83z7xjiv+Ms4VHVVW7X8d20xRX
    # 5BLFiLHAuZ/1d26HyVhgBUr7KHyf94odocz8BylWKXGl5SXMCZun1Td1vgVKlGK+
    # GRxzB2cWGWqzC2UmqSTc0Z0aIWbXukKwvcX76uBKsQZ+kB2A7jFobxHiaoQEDJ8B
    # WRNEMH2+CqCAu9rsrNRinnJKhT2nXcr9F9YfwRIlagdAePGWin+EUW8huf14dDBm
    # Z2Y34aKW4RQibF8xirMHeRBbOLmcq2VpKLKwNfBHUDgZB8iuD7bLn4n9nwWXMG1w
    # zgNsTybkv46vLPamTpEaUoNTHfuRDTAuE7Z7lkcc7jF41Z0V1DC/DCCWcL/0LvhP
    # GIxFdkYug3hetdF2U/OZhUoEfxvkqcuBnrr55LFzqheKEllQpPwPpt7UF0aH8bg3
    # i/YpjHsf3xU=
    # =mpYX
    # -----END PGP SIGNATURE-----
    # gpg: Signature made Tue 25 Apr 2023 02:12:29 PM BST
    # gpg:                using RSA key DC3DEB159A9AF95D3D7456FE7F09B272C88F2FD6
    # gpg:                issuer "kwolf@redhat.com"
    # gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>" [full]
    
    * tag 'for-upstream' of https://repo.or.cz/qemu/kevin: (25 commits)
      block/monitor: Fix crash when executing HMP commit
      vmdk: make vmdk_is_cid_valid a coroutine_fn
      qcow2: mark various functions as coroutine_fn and GRAPH_RDLOCK
      tests: mark more coroutine_fns
      qemu-pr-helper: mark more coroutine_fns
      9pfs: mark more coroutine_fns
      nbd: mark more coroutine_fns, do not use co_wrappers
      mirror: make mirror_flush a coroutine_fn, do not use co_wrappers
      blkdebug: add missing coroutine_fn annotation
      vvfat: mark various functions as coroutine_fn
      thread-pool: avoid passing the pool parameter every time
      thread-pool: use ThreadPool from the running thread
      io_uring: use LuringState from the running thread
      linux-aio: use LinuxAioState from the running thread
      block: add missing coroutine_fn to bdrv_sum_allocated_file_size()
      include/block: fixup typos
      monitor: convert monitor_cleanup() to AIO_WAIT_WHILE_UNLOCKED()
      hmp: convert handle_hmp_command() to AIO_WAIT_WHILE_UNLOCKED()
      block: convert bdrv_drain_all_begin() to AIO_WAIT_WHILE_UNLOCKED()
      block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED()
      ...
    
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    rth7680 committed Apr 26, 2023
    Copy the full SHA
    4d1467a View commit details
    Browse the repository at this point in the history
  4. Merge tag 'pull-qapi-2023-04-26' of https://repo.or.cz/qemu/armbru in…

    …to staging
    
    QAPI patches patches for 2023-04-26
    
    # -----BEGIN PGP SIGNATURE-----
    #
    # iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAmRIvOkSHGFybWJydUBy
    # ZWRoYXQuY29tAAoJEDhwtADrkYZTX3MQAIqrKQbOzQ81/cDZ7aeLOroDoGYf1Cs0
    # 0NiEVlyoblWNzL3HraGgXiNRTP+zaG/TcFKza1nz8qjdkxWxBjdbfF5Lm6mQf5Zo
    # tcHUjksmnUlPkLYSOyEjfY9SNvcS6g7djE/NF5lbJtzYGZScZpLarELR7oUvrcXR
    # AEiw8N5FZXp+j6cTeWvrLzSqz9qBsFJUCGcGER0T/Mt5MlUwDexE1xe7g8oD5l+b
    # s0jeQr1PTZm5k6ehajQtgbHvAkgH8xVTKqbB/U5iz4VhYriH+IPEOtfCFt6/1soz
    # pVkYikJpazCvQMjqnWu9dE1onthgSsEIOV29kFU0Kr8ATZuJBQMuLVp4hSsbKANj
    # BUVyL2/fUsIp7gd+KikXUOjKYajxek6Q2YLAPpL+1pBCTql/PBQ7td8CECdiv/9e
    # Xh50q+BGvyEiyoyf4EEpaLXUZog605WHEaODj9uPtNHJP9x6Rqt93FUsdWUtt/k9
    # hJ8RSKy8njr0vxGoJkj89m2XfCwtuX3VQ5IXvv/If4U5Y4+JhcLtiqW+Njh8fAM4
    # ZwIrlUYG7inLUKFVcQ3sEGpaj611i5ixIxctUvEiggZX+fPeSFKYUr+Rq8WXM8gv
    # suLXz7VF6H4Sw30lCvdQ4LSungbzlYAtQYpmdEQGoM8iasIi4PoDf0cTYBbMYHDX
    # +pZvWC50cVtf
    # =wLx6
    # -----END PGP SIGNATURE-----
    # gpg: Signature made Wed 26 Apr 2023 06:55:53 AM BST
    # gpg:                using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653
    # gpg:                issuer "armbru@redhat.com"
    # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [undefined]
    # gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>" [undefined]
    # gpg: WARNING: This key is not certified with a trusted signature!
    # gpg:          There is no indication that the signature belongs to the owner.
    # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653
    
    * tag 'pull-qapi-2023-04-26' of https://repo.or.cz/qemu/armbru:
      qapi: allow unions to contain further unions
      qapi: Improve specificity of type/member descriptions
      qapi: support updating expected test output via make
      qapi: Require boxed for conditional command and event arguments
      qapi: Fix code generated for optional conditional struct member
      tests/qapi-schema: Cover optional conditional struct member
      tests/qapi-schema: Clean up positive test for conditionals
      tests/qapi-schema: Rename a few conditionals
      tests/qapi-schema: Improve union discriminator coverage
      qapi: Fix to reject 'data': 'mumble' in struct
      qapi: Fix error message when type name or array is expected
      qapi: Simplify code a bit after previous commits
      qapi: Improve error message for unexpected array types
      qapi: Split up check_type()
      qapi: Clean up after removal of simple unions
      qapi/schema: Use super()
      qapi: Fix error message format regression
    
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    rth7680 committed Apr 26, 2023
    Copy the full SHA
    c3f9aa8 View commit details
    Browse the repository at this point in the history