I attended Paolo Bonzini's qemu session ("Live Disk Operations: Juggling Data and Trying to go Unnoticed") in LinuxCon Japan, and he adviced me to post the bits I have regarding my question on qemu's support on shrinking CoW image.
Here's my problem description. I recently designed a experimental system which holds VM master images on a HDD and CoW snapshots on a SSD. VMs run on CoW snapshots only. This split-image configration is done to keep VM I/Os on a SSD As SSD capacity is rather limited, I need to do a writeback commit from SSD to HDD time to time, and that is done during weekend/midnight. The problem is although a commit is made, that alone won't shrink CoW image - all unused blocks are still kept in a snapshot, and uses up space. Patch attached is a workaround I added to cope with the problem, but the basic problem I faced was that both QCOW2/QED format still does not support "bdrv_make_empty" API. Implementing the API (say, by hole punching) seemed like a lot of effort, so I ended up creating a new CoW image, and then replace current CoW snapshot with a new (empty) one. But I find the code ugly. In his talk, Paolo suggested possibility of using new "live op" API for this task, but I'm not aware of the actual API. Is there any documentation or source code I can look at to re-implement above feature? Best Regards,
qemu-block-refresh.patch
Description: Binary data