]> git.ipfire.org Git - thirdparty/qemu.git/commit
mirror: Fail gracefully for source == target
authorKevin Wolf <kwolf@redhat.com>
Tue, 14 Aug 2018 09:52:25 +0000 (11:52 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 19 Mar 2019 02:38:54 +0000 (21:38 -0500)
commit1662d4d4901f0ee8499a6143d98e15960227f4f4
tree6c9e4728cb2acff45d09555fea1e0a32eed3c8e2
parentc89985bad953c10775996f10723d1492b4496adf
mirror: Fail gracefully for source == target

blockdev-mirror with the same node for source and target segfaults
today: A node is in its own backing chain, so mirror_start_job() decides
that this is an active commit. When adding the intermediate nodes with
block_job_add_bdrv(), it starts the iteration through the subchain with
the backing file of source, though, so it never reaches target and
instead runs into NULL at the base.

While we could fix that by starting with source itself, there is no
point in allowing mirroring a node into itself and I wouldn't be
surprised if this caused more problems later.

So just check for this scenario and error out.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 86fae10c64d642256cf019e6829929fa0d259c7a)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/mirror.c
tests/qemu-iotests/041
tests/qemu-iotests/041.out