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>
This commit is contained in:
Zhi Yong Wu 2012-05-07 16:51:03 +08:00 committed by Kevin Wolf
parent 5b7e1542cf
commit 15552c4ad3
1 changed files with 3 additions and 0 deletions

View File

@ -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;
}