bdrv_replace_in_backing_chain() sometimes does what is advertised (if the new node does not have a backing file yet and if it hasn't been in the same backing chain already), but this is not what the mirror block job (the sole user of that function) actually needs. In fact, it only needs this behavior in 'top' sync mode.
In 'none' sync mode, we need to use the old BDS as the new backing BDS; in 'full' sync mode, we should not set any backing BDS at all. And if we need to set a backing BDS, we should always do so, regardless of whether the new BDS already has one. Therefore, bdrv_replace_in_backing_chain() should not attempt to find out which backing BDS is the right one. Instead, we should leave that to the mirror block job, namely mirror_exit(). Max Reitz (2): block/mirror: Fix target backing BDS iotests: Add test for post-mirror backing chains block.c | 8 -- block/mirror.c | 13 +++ tests/qemu-iotests/155 | 218 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/155.out | 5 ++ tests/qemu-iotests/group | 1 + 5 files changed, 237 insertions(+), 8 deletions(-) create mode 100755 tests/qemu-iotests/155 create mode 100644 tests/qemu-iotests/155.out -- 2.8.3