diff options
author | BenoƮt Canet <benoit.canet@irqsave.net> | 2014-06-27 18:25:25 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-06-27 20:00:00 +0200 |
commit | 09158f00e0fdb506dcbf36f67c615b7f6c604c5a (patch) | |
tree | f7a4f03efed4ae74d92c1dc3d1b9d4bef51a6780 /block.c | |
parent | 823c686356e6758bacb46d3a316b841536d6d707 (diff) |
block: Add replaces argument to drive-mirror
drive-mirror will bdrv_swap the new BDS named node-name with the one
pointed by replaces when the mirroring is finished.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -5766,3 +5766,28 @@ bool bdrv_is_first_non_filter(BlockDriverState *candidate) return false; } + +BlockDriverState *check_to_replace_node(const char *node_name, Error **errp) +{ + BlockDriverState *to_replace_bs = bdrv_find_node(node_name); + if (!to_replace_bs) { + error_setg(errp, "Node name '%s' not found", node_name); + return NULL; + } + + if (bdrv_op_is_blocked(to_replace_bs, BLOCK_OP_TYPE_REPLACE, errp)) { + return NULL; + } + + /* We don't want arbitrary node of the BDS chain to be replaced only the top + * most non filter in order to prevent data corruption. + * Another benefit is that this tests exclude backing files which are + * blocked by the backing blockers. + */ + if (!bdrv_is_first_non_filter(to_replace_bs)) { + error_setg(errp, "Only top most non filter can be replaced"); + return NULL; + } + + return to_replace_bs; +} |