While i started evaluating KVM IO performance, i leveraged qcow2 preallocation capabilities which helped me to boot IO performance. Its always good to preallocate image for better performance. For ex, while attaching disks to instances in openstack.
Earlier if we want to preallocate qcow2 image we had to do manually using falloc as shown below.
qemu-img create -f qcow2 -o preallocation=metadata /tmp/test.qcow2 8G
fallocate -l 8591507456 /tmp/test.qcow2
Now we have these options very useful.
qemu-img create -f qcow2 /tmp/test.qcow2 -o preallocation=falloc 1G
Formatting ‘/tmp/test.qcow2′, fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 preallocation=’falloc’ lazy_refcounts=off refcount_bits=16
“falloc” mode preallocated space for image by calling posic_fallocate()
qemu-img create -f qcow2 /tmp/test.qcow2 -o preallocation=full 1G
Formatting ‘/tmp/test.qcow2′, fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 preallocation=’full’ lazy_refcounts=off refcount_bits=16
“full” mode preallocates space for image by writing zeros to underlying storage. Similing to dd
Thanks to my IO Guru Stefan Hajnoczi for clarifying some of the IO part internals.