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 <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
blockdev.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 1c7dab4..fd55904 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2649,14 +2649,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)