mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
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>
This commit is contained in:
parent
823c686356
commit
09158f00e0
8 changed files with 118 additions and 17 deletions
31
blockdev.c
31
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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue