From 254aee4dbbec1b8ab0de23c435e927d1501bae34 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Thu, 29 Jun 2017 15:27:43 +0200 Subject: vvfat: make it thread-safe Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Fam Zheng Signed-off-by: Paolo Bonzini Message-Id: <20170629132749.997-6-pbonzini@redhat.com> Signed-off-by: Fam Zheng --- block/vvfat.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'block/vvfat.c') diff --git a/block/vvfat.c b/block/vvfat.c index 4fd28e1e87..4dae790203 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -3078,8 +3078,14 @@ static int coroutine_fn write_target_commit(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { + int ret; + BDRVVVFATState* s = *((BDRVVVFATState**) bs->opaque); - return try_commit(s); + qemu_co_mutex_lock(&s->lock); + ret = try_commit(s); + qemu_co_mutex_unlock(&s->lock); + + return ret; } static void write_target_close(BlockDriverState *bs) { -- cgit v1.2.3