]> git.proxmox.com Git - mirror_qemu.git/commit - block/qcow2.c
qcow2: Fix full preallocation with external data file
authorKevin Wolf <kwolf@redhat.com>
Mon, 15 Apr 2019 14:34:30 +0000 (16:34 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 30 Apr 2019 13:29:00 +0000 (15:29 +0200)
commit718c0fce2f56755a8d8f737607779a98aa6e7cc4
tree5a87a739fe8e427fa9c4291faa9f2722eed9e197
parent360bd07471dfd1830246e8403ffdc9ba9d82f9d4
qcow2: Fix full preallocation with external data file

preallocate_co() already gave the data file the full size without
forwarding the requested preallocation mode to the protocol. When
bdrv_co_truncate() was called later with the preallocation mode, the
file didn't actually grow any more, so the data file stayed unallocated
even if full preallocation was requested.

Pass the right preallocation mode to preallocate_co() and remove the
second bdrv_co_truncate() to fix this. As a side effect, the ugly
one-byte write in preallocate_co() is replaced with a truncate call,
now leaving the last block unallocated on the protocol level as it
should be.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
block/qcow2.c