summary refs log tree commit diff stats
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorHanna Reitz <hreitz@redhat.com>2022-04-05 15:46:50 +0200
committerHanna Reitz <hreitz@redhat.com>2022-04-20 10:14:28 +0200
commita8c07ec287554dcefd33733f0e5888a281ddc95e (patch)
tree7bbfee74628e45bc924d742b2a3be9d0791a6f59 /linux-user/main.c
parent32911369fee72de1932a1ded714319fe0ecb9d2d (diff)
downloadfocaccia-qemu-a8c07ec287554dcefd33733f0e5888a281ddc95e.tar.gz
focaccia-qemu-a8c07ec287554dcefd33733f0e5888a281ddc95e.zip
qcow2: Improve refcount structure rebuilding
When rebuilding the refcount structures (when qemu-img check -r found
errors with refcount = 0, but reference count > 0), the new refcount
table defaults to being put at the image file end[1].  There is no good
reason for that except that it means we will not have to rewrite any
refblocks we already wrote to disk.

Changing the code to rewrite those refblocks is not too difficult,
though, so let us do that.  That is beneficial for images on block
devices, where we cannot really write beyond the end of the image file.

Use this opportunity to add extensive comments to the code, and refactor
it a bit, getting rid of the backwards-jumping goto.

[1] Unless there is something allocated in the area pointed to by the
    last refblock, so we have to write that refblock.  In that case, we
    try to put the reftable in there.

Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1519071
Closes: https://gitlab.com/qemu-project/qemu/-/issues/941
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220405134652.19278-2-hreitz@redhat.com>
Diffstat (limited to 'linux-user/main.c')
0 files changed, 0 insertions, 0 deletions