blockjob: add block_job_defer_to_main_loop()
commitdec7d421f85578b0949292336f784f55ac84812d
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 21 Oct 2014 11:03:54 +0000 (21 12:03 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 3 Nov 2014 11:41:49 +0000 (3 11:41 +0000)
tree1e3c37516831a97591874685d13f270e8cb7a2d5
parent723c5d93c51bdb3adbc238ce90195c0864aa6cd5
blockjob: add block_job_defer_to_main_loop()

Block jobs will run in the BlockDriverState's AioContext, which may not
always be the QEMU main loop.

There are some block layer APIs that are either not thread-safe or risk
lock ordering problems.  This includes bdrv_unref(), bdrv_close(), and
anything that calls bdrv_drain_all().

The block_job_defer_to_main_loop() API allows a block job to schedule a
function to run in the main loop with the BlockDriverState AioContext
held.

This function will be used to perform cleanup and backing chain
manipulations in block jobs.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1413889440-32577-6-git-send-email-stefanha@redhat.com
blockjob.c
include/block/blockjob.h