mirror of
https://github.com/qemu/qemu.git
synced 2025-08-10 21:34:57 +00:00
vmdk: correctly propagate errors
Now that we can return the "right" errors, use the Error** parameter to pass them back instead of just printing them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
37f09e5e3d
commit
89ac8480a8
@ -572,6 +572,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|||||||
error_setg_errno(errp, -ret,
|
error_setg_errno(errp, -ret,
|
||||||
"Could not read header from file '%s'",
|
"Could not read header from file '%s'",
|
||||||
file->filename);
|
file->filename);
|
||||||
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (header.capacity == 0) {
|
if (header.capacity == 0) {
|
||||||
uint64_t desc_offset = le64_to_cpu(header.desc_offset);
|
uint64_t desc_offset = le64_to_cpu(header.desc_offset);
|
||||||
@ -641,7 +642,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|||||||
char buf[64];
|
char buf[64];
|
||||||
snprintf(buf, sizeof(buf), "VMDK version %d",
|
snprintf(buf, sizeof(buf), "VMDK version %d",
|
||||||
le32_to_cpu(header.version));
|
le32_to_cpu(header.version));
|
||||||
qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
||||||
bs->device_name, "vmdk", buf);
|
bs->device_name, "vmdk", buf);
|
||||||
return -ENOTSUP;
|
return -ENOTSUP;
|
||||||
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
|
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
|
||||||
@ -654,7 +655,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (le32_to_cpu(header.num_gtes_per_gt) > 512) {
|
if (le32_to_cpu(header.num_gtes_per_gt) > 512) {
|
||||||
error_report("L2 table size too big");
|
error_setg(errp, "L2 table size too big");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +671,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|||||||
}
|
}
|
||||||
if (bdrv_getlength(file) <
|
if (bdrv_getlength(file) <
|
||||||
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) {
|
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) {
|
||||||
error_report("File truncated, expecting at least %lld bytes",
|
error_setg(errp, "File truncated, expecting at least %lld bytes",
|
||||||
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE);
|
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,7 @@ no file open, try 'help open'
|
|||||||
|
|
||||||
=== Testing too big L2 table size ===
|
=== Testing too big L2 table size ===
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||||
L2 table size too big
|
qemu-io: can't open device TEST_DIR/t.vmdk: L2 table size too big
|
||||||
qemu-io: can't open device TEST_DIR/t.vmdk: Could not open 'TEST_DIR/t.vmdk': Invalid argument
|
|
||||||
no file open, try 'help open'
|
no file open, try 'help open'
|
||||||
|
|
||||||
=== Testing too big L1 table size ===
|
=== Testing too big L1 table size ===
|
||||||
@ -2045,8 +2044,7 @@ RW 12582912 VMFS "dummy.IMGFMT" 1
|
|||||||
|
|
||||||
=== Testing truncated sparse ===
|
=== Testing truncated sparse ===
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
|
||||||
qemu-img: File truncated, expecting at least 13172736 bytes
|
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
|
||||||
qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'TEST_DIR/t.IMGFMT': Invalid argument
|
|
||||||
|
|
||||||
=== Testing version 3 ===
|
=== Testing version 3 ===
|
||||||
image: TEST_DIR/iotest-version3.IMGFMT
|
image: TEST_DIR/iotest-version3.IMGFMT
|
||||||
|
Loading…
Reference in New Issue
Block a user