The current implementation of alloc_refcount_block and grow_refcount_table has fundamental problems regarding error handling. There are some places where an I/O error means that the image is going to be corrupted. I have found that the only way to fix this is to completely rewrite the thing.
Just sending as an RFC to the list hasn't generated a lot of comments (to be precise, not a single one). This is a critical part of qcow2 and needs reviews. So let's try it another way: People in CC, please give it a review. Sooner or later some of you will need to do so anyway. Kevin Wolf (3): qcow2: Factor next_refcount_table_size out qcow2: Rewrite alloc_refcount_block/grow_refcount_table qcow2: More check for qemu-img check block/qcow2-refcount.c | 334 +++++++++++++++++++++++++++++++++++------------- 1 files changed, 244 insertions(+), 90 deletions(-)