Skip to content

Commit

Permalink
block/drive-mirror: Reuse backing HD for sync=none
Browse files Browse the repository at this point in the history
For "none" sync mode in "absolute-paths" mode, the current image should
be used as the backing file for the newly created image.

The current behavior is:
a) If the image to be mirrored has a backing file, use that (which is
   wrong, since the operations recorded by "none" are applied to the
   image itself, not to its backing file).
b) If the image to be mirrored lacks a backing file, the target doesn't
   have one either (which is not really wrong, but not really right,
   either; "none" records a set of operations executed on the image
   file, therefore having no backing file to apply these operations on
   seems rather pointless).

For a, this is clearly a bugfix. For b, it is still a bugfix, although
it might break existing API - but since that case crashed qemu just
three weeks ago (before 1452686), we
can safely assume there is no such API relying on that case yet.

Suggested-by: Paolo Bonzini <[email protected]>
Signed-off-by: Max Reitz <[email protected]>
Reviewed-by: Paolo Bonzini <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Message-id: [email protected]
Signed-off-by: Anthony Liguori <[email protected]>
  • Loading branch information
XanClic authored and Anthony Liguori committed Nov 27, 2013
1 parent 7457fe9 commit 117e0c8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions blockdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,9 @@ void qmp_drive_mirror(const char *device, const char *target,
if (!source && sync == MIRROR_SYNC_MODE_TOP) {
sync = MIRROR_SYNC_MODE_FULL;
}
if (sync == MIRROR_SYNC_MODE_NONE) {
source = bs;
}

size = bdrv_getlength(bs);
if (size < 0) {
Expand Down

0 comments on commit 117e0c8

Please sign in to comment.