Until now I've enabled discard on my QEMU guests using the libvirt XML command
..
<driver name='qemu' type='qcow2' discard='unmap' />
..
And it seems to work fine.
Now that I'm about to convert my storage from virtio-scsi
to virtio-blk
because it now support discard, I ran into the option detect_zeroes=off|on|unmap
(or QEMUs equivalent detect-zeroes
)
Should I also use this option and why? I assume beside the areas will be marked "available" by discard they are also written by zeroes, but what values does it have, especially on SSD backed storage?
Using qcow2 images I see the point of writing zeros to mark the empty space sparsed, but it seems the qcow2 image files are actually getting smaller (sparsed) without this option and just using discard='unmap'
.
The libvirt documentation says:
The optional detect_zeroes attribute controls whether to detect zero write requests. The value can be "off", "on" or "unmap". First two values turn the detection off and on, respectively. The third value ("unmap") turns the detection on and additionally tries to discard such areas from the image based on the value of discard above (it will act as "on" if discard is set to "ignore"). NB enabling the detection is a compute intensive operation, but can save file space and/or time on slow media. Since 2.0.0
Which unfortunately didn't got me closer to a decision of using detect_zeroes
or not :-/
Backing storage for my QEMU guests are both qcow2 images on HDD and SSD and LVM block devices located on SSD.