oVirt / vdsm

The Virtual Desktop Server Manager
GNU General Public License v2.0
161 stars 202 forks source link

Fix creating a preallocated qcow2 disk #292

Closed aesteve-rh closed 2 years ago

aesteve-rh commented 2 years ago

Running the command:

$ ./ovirt-img upload-disk -c engine --storage-domain nfs-01 /data/tmp/fedora-34.qcow2 --preallocated

...does not create preallocated file (with qemu-img info): Virtual Size: 50 GiB Actual Size: 23 GiB

So, for qcow2 format we don't do preallocation even if engine asked for preallocated format. Needs investigation. There may be a good reason why we don't preallocate, but it may also be an error.

aesteve-rh commented 2 years ago

For block storage:

if preallocate == sc.SPARSE_VOL:
...
else:
    # Preallocated qcow2
    alloc_size = initial_size if initial_size else capacity

So upload-disk was (should not in the latest version) requesting a new preallocated qcow2 disk with initial_size 23 GiB, and virtual_size 50 GiB. With this request, Vdsm takes into consideration the initial_size that engine has sent in the request and creates the disk, even for preallocated disks.

For file storage (as in the initial message):

preallocate is not considered at all for COW volumes (?).