|
|
958e1b |
From 39a68fd720126dd9c53af4f7fdeeecc0eeacc1ce Mon Sep 17 00:00:00 2001
|
|
|
958e1b |
Message-Id: <39a68fd720126dd9c53af4f7fdeeecc0eeacc1ce.1418766606.git.jen@redhat.com>
|
|
|
958e1b |
In-Reply-To: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
|
|
|
958e1b |
References: <6f81b4847eb68ebdf54a8f1a771e19d112d74152.1418766606.git.jen@redhat.com>
|
|
|
958e1b |
From: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Date: Thu, 4 Dec 2014 00:05:08 -0600
|
|
|
958e1b |
Subject: [CHANGE 14/31] vmdk: correctly propagate errors
|
|
|
958e1b |
To: rhvirt-patches@redhat.com,
|
|
|
958e1b |
jen@redhat.com
|
|
|
958e1b |
|
|
|
958e1b |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Message-id: <1417651524-18041-15-git-send-email-famz@redhat.com>
|
|
|
958e1b |
Patchwork-id: 62687
|
|
|
958e1b |
O-Subject: [RHEL-7.1 qemu-kvm PATCH v5 14/30] vmdk: correctly propagate errors
|
|
|
958e1b |
Bugzilla: 1134251
|
|
|
958e1b |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
958e1b |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
958e1b |
|
|
|
958e1b |
Now that we can return the "right" errors, use the Error** parameter
|
|
|
958e1b |
to pass them back instead of just printing them.
|
|
|
958e1b |
|
|
|
958e1b |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
958e1b |
Reviewed-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
958e1b |
(cherry picked from commit 89ac8480a8c7f73dd943dcb1313d6bd984f9a870)
|
|
|
958e1b |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
958e1b |
Signed-off-by: Jeff E. Nelson <jen@redhat.com>
|
|
|
958e1b |
---
|
|
|
958e1b |
block/vmdk.c | 11 ++++++-----
|
|
|
958e1b |
tests/qemu-iotests/059.out | 6 ++----
|
|
|
958e1b |
2 files changed, 8 insertions(+), 9 deletions(-)
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/block/vmdk.c b/block/vmdk.c
|
|
|
958e1b |
index 94f7dae..c7b930f 100644
|
|
|
958e1b |
--- a/block/vmdk.c
|
|
|
958e1b |
+++ b/block/vmdk.c
|
|
|
958e1b |
@@ -572,6 +572,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
958e1b |
error_setg_errno(errp, -ret,
|
|
|
958e1b |
"Could not read header from file '%s'",
|
|
|
958e1b |
file->filename);
|
|
|
958e1b |
+ return -EINVAL;
|
|
|
958e1b |
}
|
|
|
958e1b |
if (header.capacity == 0) {
|
|
|
958e1b |
uint64_t desc_offset = le64_to_cpu(header.desc_offset);
|
|
|
958e1b |
@@ -641,8 +642,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
958e1b |
char buf[64];
|
|
|
958e1b |
snprintf(buf, sizeof(buf), "VMDK version %d",
|
|
|
958e1b |
le32_to_cpu(header.version));
|
|
|
958e1b |
- qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
|
|
958e1b |
- bs->device_name, "vmdk", buf);
|
|
|
958e1b |
+ error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
|
|
|
958e1b |
+ bs->device_name, "vmdk", buf);
|
|
|
958e1b |
return -ENOTSUP;
|
|
|
958e1b |
} else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
|
|
|
958e1b |
/* VMware KB 2064959 explains that version 3 added support for
|
|
|
958e1b |
@@ -654,7 +655,7 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
if (le32_to_cpu(header.num_gtes_per_gt) > 512) {
|
|
|
958e1b |
- error_report("L2 table size too big");
|
|
|
958e1b |
+ error_setg(errp, "L2 table size too big");
|
|
|
958e1b |
return -EINVAL;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
@@ -670,8 +671,8 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
|
|
|
958e1b |
}
|
|
|
958e1b |
if (bdrv_getlength(file) <
|
|
|
958e1b |
le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) {
|
|
|
958e1b |
- error_report("File truncated, expecting at least %lld bytes",
|
|
|
958e1b |
- le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE);
|
|
|
958e1b |
+ error_setg(errp, "File truncated, expecting at least %lld bytes",
|
|
|
958e1b |
+ le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE);
|
|
|
958e1b |
return -EINVAL;
|
|
|
958e1b |
}
|
|
|
958e1b |
|
|
|
958e1b |
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
|
|
|
958e1b |
index 0220774..7c9ef90 100644
|
|
|
958e1b |
--- a/tests/qemu-iotests/059.out
|
|
|
958e1b |
+++ b/tests/qemu-iotests/059.out
|
|
|
958e1b |
@@ -7,8 +7,7 @@ no file open, try 'help open'
|
|
|
958e1b |
=== Testing too big L2 table size ===
|
|
|
958e1b |
|
|
|
958e1b |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
|
|
958e1b |
-L2 table size too big
|
|
|
958e1b |
-qemu-io: can't open device TEST_DIR/t.vmdk: Could not open 'TEST_DIR/t.vmdk': Invalid argument
|
|
|
958e1b |
+qemu-io: can't open device TEST_DIR/t.vmdk: L2 table size too big
|
|
|
958e1b |
no file open, try 'help open'
|
|
|
958e1b |
=== Testing too big L1 table size ===
|
|
|
958e1b |
|
|
|
958e1b |
@@ -2045,8 +2044,7 @@ RW 12582912 VMFS "dummy.IMGFMT" 1
|
|
|
958e1b |
|
|
|
958e1b |
=== Testing truncated sparse ===
|
|
|
958e1b |
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=107374182400
|
|
|
958e1b |
-qemu-img: File truncated, expecting at least 13172736 bytes
|
|
|
958e1b |
-qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open 'TEST_DIR/t.IMGFMT': Invalid argument
|
|
|
958e1b |
+qemu-img: Could not open 'TEST_DIR/t.IMGFMT': File truncated, expecting at least 13172736 bytes
|
|
|
958e1b |
|
|
|
958e1b |
=== Testing version 3 ===
|
|
|
958e1b |
image: TEST_DIR/iotest-version3.IMGFMT
|
|
|
958e1b |
--
|
|
|
958e1b |
2.1.0
|
|
|
958e1b |
|