]> git.proxmox.com Git - qemu.git/commitdiff
qcow2: lock on prealloc
authorZhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Mon, 7 May 2012 08:51:03 +0000 (16:51 +0800)
committerKevin Wolf <kwolf@redhat.com>
Mon, 7 May 2012 17:33:18 +0000 (19:33 +0200)
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>
block/qcow2.c

index 8c60a6f06123c154da9f7768ee04ea6a2e857286..ee4678f6edf75d31250d9fafee9cf675d1ce156b 100644 (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;
         }