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). This series (as of v6) depends on the "[PATCH 0/2] qcow2: Fix discard" series. v6: - Patch 1: Rebased on "[PATCH 0/2] qcow2: Fix discard" - Patch 2: - use QCOW2_DISCARD_SNAPSHOT [Kevin] - increase the number of clusters discarded per step [Kevin] - Patch 3: Added. This patch adds a much faster way of emptying a qcow2 image as long as there are no internal snapshots. It is however optional, and may therefore be excluded from this series without causing problems, as long as patch 13 is excluded as well which adds a test case for this implementation. - Patch 6 (previously 5): Changed due to Fam's fixes in mirror.c - Patch 8: Completely reworked from previous patch 7: - add -d flag for inhibiting bdrv_make_empty() [Eric] - no need to empty the whole backing chain; -d will be implicit whenever -b is given as well, therefore only the top image has to be emptied (if any) [Eric] - Patch 9 (previously 8): - fixed spelling mistake [Eric] - swapped order of p and q in getopt() [Eric] - rebased on patch 8's changes - Patch 10 (previously 9): - -b implies -d [Eric] - rebased on patch 8's changes - Patch 12 (previously 11): - if -b is given, no image will be emptied as of this version; the test has been adjusted accordingly - bumped test number to 092 to avoid conflict with Fam's series - Patch 13: Added as a test for the added patch 3. - Patch 14: - assert that data/offset == data/len after the block job finishes [Eric] - rebased on Fam's changes in iotests.py:wait_until_completed git-backport-diff output against v5: 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:[0013] [FC] 'qcow2: Allow "full" discard' 002/14:[0035] [FC] 'qcow2: Implement bdrv_make_empty()' 003/14:[down] 'qcow2: Optimize bdrv_make_empty()' 004/14:[----] [--] 'blockjob: Introduce block_job_complete_sync()' 005/14:[----] [--] 'blockjob: Add "ready" field' 006/14:[0008] [FC] 'block/mirror: Improve progress report' 007/14:[----] [--] 'qemu-img: Implement commit like QMP' 008/14:[down] 'qemu-img: Empty image after commit' 009/14:[0022] [FC] 'qemu-img: Enable progress output for commit' 010/14:[0021] [FC] 'qemu-img: Specify backing file for commit' 011/14:[----] [--] 'iotests: Add _filter_qemu_img_map' 012/14:[0022] [FC] 'iotests: Add test for backing-chain commits' 013/14:[down] 'iotests: Add test for qcow2's bdrv_make_empty' 014/14:[0005] [FC] '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 | 32 ++-- block/qcow2-cluster.c | 27 ++- block/qcow2-snapshot.c | 2 +- block/qcow2.c | 384 ++++++++++++++++++++++++++++++++++++++- block/qcow2.h | 2 +- blockjob.c | 46 ++++- include/block/blockjob.h | 20 ++ qapi-schema.json | 4 +- qemu-img-cmds.hx | 4 +- qemu-img.c | 147 ++++++++++++--- qemu-img.texi | 13 +- tests/qemu-iotests/040 | 4 +- tests/qemu-iotests/041 | 3 +- tests/qemu-iotests/092 | 108 +++++++++++ tests/qemu-iotests/092.out | 59 ++++++ tests/qemu-iotests/093 | 72 ++++++++ tests/qemu-iotests/093.out | 26 +++ tests/qemu-iotests/common.filter | 7 + tests/qemu-iotests/group | 2 + tests/qemu-iotests/iotests.py | 3 +- 21 files changed, 900 insertions(+), 67 deletions(-) create mode 100755 tests/qemu-iotests/092 create mode 100644 tests/qemu-iotests/092.out create mode 100755 tests/qemu-iotests/093 create mode 100644 tests/qemu-iotests/093.out -- 1.9.2