Currently, the configuration of blkdebug and blkverify is done through the "filename" alone. There is now way of manually choosing blkdebug or blkverify as a driver and using a normal image filename.
In the case of blkdebug, the filename starts with the protocol prefix, follows up with the name of a configuration file and ends with the name of the image file. In the case of blkverify, the filename starts with the protocol prefix, follows up with the raw reference image filename and ends with the name of the image file. This patch allows the configuration of both drivers completely through QMP and accordingly command-line options. The driver has to be selected through the driver option (or similar), the image filename may be given either as the filename itself or through a x.filename option, where "x" depends on the driver. Further options may be required depending on the driver. In case of blkverify, the test image may be specified either through the filename or as a BlockdevRef reference through the "test" option. The raw image is referenced as "raw". In case of blkdebug, one may either set the "config" option to the filename of a configuration file, or the content of the configuration file may be given directly (as options). The image filename is either specified as the filename or referenced through the "image" option. v7: - Addressed Eric's and Stefan's comments (first number is patch number in v6, second is patch number in this series): - Patch 3/3: Adjusted comment - Patch 4/4: Hopefully finally fixed - Patch 5/5: Rebased on Peter's series (don't use qemu_opts_create_nofail); note that this does not add a dependency on that series - Patch 8/8: Rebased on Fam's series (or rather, Stefan's block branch); the changes in VMDK introduced new calls to bdrv_file_open(), which have to be adjusted as is done in the remainder of the patch - Patch 21/-: Added - Patch 22/-: Added v6: - Addressed Kevin's and Eric's comments (first number is patch number in v5, second is patch number in this series): - Patch 4/4: Adjusted comment - Patch 5/-: Dropped - Patch 11/10: Guard against !drv && !file before find_image_format() - Patch -/11: Added - Patch -/12: Added - Patch 12/13: Removed unnecessary hunk and squashed next patch into this one - Patch 13/-: Squashed into previous patch - Patch 15/15: Dropped static open_image() in favor of the global bdrv_open_image() - Patch 16/-: Dropped - Patch 17/16: Dropped static open_image() in favor of the global bdrv_open_image(); also, disable format auto-detection for the raw image - Patch 18/17: Drop check for !filename since the filename is always passed to this function - Patch 19/18: Add "errno" to the list of polluted words in qapi.py rather than introduce a new alias - Patch 20/19: Use enumeration for the blkdebug trigger events; also, we can and must use "errno" now instead of "error" - Patch 22/21: Fix test by increasing the image size; add actually working tests for blkverify failures; add test for blkverify using an already existing block device as the raw image - Patch -/22: Added v5: - Addressed Fam's comments: - Patch 4: Asserted against prefix == NULL in qdict_flatten_qlist() - Patch 4: Support other types than QDicts and QLists in QLists in qdict_flatten_qlist() - Patch 4: Modified comment above qdict_flatten() to include the functionality of qdict_flatten_qlist() - Patch 8 (now patch 9): Removed goto fail; in favor of directly returning in the if (reference) patch - this fixes a double QDECREF(options) as well as two bs dereferences with bs being NULL - Patch 21 (now patch 22): Added reason for not using Python to the commit message - Added patch 5: Cleans up qdict_flatten_qdict() which contains a now unused delete variable v4: - Fixed a memleak in qdict_flatten_qlist() in patch 4 v3: - The first few patches are probably similar to the ones from the previous series; but it's probably best to see this series as a completely new one. git-backport-diff against v6: 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/24:[----] [--] 'blkdebug: Use errp for read_config()' 002/24:[----] [--] 'blkdebug: Don't require sophisticated filename' 003/24:[0013] [FC] 'qdict: Add qdict_array_split()' 004/24:[0003] [FC] 'qapi: extend qdict_flatten() for QLists' 005/24:[0007] [FC] 'qemu-option: Add qemu_config_parse_qdict()' 006/24:[----] [--] 'blkdebug: Always call read_config()' 007/24:[----] [--] 'blkdebug: Use command-line in read_config()' 008/24:[0004] [FC] 'block: Allow reference for bdrv_file_open()' 009/24:[----] [--] 'block: Pass reference to bdrv_file_open()' 010/24:[----] [--] 'block: Allow block devices without files' 011/24:[----] [--] 'block: Add bdrv_open_image()' 012/24:[----] [--] 'block: Use bdrv_open_image() in bdrv_open()' 013/24:[----] [--] 'block: Allow recursive "file"s' 014/24:[----] [--] 'blockdev: Move "file" to legacy_opts' 015/24:[----] [-C] 'blkdebug: Allow command-line file configuration' 016/24:[----] [-C] 'blkverify: Allow command-line configuration' 017/24:[----] [--] 'blkverify: Don't require protocol filename' 018/24:[----] [--] 'qapi: Add "errno" to the list of polluted words' 019/24:[----] [--] 'qapi: QMP interface for blkdebug and blkverify' 020/24:[----] [--] 'qemu-io: Make filename optional' 021/24:[down] 'tests: Add test for qdict_array_split()' 022/24:[down] 'tests: Add test for qdict_flatten()' 023/24:[----] [--] 'iotests: Test new blkdebug/blkverify interface' 024/24:[----] [--] 'iotests: Test file format nesting' Max Reitz (24): blkdebug: Use errp for read_config() blkdebug: Don't require sophisticated filename qdict: Add qdict_array_split() qapi: extend qdict_flatten() for QLists qemu-option: Add qemu_config_parse_qdict() blkdebug: Always call read_config() blkdebug: Use command-line in read_config() block: Allow reference for bdrv_file_open() block: Pass reference to bdrv_file_open() block: Allow block devices without files block: Add bdrv_open_image() block: Use bdrv_open_image() in bdrv_open() block: Allow recursive "file"s blockdev: Move "file" to legacy_opts blkdebug: Allow command-line file configuration blkverify: Allow command-line configuration blkverify: Don't require protocol filename qapi: Add "errno" to the list of polluted words qapi: QMP interface for blkdebug and blkverify qemu-io: Make filename optional tests: Add test for qdict_array_split() tests: Add test for qdict_flatten() iotests: Test new blkdebug/blkverify interface iotests: Test file format nesting block.c | 123 ++++++++++++++++++++--- block/blkdebug.c | 59 ++++++----- block/blkverify.c | 29 ++---- block/cow.c | 3 +- block/qcow.c | 3 +- block/qcow2.c | 2 +- block/qed.c | 4 +- block/sheepdog.c | 4 +- block/vhdx.c | 2 +- block/vmdk.c | 8 +- blockdev.c | 19 ++-- include/block/block.h | 6 +- include/qapi/qmp/qdict.h | 1 + include/qemu/config-file.h | 6 ++ qapi-schema.json | 113 ++++++++++++++++++++- qemu-io.c | 10 +- qobject/qdict.c | 91 +++++++++++++++-- scripts/qapi.py | 2 +- tests/check-qdict.c | 156 +++++++++++++++++++++++++++++ tests/qemu-iotests/051.out | 2 +- tests/qemu-iotests/071 | 239 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/071.out | 90 +++++++++++++++++ tests/qemu-iotests/072 | 69 +++++++++++++ tests/qemu-iotests/072.out | 21 ++++ tests/qemu-iotests/group | 2 + util/qemu-config.c | 100 +++++++++++++++++++ 26 files changed, 1069 insertions(+), 95 deletions(-) create mode 100755 tests/qemu-iotests/071 create mode 100644 tests/qemu-iotests/071.out create mode 100755 tests/qemu-iotests/072 create mode 100644 tests/qemu-iotests/072.out -- 1.8.5.1