From: Zhi Yong Wu Date: Mon, 7 May 2012 08:51:03 +0000 (+0800) Subject: qcow2: lock on prealloc X-Git-Tag: v1.1-rc1~14^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15552c4ad38b9ec66792b044cf5ae74538c32717;p=thirdparty%2Fqemu.git qcow2: lock on prealloc preallocate() will be locked. This is required because qcow2_alloc_cluster_link_l2() assumes that it runs under a lock that it can drop while COW is being performed. Signed-off-by: Zhi Yong Wu Signed-off-by: Kevin Wolf --- diff --git a/block/qcow2.c b/block/qcow2.c index 8c60a6f0612..ee4678f6edf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1192,7 +1192,10 @@ static int qcow2_create2(const char *filename, int64_t total_size, /* And if we're supposed to preallocate metadata, do that now */ if (prealloc) { + BDRVQcowState *s = bs->opaque; + qemu_co_mutex_lock(&s->lock); ret = preallocate(bs); + qemu_co_mutex_unlock(&s->lock); if (ret < 0) { goto out; }