RFCv2: * Publishing RFC again to discuss the new user-visible interfaces. Code has changed quite a bit, I have not kept any Reviewed-by tags. * Rename qemu-img sub-command "measure" and API bdrv_measure() [Nir] * Report both "required bytes" and "fully allocated bytes" to handle the empty image file and prealloc use cases [Nir and Dan] * Use bdrv_getlength() instead of bdrv_nb_sectors() [Berto] * Rename "err" label "out" in qemu-img-cmds.c [Nir] * Add basic qcow2 support, doesn't support qemu-img convert from existing files yet
RFCv1: * Publishing patch series with just raw support, no qcow2 yet. Please review the command-line interface and let me know if you are happy with this approach. Users and management tools sometimes need to know the size required for a new disk image so that an LVM volume, SAN LUN, etc can be allocated ahead of time. Image formats like qcow2 have non-trivial metadata that makes it hard to estimate the exact size without knowledge of file format internals. This patch series introduces a new qemu-img sub-command that calculates the required size for both image creation and conversion scenarios. The conversion scenario is: $ qemu-img measure -f raw -O qcow2 input.img required bytes: 1327680 fully allocated bytes: 1074069504 Here an existing image file is taken and the output includes the space required for data from the input image file. The creation scenario is: $ qemu-img measure -O qcow2 --size 5G required bytes: 327680 fully allocated bytes: 1074069504 Stefan Hajnoczi (8): block: add bdrv_measure() API raw-format: add bdrv_measure() support qcow2: extract preallocation calculation function qcow2: extract image creation option parsing qcow2: add bdrv_measure() support qemu-img: add measure subcommand qemu-iotests: support per-format golden output files iotests: add test 178 for qemu-img measure qapi/block-core.json | 19 +++ include/block/block.h | 4 + include/block/block_int.h | 2 + block.c | 33 +++++ block/qcow2.c | 296 ++++++++++++++++++++++++++------------- block/raw-format.c | 22 +++ qemu-img.c | 213 ++++++++++++++++++++++++++++ qemu-img-cmds.hx | 9 ++ tests/qemu-iotests/178 | 75 ++++++++++ tests/qemu-iotests/178.out.qcow2 | 33 +++++ tests/qemu-iotests/178.out.raw | 33 +++++ tests/qemu-iotests/check | 5 + tests/qemu-iotests/group | 1 + 13 files changed, 651 insertions(+), 94 deletions(-) create mode 100755 tests/qemu-iotests/178 create mode 100644 tests/qemu-iotests/178.out.qcow2 create mode 100644 tests/qemu-iotests/178.out.raw -- 2.9.3