Make sure that query-block-jobs acquires the BlockDriverState AioContext so that the blockjob isn't running in another thread while we access its state.
Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> --- blockdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 379a268..270425d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2585,14 +2585,19 @@ fail: static void do_qmp_query_block_jobs_one(void *opaque, BlockDriverState *bs) { BlockJobInfoList **prev = opaque; - BlockJob *job = bs->job; + AioContext *aio_context; + + aio_context = bdrv_get_aio_context(bs); + aio_context_acquire(aio_context); - if (job) { + if (bs->job) { BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1); elem->value = block_job_query(bs->job); (*prev)->next = elem; *prev = elem; } + + aio_context_release(aio_context); } BlockJobInfoList *qmp_query_block_jobs(Error **errp) -- 1.9.3