[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/18] qemu-img: Fix convert -n -B for backing-less targets
From: |
Max Reitz |
Subject: |
[PULL 15/18] qemu-img: Fix convert -n -B for backing-less targets |
Date: |
Thu, 20 Feb 2020 17:07:07 +0100 |
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: address@hidden
Fixes: 351c8efff9ad809c822d55620df54d575d536f68
("qemu-img: Special post-backing convert handling")
Signed-off-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: John Snow <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
qemu-img.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/qemu-img.c b/qemu-img.c
index 0faf2cd2f5..804630a368 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -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
--
2.24.1
- [PULL 07/18] block: always fill entire LUKS header space with zeros, (continued)
- [PULL 07/18] block: always fill entire LUKS header space with zeros, Max Reitz, 2020/02/20
- [PULL 08/18] block/backup-top: fix flags handling, Max Reitz, 2020/02/20
- [PULL 09/18] iotests/279: Fix for non-qcow2 formats, Max Reitz, 2020/02/20
- [PULL 10/18] block/nbd: Fix hang in .bdrv_close(), Max Reitz, 2020/02/20
- [PULL 11/18] block: Generic file creation fallback, Max Reitz, 2020/02/20
- [PULL 12/18] file-posix: Drop hdev_co_create_opts(), Max Reitz, 2020/02/20
- [PULL 13/18] iscsi: Drop iscsi_co_create_opts(), Max Reitz, 2020/02/20
- [PULL 14/18] iotests: Add test for image creation fallback, Max Reitz, 2020/02/20
- [PULL 15/18] qemu-img: Fix convert -n -B for backing-less targets,
Max Reitz <=
- [PULL 16/18] iotests: Test convert -n -B to backing-less target, Max Reitz, 2020/02/20
- [PULL 17/18] block: Fix VM size field width in snapshot dump, Max Reitz, 2020/02/20
- [PULL 18/18] iotests: Test snapshot -l field separation, Max Reitz, 2020/02/20
- Re: [PULL 00/18] Block patches, Peter Maydell, 2020/02/21