aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorZhi Yong Wu <wuzhy@linux.vnet.ibm.com>2012-05-07 16:51:03 +0800
committerKevin Wolf <kwolf@redhat.com>2012-05-07 19:33:18 +0200
commit15552c4ad38b9ec66792b044cf5ae74538c32717 (patch)
treeb168541511421906bc1214b8408cd7175ca486d5 /block
parent5b7e1542cfa41a281af9629d31cef03704d976e6 (diff)
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 <wuzhy@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qcow2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 8c60a6f061..ee4678f6ed 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;
}