]> git.proxmox.com Git - mirror_qemu.git/commitdiff
block: acquire AioContext in qmp_query_blockstats()
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 17 Jun 2014 06:32:05 +0000 (14:32 +0800)
committerKevin Wolf <kwolf@redhat.com>
Fri, 27 Jun 2014 16:20:29 +0000 (18:20 +0200)
Make query-blockstats safe for dataplane by acquiring the
BlockDriverState's AioContext.  This ensures that the dataplane IOThread
and the main loop's monitor code do not race.

Note the assumption that acquiring the drive's BDS AioContext also
protects ->file and ->backing_hd.  This assumption is made by other
aio_context_acquire() callers too.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qapi.c

index aeabaaf85c5222d4e4da5c387e54cbd63c1fd32b..f44f6b40120a69183539bbebca2b491467e33fb2 100644 (file)
@@ -360,7 +360,11 @@ BlockStatsList *qmp_query_blockstats(Error **errp)
 
      while ((bs = bdrv_next(bs))) {
         BlockStatsList *info = g_malloc0(sizeof(*info));
+        AioContext *ctx = bdrv_get_aio_context(bs);
+
+        aio_context_acquire(ctx);
         info->value = bdrv_query_stats(bs);
+        aio_context_release(ctx);
 
         *p_next = info;
         p_next = &info->next;