]> git.proxmox.com Git - mirror_qemu.git/commitdiff
blockdev: acquire AioContext in do_qmp_query_block_jobs_one()
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 21 Oct 2014 11:03:51 +0000 (12:03 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 3 Nov 2014 11:41:49 +0000 (11:41 +0000)
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 <stefanha@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 1413889440-32577-3-git-send-email-stefanha@redhat.com

blockdev.c

index 501473da69e52b2a2f5f1ddb3c167b99ffa5e39d..40fc5d624fcb023e05ab41953b81db2061200393 100644 (file)
@@ -2628,12 +2628,18 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp)
     BlockDriverState *bs;
 
     for (bs = bdrv_next(NULL); bs; bs = bdrv_next(bs)) {
+        AioContext *aio_context = bdrv_get_aio_context(bs);
+
+        aio_context_acquire(aio_context);
+
         if (bs->job) {
             BlockJobInfoList *elem = g_new0(BlockJobInfoList, 1);
             elem->value = block_job_query(bs->job);
             *p_next = elem;
             p_next = &elem->next;
         }
+
+        aio_context_release(aio_context);
     }
 
     return head;