qemu-img should use QMP commands whenever possible in order to ensure feature completeness of both online and offline image operations. For the "commit" command, this is relatively easy, so implement it first (in the hope that indeed others will follow).
As qemu-img does not have access to QMP (due to QMP being intertwined with basically everything in qemu), we cannot directly use QMP, but at least use the functions the corresponding QMP commands are using (which would be "block-commit", in this case). I'll still take a look on Kevin's proposal for patch 3 (make use of lazy refcounts to simplify emptying a snapshot-less qcow2 image), but I still think we'll need the size-calculation function anyway; that is why I sent this version which still uses that function and no lazy refcounts. In case using lazy refcounts turns out to be vastly easier (which I actually think it will), I'll send an alternative for patch 3; the other patches should be untouched by the decision which version is used (except probably the test from patch 13). v9: Rebase on master - Patch 5: block_job_ready() is now called block_job_event_ready() and has been changed in the meantime - Patch 6: rebased on the fixes for zero-length mirrors - Patch 12: test number 094 is now taken as well, move to 097 - Patch 13: - test number 095 is taken, move to 098 - remove blkdebug.conf when test is done - filter out test directory and image format from the commit output Key: [----] : patches are identical [####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively 001/14:[----] [--] 'qcow2: Allow "full" discard' 002/14:[----] [--] 'qcow2: Implement bdrv_make_empty()' 003/14:[----] [--] 'qcow2: Optimize bdrv_make_empty()' 004/14:[----] [--] 'blockjob: Introduce block_job_complete_sync()' 005/14:[0004] [FC] 'blockjob: Add "ready" field' 006/14:[0006] [FC] 'block/mirror: Improve progress report' 007/14:[----] [--] 'qemu-img: Implement commit like QMP' 008/14:[----] [--] 'qemu-img: Empty image after commit' 009/14:[----] [--] 'qemu-img: Enable progress output for commit' 010/14:[----] [--] 'qemu-img: Specify backing file for commit' 011/14:[----] [--] 'iotests: Add _filter_qemu_img_map' 012/14:[0004] [FC] 'iotests: Add test for backing-chain commits' 013/14:[0013] [FC] 'iotests: Add test for qcow2's bdrv_make_empty' 014/14:[----] [-C] 'iotests: Omit length/offset test in 040 and 041' Max Reitz (14): qcow2: Allow "full" discard qcow2: Implement bdrv_make_empty() qcow2: Optimize bdrv_make_empty() blockjob: Introduce block_job_complete_sync() blockjob: Add "ready" field block/mirror: Improve progress report qemu-img: Implement commit like QMP qemu-img: Empty image after commit qemu-img: Enable progress output for commit qemu-img: Specify backing file for commit iotests: Add _filter_qemu_img_map iotests: Add test for backing-chain commits iotests: Add test for qcow2's bdrv_make_empty iotests: Omit length/offset test in 040 and 041 block/Makefile.objs | 2 +- block/mirror.c | 34 ++-- block/qcow2-cluster.c | 27 ++- block/qcow2-snapshot.c | 2 +- block/qcow2.c | 388 ++++++++++++++++++++++++++++++++++++++- block/qcow2.h | 2 +- blockjob.c | 42 ++++- include/block/blockjob.h | 20 ++ qapi/block-core.json | 4 +- qemu-img-cmds.hx | 4 +- qemu-img.c | 149 ++++++++++++--- qemu-img.texi | 13 +- tests/qemu-iotests/040 | 4 +- tests/qemu-iotests/041 | 3 +- tests/qemu-iotests/097 | 122 ++++++++++++ tests/qemu-iotests/097.out | 119 ++++++++++++ tests/qemu-iotests/098 | 75 ++++++++ tests/qemu-iotests/098.out | 26 +++ tests/qemu-iotests/common.filter | 7 + tests/qemu-iotests/group | 2 + tests/qemu-iotests/iotests.py | 3 +- 21 files changed, 981 insertions(+), 67 deletions(-) create mode 100755 tests/qemu-iotests/097 create mode 100644 tests/qemu-iotests/097.out create mode 100755 tests/qemu-iotests/098 create mode 100644 tests/qemu-iotests/098.out -- 2.0.1