qemu: fix the bug reported by qemu-iotests case 055
v3 cover qemu: fix the bug reported by qemu-iotests case 055
Hi all,
v3 doesn't have code change but got the reviewed-by from Fam Zheng(thanks to Fam).
v2 includes changes due to review comments by Kevin Wolf(thanks to Kevin).
v3:
* Got reviewed-by from Fam Zheng.
* Based on master's commit:
6a928d25b6: Update version for v2.8.0-rc4 release
v2:
* Add endian conversion for lba field in vmdk_write_extent.
* Based on master's commit:
00227fefd205: Update version for v2.8.0-rc1 release
v1:
* Add patch to fix the bug reported by qemu-iotests case 055. Jing Liu and I found the cause was in vmdk and the fix is in the followed patch.
Based on master's commit:
00227fefd205: Update version for v2.8.0-rc1 release
Upstream master's qemu-iotests case 055 reports the following error:
+qemu-img: Error while reading offset 0 of tests/qemu-iotests/scratch/blockdev-target.img: Invalid argument +qemu-img: Error while reading offset 0 of tests/qemu-iotests/scratch/blockdev-target.img: Invalid argument +qemu-img: Error while reading offset 0 of tests/qemu-iotests/scratch/blockdev-target.img: Invalid argument +qemu-img: Error while reading offset 0 of tests/qemu-iotests/scratch/blockdev-target.img: Invalid argument
Thanks!
QingFeng Hao
QingFeng Hao (1):
block/vmdk: Fix the endian problem of buf_len and lba
block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.8.4
PATCH v3 1/1 block/vmdk: Fix the endian problem of buf_len and lba
The problem was triggered by qemu-iotests case 055. It failed when it was comparing the compressed vmdk image with original test.img.
The cause is that buf_len in vmdk_write_extent wasn't converted to little-endian before it was stored to disk. But later vmdk_read_extent read it and converted it from little-endian to cpu endian. If the cpu is big-endian like s390, the problem will happen and the data length read by vmdk_read_extent will become invalid! The fix is to add the conversion in vmdk_write_extent, meanwhile, repair the endianness problem of lba field which shall also be converted to little-endian before storing to disk.
--- block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
block/vmdk.c +2 -2
@@ -1354,8 +1354,8 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, goto out; } - data->lba = offset >>BDRV_SECTOR_BITS ; - data->size = buf_len; + data->lba =cpu_to_le64 (offset >>BDRV_SECTOR_BITS ); + data->size =cpu_to_le32 (buf_len); n_bytes = buf_len +sizeof (VmdkGrainMarker); iov = (struct iovec ) {
Signature · 1 line
2.8.4
Re: [Qemu-devel] [PATCH v3 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Dears,
We would like to know if this patch will be pulled
into upstream or what else we need to do for it?
Because for upstream, the qemu-iotests case 055 still failed.
Thanks.
Jing
Quoted 36 lines · QingFeng Hao
The problem was triggered by qemu-iotests case 055. It failed when it was comparing the compressed vmdk image with original test.img.
The cause is that
buf_leninvmdk_write_extentwasn't converted to little-endian before it was stored to disk. But latervmdk_read_extentread it and converted it from little-endian to cpu endian. If the cpu is big-endian like s390, the problem will happen and the data length read byvmdk_read_extentwill become invalid! The fix is to add the conversion invmdk_write_extent, meanwhile, repair the endianness problem of lba field which shall also be converted to little-endian before storing to disk.Signed-off-by QingFeng Hao <[email protected]>Signed-off-by Jing Liu <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Reviewed-by Fam Zheng <[email protected]>--- block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/vmdk.c +2
-2@@ -1354,8 +1354,8 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, goto out; } - data->lba = offset >>BDRV_SECTOR_BITS ; - data->size = buf_len; + data->lba =cpu_to_le64 (offset >>BDRV_SECTOR_BITS ); + data->size =cpu_to_le32 (buf_len); n_bytes = buf_len +sizeof (VmdkGrainMarker); iov = (struct iovec ) {
Re: [Qemu-devel] [PATCH v3 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 7 lines · liujing
Dears,
We would like to know if this patch will be pulled
into upstream or what else we need to do for it?
Because for upstream, the qemu-iotests case 055 still failed.
Kevin, would you like to take this or should I do it?
Fam
Quoted 45 lines
Thanks.
Jing
Quoted 36 lines · QingFeng Hao
The problem was triggered by qemu-iotests case 055. It failed when it was comparing the compressed vmdk image with original test.img.
The cause is that
buf_leninvmdk_write_extentwasn't converted to little-endian before it was stored to disk. But latervmdk_read_extentread it and converted it from little-endian to cpu endian. If the cpu is big-endian like s390, the problem will happen and the data length read byvmdk_read_extentwill become invalid! The fix is to add the conversion invmdk_write_extent, meanwhile, repair the endianness problem of lba field which shall also be converted to little-endian before storing to disk.Signed-off-by QingFeng Hao <[email protected]>Signed-off-by Jing Liu <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Reviewed-by Fam Zheng <[email protected]>--- block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)block/vmdk.c +2
-2@@ -1354,8 +1354,8 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, goto out; } - data->lba = offset >>BDRV_SECTOR_BITS ; - data->size = buf_len; + data->lba =cpu_to_le64 (offset >>BDRV_SECTOR_BITS ); + data->size =cpu_to_le32 (buf_len); n_bytes = buf_len +sizeof (VmdkGrainMarker); iov = (struct iovec ) {
Re: [Qemu-devel] [PATCH v3 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 10 lines · Fam Zheng
Quoted 7 lines · liujing
Dears,
We would like to know if this patch will be pulled
into upstream or what else we need to do for it?
Because for upstream, the qemu-iotests case 055 still failed.
Kevin, would you like to take this or should I do it?
Adding Max since he's taking care of the other VMDK fix I posted.
Fam
Re: [Qemu-devel] [Qemu-block] [PATCH v3 1/1] block/vmdk: Fix the endian problem of buf_len and lba
In reply to QingFeng HaoQuoted 12 lines · QingFeng Hao
The problem was triggered by qemu-iotests case 055. It failed when it was comparing the compressed vmdk image with original test.img.
The cause is that
buf_leninvmdk_write_extentwasn't converted to little-endian before it was stored to disk. But latervmdk_read_extentread it and converted it from little-endian to cpu endian. If the cpu is big-endian like s390, the problem will happen and the data length read byvmdk_read_extentwill become invalid! The fix is to add the conversion invmdk_write_extent, meanwhile, repair the endianness problem of lba field which shall also be converted to little-endian before storing to disk.
Quoted 8 lines
Signed-off-by QingFeng Hao <[email protected]>Signed-off-by Jing Liu <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Reviewed-by Fam Zheng <[email protected]>--- block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Thanks, I've applied the patch to my block tree:
https://github.com/XanClic/qemu/commits/block
Max
Re: [Qemu-devel] [Qemu-block] [PATCH v3 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 21 lines · Max Reitz
Quoted 12 lines · QingFeng Hao
The problem was triggered by qemu-iotests case 055. It failed when it was comparing the compressed vmdk image with original test.img.
The cause is that
buf_leninvmdk_write_extentwasn't converted to little-endian before it was stored to disk. But latervmdk_read_extentread it and converted it from little-endian to cpu endian. If the cpu is big-endian like s390, the problem will happen and the data length read byvmdk_read_extentwill become invalid! The fix is to add the conversion invmdk_write_extent, meanwhile, repair the endianness problem of lba field which shall also be converted to little-endian before storing to disk.Quoted 8 lines
Signed-off-by QingFeng Hao <[email protected]>Signed-off-by Jing Liu <[email protected]>Signed-off-by Kevin Wolf <[email protected]>Reviewed-by Fam Zheng <[email protected]>--- block/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 3 lines
Thanks, I've applied the patch to my block tree:
Thanks Max!
Quoted 3 lines
Max
Signature · 1 line
QingFeng Hao(Robin)