KVM/qemu support various types of cache - none, writethrough, writeback.

How to check which one is default and is used on system when no cache= is specified?

For RHEL6 i found that it's writethrough - but for example for sles sometimes it's writeback.


Here is a way to check some default cache mode. Although it's also kind of documentation, it's "online" and you get the default cache mode of your current QEMU version. As @dokotr5000 said, it depends on the version.

Run "qemu-img -h" and search for the "cache" part. You will find something like the following.

  'cache' is the cache mode used to write the output disk image, the valid
options are: 'none', 'writeback' (default, except for convert), 'writethrough',
'directsync' and 'unsafe' (default for convert)

The cache mode is associated with individual image files. And the default cache mode you get this way is the one to convert or rebase an image file, instead of the mode when you create it. But at least it suggests the favorite default of current version of QEMU, and lets you make an educated guess.

I tried this on Ubunt 12.04, 14.04, and 16.04. All give writeback as default.


That depends on what kvm version and what flavour you run. See e.g. https://www.suse.com/documentation/sles11/book_kvm/data/sect1_1_chapter_book_kvm.html where it says:

cache mode unspecified

In qemu-kvm versions older than v1.2 (eg SLES11 SP2), not specifying a cache mode meant that writethrough would be used as the default.

http://wiki.qemu.org/ChangeLog/1.2#Block_devices states:

Block devices


  • The default cache mode for images is now writeback.

For some recommendations between the various modes see e.g.

  • Interesting links, but... it doesn't answer to question :-) I know that knowing distribution, version of kvm, environment - it's possible to check in documentation (or sources) what is default. But - how to check it "online"? Having only host and running guest. – undefine May 3 '15 at 21:43
  • Uhmmm by checking the qemu version via e.g. qemu-kvm --version ? If you're below 1.2 then the default is writethrough, starting with 1.2 the default is writeback. If your question is how to query this for a running VM or un the underlying host, that's probably not that easy and highly depends on how you start the VM. Do you use qemu directly, do you use virsh, do you use virt-viewer ... ? – doktor5000 May 4 '15 at 23:05
  • Is your question still not fully answered? Please specify what exactly you're missing. For running VMs you could try to query them via QMP (qemu monitor protocol), see some explanations at kashyapc.com/2013/03/31/… or unix.stackexchange.com/a/140927/83329 – doktor5000 May 10 '15 at 12:43
  • I have machine with sime running kvm's. I would like to know which cache mode is used, when (for example) definition of disk is: -device virtio-blk-pci,drive=hotdisk-XXX-pci-4,id=hotdisk-XXX-pci-4,bus=pci.0,addr=0x4 -drive file=/var/run/ganeti/instance-disks/XXX:0,format=raw,if=none,id=hotdisk-XXX-pci-4,bus=0,unit=4 (there is no "cache=" definition in it). If there is possible to get this information via monitor or qmp - please give me some details :-) - i don't see such option. – undefine May 11 '15 at 12:51
  • If you do not explicitly specify the cache mode, the quotes from my answer apply as you're using the defaults the. Seems it cannot currently be queried directly if I interpret wiki.qemu.org/Features/Block/… correctly. You might want to ask on the qemu mailing list about this if you are interested. – doktor5000 May 11 '15 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.