qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

mirror: Double-check immediately before replacing

There is no guarantee that we can still replace the node we want to
replace at the end of the mirror job. Double-check by calling
bdrv_recurse_can_replace().

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20200218103454.296704-12-mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>

authored by

Max Reitz and committed by
Kevin Wolf
6e9cc051 6b4907cf

+13 -1
+13 -1
block/mirror.c
··· 700 700 * drain potential other users of the BDS before changing the graph. */ 701 701 assert(s->in_drain); 702 702 bdrv_drained_begin(target_bs); 703 - bdrv_replace_node(to_replace, target_bs, &local_err); 703 + /* 704 + * Cannot use check_to_replace_node() here, because that would 705 + * check for an op blocker on @to_replace, and we have our own 706 + * there. 707 + */ 708 + if (bdrv_recurse_can_replace(src, to_replace)) { 709 + bdrv_replace_node(to_replace, target_bs, &local_err); 710 + } else { 711 + error_setg(&local_err, "Can no longer replace '%s' by '%s', " 712 + "because it can no longer be guaranteed that doing so " 713 + "would not lead to an abrupt change of visible data", 714 + to_replace->node_name, target_bs->node_name); 715 + } 704 716 bdrv_drained_end(target_bs); 705 717 if (local_err) { 706 718 error_report_err(local_err);