Skip to content
Snippets Groups Projects
  • Kevin Wolf's avatar
    eb94b81a
    block: Convert 'block_resize' to coroutine · eb94b81a
    Kevin Wolf authored
    
    block_resize performs some I/O that could potentially take quite some
    time, so use it as an example for the new 'coroutine': true annotation
    in the QAPI schema.
    
    bdrv_truncate() requires that we're already in the right AioContext for
    the BlockDriverState if called in coroutine context. So instead of just
    taking the AioContext lock, move the QMP handler coroutine to the
    context.
    
    Call blk_unref() only after switching back because blk_unref() may only
    be called in the main thread.
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20201005155855.256490-15-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
    eb94b81a
    History
    block: Convert 'block_resize' to coroutine
    Kevin Wolf authored
    
    block_resize performs some I/O that could potentially take quite some
    time, so use it as an example for the new 'coroutine': true annotation
    in the QAPI schema.
    
    bdrv_truncate() requires that we're already in the right AioContext for
    the BlockDriverState if called in coroutine context. So instead of just
    taking the AioContext lock, move the QMP handler coroutine to the
    context.
    
    Call blk_unref() only after switching back because blk_unref() may only
    be called in the main thread.
    
    Signed-off-by: default avatarKevin Wolf <kwolf@redhat.com>
    Message-Id: <20201005155855.256490-15-kwolf@redhat.com>
    Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
    Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>