Issue #1: Sometimes we can have a wrong backing BDS for the target after a mirror block job. In "existing" mode with drive-mirror, or when using blockdev-mirror, it's generally the user's fault. In "absolute-paths" mode this only means that after a sync=full drive-mirror, the target may have a backing file, but this will not change its visible data, so it's "fine".
Still, it's ugly. Issue #2: Currently the backing chain of the target is basically opened using bdrv_open_backing_file() (except for sometimes™). This results in multiple BDSs for a single physical file, which is bad. In most use cases, this is only temporary, but it still is bad. We can just reuse the existing backing chain of the source, so we should do so. Patch 2 fixes the issue. Patch 1 allows change_parent_backing_link() to replace a BDS by its immediate overlay (which is necessary so that patch 2 can set the source BDS as the backing BDS of the target (sync=none) in mirror_complete(), i.e. before bdrv_replace_in_backing_chain() is called in mirror_exit()). Patch 3 adds a test. v2: - Move the whole logic to mirror_complete(). This has the benefit of resolving the bdrv_open_backing_file() issue with multiple BDSs being open for a single physical file (which is a very real issue when it comes to image locking). - However, this also has the drawback of requiring patch 1. So it needed to be added. git-backport-diff against v1: 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/3:[down] 'block: Allow replacement of a BDS by its overlay' 002/3:[0030] [FC] 'block/mirror: Fix target backing BDS' 003/3:[----] [--] 'iotests: Add test for post-mirror backing chains' Max Reitz (3): block: Allow replacement of a BDS by its overlay block/mirror: Fix target backing BDS iotests: Add test for post-mirror backing chains block.c | 23 +++-- block/mirror.c | 21 +++-- tests/qemu-iotests/155 | 218 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/155.out | 5 ++ tests/qemu-iotests/group | 1 + 5 files changed, 251 insertions(+), 17 deletions(-) create mode 100755 tests/qemu-iotests/155 create mode 100644 tests/qemu-iotests/155.out -- 2.8.3