mirror of
https://github.com/qemu/qemu.git
synced 2024-11-23 19:03:38 +08:00
qemu-img: Fix convert -n -B for backing-less targets
s.target_has_backing does not reflect whether the target BDS has a
backing file; it only tells whether we should use a backing file during
conversion (specified by -B).
As such, if you use convert -n, the target does not necessarily actually
have a backing file, and then dereferencing out_bs->backing fails here.
When converting to an existing file, we should set
target_backing_sectors to a negative value, because first, as the
comment explains, this value is only used for optimization, so it is
always fine to do that.
Second, we use this value to determine where the target must be
initialized to zeroes (overlays are initialized to zero after the end of
their backing file). When converting to an existing file, we cannot
assume that to be true.
Cc: qemu-stable@nongnu.org
Fixes: 351c8efff9
("qemu-img: Special post-backing convert handling")
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200121155915.98232-2-mreitz@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
4dddeac115
commit
c69291e712
@ -2523,7 +2523,7 @@ static int img_convert(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (s.target_has_backing) {
|
||||
if (s.target_has_backing && s.target_is_new) {
|
||||
/* Errors are treated as "backing length unknown" (which means
|
||||
* s.target_backing_sectors has to be negative, which it will
|
||||
* be automatically). The backing file length is used only
|
||||
|
Loading…
Reference in New Issue
Block a user