[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/54] vmdk: do not try opening a file as both image
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 27/54] vmdk: do not try opening a file as both image and descriptor |
Date: |
Fri, 21 Feb 2014 23:12:24 +0100 |
From: Paolo Bonzini <address@hidden>
This prepares for propagating errors from vmdk_open_sparse and
vmdk_open_desc_file up to the caller of vmdk_open.
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/vmdk.c | 22 +++++++++++++++-------
tests/qemu-iotests/059.out | 4 ++--
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index f34c16d..50a279a 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -886,20 +886,28 @@ static int vmdk_open(BlockDriverState *bs, QDict
*options, int flags,
char *buf = NULL;
int ret;
BDRVVmdkState *s = bs->opaque;
+ uint32_t magic;
buf = vmdk_read_desc(bs->file, 0, errp);
if (!buf) {
return -EINVAL;
}
- if (vmdk_open_sparse(bs, bs->file, flags, buf, errp) == 0) {
- s->desc_offset = 0x200;
- } else {
- ret = vmdk_open_desc_file(bs, flags, buf, errp);
- if (ret) {
- goto fail;
- }
+ magic = ldl_be_p(buf);
+ switch (magic) {
+ case VMDK3_MAGIC:
+ case VMDK4_MAGIC:
+ ret = vmdk_open_sparse(bs, bs->file, flags, buf, errp);
+ s->desc_offset = 0x200;
+ break;
+ default:
+ ret = vmdk_open_desc_file(bs, flags, buf, errp);
+ break;
}
+ if (ret) {
+ goto fail;
+ }
+
/* try to open parent images, if exist */
ret = vmdk_parent_open(bs);
if (ret) {
diff --git a/tests/qemu-iotests/059.out b/tests/qemu-iotests/059.out
index 4ffeb54..4600670 100644
--- a/tests/qemu-iotests/059.out
+++ b/tests/qemu-iotests/059.out
@@ -8,7 +8,7 @@ no file open, try 'help open'
=== Testing too big L2 table size ===
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
L2 table size too big
-qemu-io: can't open device TEST_DIR/t.vmdk: Could not open 'TEST_DIR/t.vmdk':
Wrong medium type
+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'
=== Testing too big L1 table size ===
@@ -2046,7 +2046,7 @@ RW 12582912 VMFS "dummy.IMGFMT" 1
=== Testing truncated sparse ===
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': Could not open
'TEST_DIR/t.IMGFMT': Wrong medium type
+qemu-img: Could not open 'TEST_DIR/t.IMGFMT': Could not open
'TEST_DIR/t.IMGFMT': Invalid argument
=== Testing version 3 ===
image: TEST_DIR/iotest-version3.IMGFMT
--
1.8.1.4
- [Qemu-devel] [PULL 17/54] gluster: default scheme to gluster:// and host to localhost., (continued)
- [Qemu-devel] [PULL 17/54] gluster: default scheme to gluster:// and host to localhost., Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 19/54] cow: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 18/54] gluster: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 20/54] curl: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 21/54] qcow: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 22/54] qed: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 23/54] vhdx: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 25/54] vmdk: extract vmdk_read_desc, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 26/54] vmdk: push vmdk_read_desc up to caller, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 24/54] vvfat: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 27/54] vmdk: do not try opening a file as both image and descriptor,
Kevin Wolf <=
- [Qemu-devel] [PULL 28/54] vmdk: correctly propagate errors, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 29/54] block: do not abuse EMEDIUMTYPE, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 30/54] vdi: say why an image is bad, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 31/54] qemu-option: has_help_option() and is_valid_option_list(), Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 32/54] qemu-img create: Support multiple -o options, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 33/54] qemu-img convert: Support multiple -o options, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 34/54] qemu-img amend: Support multiple -o options, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 35/54] qemu-img: Allow -o help with incomplete argument list, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 36/54] qemu-iotests: Check qemu-img command line parsing, Kevin Wolf, 2014/02/21
- [Qemu-devel] [PULL 37/54] qemu-config: Sections must consist of keys, Kevin Wolf, 2014/02/21