(Fun fact: This series has been lying around on my disk since last November. I guess I forgot to send it because I still wanted to review it before sending it out, and that it what I forgot to do. Well, and now Berto noticed that we ought to fix something.)
There are some issues regarding filename generation right now: - You always get a JSON filename if you set even a single qcow2-specific runtime options (as long as it does not have a dot in it, which is a bug, too, but here it is working in our favor...). That is not nice and actually breaks the usage of backing files with relative filenames with such qcow2 BDS. - As hinted above, you cannot use relative backing filenames with BDS that have a JSON filename only, even though qemu might be able to obtain the directory name by walking through the BDS graph to the protocol level. - Overriding the backing file at runtime should invalidate the filename because it actually changes the BDS's data. Therefore, we need to force a JSON filename in that case, containing the backing file override. - Much of our code assumes paths never to exceed PATH_MAX in length. This is wrong, at least because of JSON filenames. This should be fixed wherever the opportunity arises. This series addresses the first issue by splitting off code from bdrv_refresh_filename() into bdrv_default_refresh_format_filename() and bdrv_default_refresh_protocol_filename(). The former will take a boolean signifying whether the driver-specific runtime options are actually significant for the BDS data (guest-visible content). For qcow2, they never are, therefore, the qcow2 driver has to implement bdrv_refresh_filename() by invoking bdrv_default_refresh_format_filename() with the boolean set appropriately (deviating from the actual default implementation which has to assume that all driver-specific runtime options are significant). [Patches 4 -- 7] The second issue is addressed by introducing bdrv_dirname() which returns the directory of a specific BDS. By default, this is obtained by walking through the BDS graph to the protocol level and processing that BDS's filename (exact_filename, to be exact). This behavior can be overridden by any block driver along the path implementing bdrv_dirname() itself, or by the user explicitly specifying the 'base-directory' option for any BDS node. [Patches 11, 13 -- 18] The third issue is addressed by paying respect to the backing file options, and noting whether any of the backing file's options have been overridden in a way that make opening the backing file implicitly (using the filename specified in the overlay file) impossible. [Patches 2 -- 3] The fourth issue has been addressed as far as it made sense to do it along fixing the second one. [Patch 8 -- 10] Furthermore, there are two fixes to code touched in this series. [Patches 1 and 12] Max Reitz (19): block: Use children list in bdrv_refresh_filename block: Add BDS.backing_overridden block: Respect backing bs in bdrv_refresh_filename block: Add bdrv_default_refresh_format_filename block: Add bdrv_default_refresh_protocol_filename block: Make bdrv_default_refresh_format_filename public qcow2: Implement bdrv_refresh_filename() block: Make path_combine() return the path block: bdrv_get_full_backing_filename_from_...'s ret. val. block: bdrv_get_full_backing_filename's ret. val. block: Add bdrv_make_absolute_filename() block: Fix bdrv_find_backing_image() block: Add bdrv_dirname() blkverify: Make bdrv_dirname() return NULL quorum: Make bdrv_dirname() return NULL block/nbd: Implement bdrv_dirname() block: Use bdrv_dirname() for relative filenames block: Add 'base-directory' BDS option iotests: Add quorum case to test 110 block.c | 340 +++++++++++++++++++++++++++--------------- block/blkverify.c | 13 +- block/nbd.c | 29 ++++ block/qapi.c | 12 +- block/qcow2.c | 8 + block/quorum.c | 12 +- block/vmdk.c | 11 +- include/block/block.h | 15 +- include/block/block_int.h | 7 + qapi/block-core.json | 9 ++ tests/qemu-iotests/051.out | 8 +- tests/qemu-iotests/051.pc.out | 8 +- tests/qemu-iotests/110 | 51 ++++++- tests/qemu-iotests/110.out | 11 +- 14 files changed, 372 insertions(+), 162 deletions(-) -- 2.8.0
