[PATCH 0/3] Add a for_commit option to qemu-img measure

Jean-Louis Dupond posted 3 patches 3 weeks, 1 day ago
block/qcow2.c                    | 137 +++++++++++++++++++++++++++++--
include/block/block_int-common.h |   4 +
qapi/block-core.json             |  28 +++++++
qemu-img.c                       |  40 +++++++--
tests/qemu-iotests/290           |  45 ++++++++++
tests/qemu-iotests/290.out       |  61 ++++++++++++++
6 files changed, 304 insertions(+), 11 deletions(-)
[PATCH 0/3] Add a for_commit option to qemu-img measure
Posted by Jean-Louis Dupond 3 weeks, 1 day ago
This fixed bug #2369 [1]

This patch is a new implementation for a previous (non-merged) patch to make measure useful to calculate
the new size of the target image after commit.
It is very useful to have this kind of calculation if you do qcow2 on block storage (like iSCSi).
This because you need to be able to size the target volume big enough to handle the committed image.

Instead of modifying the existing measure logic, a new logic was added that really looks into the allocated
clusters and use the (local) next_cluster_index to calculate the target image size.
It also takes into account discards from the top into base to lower the index when a cluster is freed.

New test was added to verify the code.

When testing the new code on the impacted images in bug #2369 [1], this gives the following results:

Start:
<filesize>  <image>
 6174015488 top
13421772800 base

calculate with discard-no-unref=on:
required -> 13624475648
Commited image size: 13610385408

When calculating with discard-no-unref=off:
required -> 13520404480
Commited image size: 13504806912

Let me know if I made some mistakes :)

[1]: https://gitlab.com/qemu-project/qemu/-/issues/2369

Jean-Louis Dupond (3):
  block: add for_commit option to measure
  qcow2: make measure for_commit aware
  iotests/290: add test case for for_commit measure

 block/qcow2.c                    | 137 +++++++++++++++++++++++++++++--
 include/block/block_int-common.h |   4 +
 qapi/block-core.json             |  28 +++++++
 qemu-img.c                       |  40 +++++++--
 tests/qemu-iotests/290           |  45 ++++++++++
 tests/qemu-iotests/290.out       |  61 ++++++++++++++
 6 files changed, 304 insertions(+), 11 deletions(-)

-- 
2.49.0