vmdk:truncate more one sector in init extent
PATCH 1/1 vmdk:truncate more one sector in init extent
issue:https://gitlab.com/qemu-project/qemu/-/issues/1357 empty vmdk only contains metadata, ovftool failed. So it allocates more one sector for empty disk. the ovftool command line: ovftool input.ovf output.ova
--- block/vmdk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/vmdk.c +2 -1
@@ -2286,7 +2286,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, goto exit; } - ret = blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, + ret =blk_co_truncate (blk, (le64_to_cpu (header.grain_offset) <<9 ) +BDRV_SECTOR_SIZE , + false,PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) { goto exit;
Signature · 1 line
2.39.3
Am 22.08.2024 um 12:52 hat luzhipeng geschrieben:
Quoted 6 lines
issue:https://gitlab.com/qemu-project/qemu/-/issues/1357 empty vmdk only contains metadata, ovftool failed. So it allocates more one sector for empty disk. the ovftool command line: ovftool input.ovf output.ova
Signed-off-by luzhipeng <[email protected]>
I think this commit message needs more of the information from the bug report, otherwise it seems unexplainable why adding an empty sector should make a difference.
block/vmdk.c vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, · line 2292
Quoted 13 lines
block/vmdk.c +2
-1@@ -2286,7 +2286,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, goto exit; } - ret = blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, + ret =blk_co_truncate (blk, (le64_to_cpu (header.grain_offset) <<9 ) +BDRV_SECTOR_SIZE , + false,PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) { goto exit;
This is not a good fix. It means that we will always leave an empty sector after the header, even if more data follows.
Does the problem really only happen with empty images? I think we don't necessarily add an end-of-stream marker for other images either, we just align the image size to full sectors at the end of 'qemu-img convert'.
I wonder if vmdk_co_pwritev_compressed() should be changed to write both a footer and an explicit end-of-stream marker for streamOptimized images in the bytes == 0 case.
Kevin
Quoted 11 lines · Kevin Wolf
Am 22.08.2024 um 12:52 hat luzhipeng geschrieben:
Quoted 6 lines
issue:https://gitlab.com/qemu-project/qemu/-/issues/1357 empty vmdk only contains metadata, ovftool failed. So it allocates more one sector for empty disk. the ovftool command line: ovftool input.ovf output.ova
Signed-off-by luzhipeng <[email protected]>I think this commit message needs more of the information from the bug report, otherwise it seems unexplainable why adding an empty sector should make a difference.
I really don't know the real reason, I suspect it's a special requirement of the ovftool tool, but this issue does exist.
Quoted 17 lines
block/vmdk.c vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, · line 2292
Quoted 13 lines
block/vmdk.c +2
-1@@ -2286,7 +2286,7 @@ vmdk_init_extent(BlockBackend *blk, int64_t filesize, bool flat, bool compress, goto exit; } - ret = blk_co_truncate(blk, le64_to_cpu(header.grain_offset) << 9, false, + ret =blk_co_truncate (blk, (le64_to_cpu (header.grain_offset) <<9 ) +BDRV_SECTOR_SIZE , + false,PREALLOC_MODE_OFF ,0 , errp);if (ret <0 ) { goto exit;This is not a good fix. It means that we will always leave an empty sector after the header, even if more data follows.
Quoted 3 lines
Does the problem really only happen with empty images? I think we don't necessarily add an end-of-stream marker for other images either, we just align the image size to full sectors at the end of 'qemu-img convert'.
this issue indeed exists.it is not fix for aligning the image size
Quoted 8 lines
I wonder if
vmdk_co_pwritev_compressed()should be changed to write both a footer and an explicit end-of-stream marker for streamOptimized images in the bytes == 0 case.Kevin