[libvirt-users] Behavior of disk caching with qcow2 disks

Andrew Martin amartin at xes-inc.com
Mon Aug 11 19:06:54 UTC 2014


Hello,

I am running several virtualization servers with QEMU 1.4.x and libvirt 1.0.2 on
Ubuntu 12.04 and am working on optimizing the cache= and aio= options for the
virtual machines. These VM images are mostly qcow2, and are served both from a
local ext4 filesystem (with data=ordered,barrier) and from an NFS mountpoint
(with sync). The local filesystem sits on top of an md software RAID of SATA
HDDs.

I have read some conflicting information about which cache option is used by
default. This documentation states that cache=writethrough is the default:
http://www-01.ibm.com/support/knowledgecenter/linuxonibm/liaat/liaatbpkvmguestcache.htm?lang=en

However this SuSE documentation claims that QEMU 1.2.x and newer allows the
driver to select which cache mode, and it often defaults to cache=writeback:
https://www.suse.com/documentation/sles11/book_kvm/data/sect1_1_chapter_book_kvm.html

Which is correct? How is the cache mode set by default (if cache= is not
specified)?

My second question is can cache=none be used safely on a local ext4 filesystem
with no BBU? Since ext4 uses barriers, would writing to these qcow2 image files
be safe? The kernel documentation about barriers states that "Write barriers
enforce proper on-disk ordering of journal commits, making volatile disk write
caches safe to use, at some performance penalty". Does this apply to qcow2 VM
images?

Thanks,

Andrew Martin




More information about the libvirt-users mailing list