aboutsummaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorBenoƮt Canet <benoit.canet@irqsave.net>2014-06-27 18:25:25 +0200
committerKevin Wolf <kwolf@redhat.com>2014-06-27 20:00:00 +0200
commit09158f00e0fdb506dcbf36f67c615b7f6c604c5a (patch)
treef7a4f03efed4ae74d92c1dc3d1b9d4bef51a6780 /blockdev.c
parent823c686356e6758bacb46d3a316b841536d6d707 (diff)
downloadqemu-09158f00e0fdb506dcbf36f67c615b7f6c604c5a.zip
qemu-09158f00e0fdb506dcbf36f67c615b7f6c604c5a.tar.gz
qemu-09158f00e0fdb506dcbf36f67c615b7f6c604c5a.tar.bz2
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 'blockdev.c')
-rw-r--r--blockdev.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/blockdev.c b/blockdev.c
index 9433012..69b7c2a 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2100,6 +2100,7 @@ BlockDeviceInfoList *qmp_query_named_block_nodes(Error **errp)
void qmp_drive_mirror(const char *device, const char *target,
bool has_format, const char *format,
bool has_node_name, const char *node_name,
+ bool has_replaces, const char *replaces,
enum MirrorSyncMode sync,
bool has_mode, enum NewImageMode mode,
bool has_speed, int64_t speed,
@@ -2187,6 +2188,29 @@ void qmp_drive_mirror(const char *device, const char *target,
return;
}
+ if (has_replaces) {
+ BlockDriverState *to_replace_bs;
+
+ if (!has_node_name) {
+ error_setg(errp, "a node-name must be provided when replacing a"
+ " named node of the graph");
+ return;
+ }
+
+ to_replace_bs = check_to_replace_node(replaces, &local_err);
+
+ if (!to_replace_bs) {
+ error_propagate(errp, local_err);
+ return;
+ }
+
+ if (size != bdrv_getlength(to_replace_bs)) {
+ error_setg(errp, "cannot replace image with a mirror image of "
+ "different size");
+ return;
+ }
+ }
+
if ((sync == MIRROR_SYNC_MODE_FULL || !source)
&& mode != NEW_IMAGE_MODE_EXISTING)
{
@@ -2231,7 +2255,12 @@ void qmp_drive_mirror(const char *device, const char *target,
return;
}
- mirror_start(bs, target_bs, speed, granularity, buf_size, sync,
+ /* pass the node name to replace to mirror start since it's loose coupling
+ * and will allow to check whether the node still exist at mirror completion
+ */
+ mirror_start(bs, target_bs,
+ has_replaces ? replaces : NULL,
+ speed, granularity, buf_size, sync,
on_source_error, on_target_error,
block_job_cb, bs, &local_err);
if (local_err != NULL) {