qemu: fix the bug reported by qemu-iotests case 055
v2 cover qemu: fix the bug reported by qemu-iotests case 055
Hi all,
v2 includes changes due to review comments by Kevin Wolf(thanks to Kevin).
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 (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 v2 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] [Qemu-stable] [PATCH v2 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 39 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]>--- 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] [Qemu-stable] [PATCH v2 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 34 lines · Fam Zheng
Quoted 33 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]>--- 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);
Quoted 7 lines
Quoted 6 lines
block/vmdk.c +0
-0n_bytes = buf_len +sizeof (VmdkGrainMarker); iov = (struct iovec ) {Signature · 1 line
2.8.4Reviewed-by Fam Zheng <[email protected]>
Thanks!
Signature · 1 line
QingFeng Hao(Robin)
Re: [Qemu-devel] [PATCH v2 1/1] block/vmdk: Fix the endian problem of buf_len and lba
In reply to QingFeng HaoHi QingFeng,
I just have a question that whether the marker->data need convert?
I've no idea, just suddenly realized this question.
Jing
Quoted 35 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]>--- 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 v2 1/1] block/vmdk: Fix the endian problem of buf_len and lba
Quoted 8 lines · liujing
Hi QingFeng,
I just have a question that whether the
marker->dataneed convert?I've no idea, just suddenly realized this question.
nope, the data is type of char * for the compressed data stream, so no endian issue. thanks.
Quoted 40 lines
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]>--- 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
QingFeng Hao(Robin)
Sorry, missed Cc qemu-stable in this patch.
Quoted 29 lines · QingFeng Hao
Hi all,
v2 includes changes due to review comments by Kevin Wolf(thanks to Kevin).v2:
* Add endian conversion for lba field invmdk_write_extent. Based on master's commit:00227fefd205: Update version for v2.8.0-rc1 releasev1:
* 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 releaseUpstream 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 argumentThanks!
QingFeng Hao (1):
block/vmdk: Fix the endian problem ofbuf_lenand lbablock/vmdk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
QingFeng Hao(Robin)