Skip to contentSkip to conversation

vmdk: Support ESX files

PATCH In review Paolo Bonzini 4 participants 9 messages Aug 11, 2013 – Aug 12, 2013 Block layer

lore
Share & tools
lore
#0 lore raw

cover vmdk: Support ESX files

So I thought I was on vacation, but my neighbor (who has a small data recovery company) asked me if I knew how to extract metadata from ESX images.

Sure, said I, thinking there would be no better test case for my metadata dump patches. However, ESX files are slightly different from "hosted" files (as VMware calls them), so we needed a small patch to open them. This series is based on that, and adds support for these files.

Paolo Bonzini (2):
vmdk: support vmfsSparse files
vmdk: support vmfs files

 block/vmdk.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 48 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 vmdk: support vmfsSparse files

VMware ESX hosts use a variant of the VMDK3 format, identified by the vmfsSparse create type ad the VMFSSPARSE extent type.

It has 16 KB grain tables (L2) and a variable-size grain directory (L1). In addition, the grain size is always 512, but that is not a problem because it is included in the header.

The format of the extents is documented in the VMDK spec. The format of the descriptor file is not documented precisely, but it can be found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual machine disk (VMDK) descriptor file for delta disks).

With these patches, vmfsSparse files only work if opened through the descriptor file. Data files without descriptor files, as far as I could understand, are not supported by ESX.

---
 block/vmdk.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 5 deletions(-)
block/vmdk.c +46 -5
index b16d509..eaf484a 100644
@@ -505,6 +505,34 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
     return ret;
 }
 
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+                                 BlockDriverState *file,
+                                 int flags)
+{
+    int ret;
+    uint32_t magic;
+    VMDK3Header header;
+    VmdkExtent *extent;
+
+    ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
+    if (ret < 0) {
+        return ret;
+    }
+    extent = vmdk_add_extent(bs, file, false,
+                          le64_to_cpu(header.disk_sectors),
+                          le64_to_cpu(header.l1dir_offset) << 9,
+                          0,
+                          le64_to_cpu(header.l1dir_size) * 4,
+                          4096,
+                          le64_to_cpu(header.granularity)); /* always 512 */
+    ret = vmdk_init_tables(bs, extent);
+    if (ret) {
+        /* free extent allocated by vmdk_add_extent */
+        vmdk_free_last_extent(bs);
+    }
+    return ret;
+}
+
 static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
                                uint64_t desc_offset);
 
@@ -663,7 +691,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name,
 /* Open an extent file and append to bs array */
 static int vmdk_open_sparse(BlockDriverState *bs,
                             BlockDriverState *file,
-                            int flags)
+                            int flags, bool vmfs_sparse)
 {
     uint32_t magic;
 
@@ -674,7 +702,11 @@ static int vmdk_open_sparse(BlockDriverState *bs,
     magic = be32_to_cpu(magic);
     switch (magic) {
         case VMDK3_MAGIC:
-            return vmdk_open_vmdk3(bs, file, flags);
+            if (vmfs_sparse) {
+                return vmdk_open_vmfs_sparse(bs, file, flags);
+            } else {
+                return vmdk_open_vmdk3(bs, file, flags);
+            }
             break;
         case VMDK4_MAGIC:
             return vmdk_open_vmdk4(bs, file, flags);
@@ -718,7 +750,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         }
 
         if (sectors <= 0 ||
-            (strcmp(type, "FLAT") && strcmp(type, "SPARSE")) ||
+            (strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
+             strcmp(type, "VMFSSPARSE")) ||
             (strcmp(access, "RW"))) {
             goto next_line;
         }
@@ -743,7 +776,14 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
             extent->flat_start_offset = flat_offset << 9;
         } else if (!strcmp(type, "SPARSE")) {
             /* SPARSE extent */
-            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags);
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, false);
+            if (ret) {
+                bdrv_delete(extent_file);
+                return ret;
+            }
+        } else if (!strcmp(type, "VMFSSPARSE")) {
+            /* VMFSSPARSE extent */
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, true);
             if (ret) {
                 bdrv_delete(extent_file);
                 return ret;
@@ -789,6 +829,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
         goto exit;
     }
     if (strcmp(ct, "monolithicFlat") &&
+        strcmp(ct, "vmfsSparse") &&
         strcmp(ct, "twoGbMaxExtentSparse") &&
         strcmp(ct, "twoGbMaxExtentFlat")) {
         fprintf(stderr,
@@ -808,7 +849,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags)
     int ret;
     BDRVVmdkState *s = bs->opaque;
 
-    if (vmdk_open_sparse(bs, bs->file, flags) == 0) {
+    if (vmdk_open_sparse(bs, bs->file, flags, false) == 0) {
         s->desc_offset = 0x200;
     } else {
         ret = vmdk_open_desc_file(bs, flags, 0);
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

Quoted 12 lines · Paolo Bonzini

VMware ESX hosts use a variant of the VMDK3 format, identified by the vmfsSparse create type ad the VMFSSPARSE extent type.

It has 16 KB grain tables (L2) and a variable-size grain directory (L1). In addition, the grain size is always 512, but that is not a problem because it is included in the header.

The format of the extents is documented in the VMDK spec. The format of the descriptor file is not documented precisely, but it can be found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual machine disk (VMDK) descriptor file for delta disks).

I don't have access to this link, could you include some documents to this descriptor format in comment or commit message? IIRC, it's only the type be "VMFSSPARSE", right?

What version of ESX has this format?

Quoted 27 lines

With these patches, vmfsSparse files only work if opened through the descriptor file. Data files without descriptor files, as far as I could understand, are not supported by ESX.

---
 block/vmdk.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 5 deletions(-)
block/vmdk.c +10 -0
index b16d509..eaf484a 100644
@@ -505,6 +505,34 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
     return ret;
 }
 
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+                                 BlockDriverState *file,
+                                 int flags)
+{
+    int ret;
+    uint32_t magic;
+    VMDK3Header header;
+    VmdkExtent *extent;
+
+    ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));

block/vmdk.c static int vmdk_open_vmdk3(BlockDriverState *bs, · line 527

Quoted 10 lines
block/vmdk.c +10 -0
+    if (ret < 0) {
+        return ret;
+    }
+    extent = vmdk_add_extent(bs, file, false,
+                          le64_to_cpu(header.disk_sectors),
+                          le64_to_cpu(header.l1dir_offset) << 9,
+                          0,
+                          le64_to_cpu(header.l1dir_size) * 4,
+                          4096,
+                          le64_to_cpu(header.granularity)); /* always 512 */

This needs to be rebased, vmdk_add_extent() signature has been changed in:

commit 8aa1331c09a9b899f48d97f097bb49b7d458be1c
Author: Fam Zheng <[email protected]>
Date: Tue Aug 6 15:44:51 2013 +0800

vmdk: check granularity field in opening

Granularity is used to calculate the cluster size and allocate r/w buffer. Check the value from image before using it, so we don't abort() for unbounded memory allocation.

Since the new function is a variant of vmdk_open_vmdk3(), would you consider doing a tiny refactor and reduce duplication? And l1dir_size and granularity need to be checked, as in vmdk_open_vmdk4().

Quoted 80 lines
block/vmdk.c +26 -5
+    ret = vmdk_init_tables(bs, extent);
+    if (ret) {
+        /* free extent allocated by vmdk_add_extent */
+        vmdk_free_last_extent(bs);
+    }
+    return ret;
+}
+
 static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
                                uint64_t desc_offset);
 
@@ -663,7 +691,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name,
 /* Open an extent file and append to bs array */
 static int vmdk_open_sparse(BlockDriverState *bs,
                             BlockDriverState *file,
-                            int flags)
+                            int flags, bool vmfs_sparse)
 {
     uint32_t magic;
 
@@ -674,7 +702,11 @@ static int vmdk_open_sparse(BlockDriverState *bs,
     magic = be32_to_cpu(magic);
     switch (magic) {
         case VMDK3_MAGIC:
-            return vmdk_open_vmdk3(bs, file, flags);
+            if (vmfs_sparse) {
+                return vmdk_open_vmfs_sparse(bs, file, flags);
+            } else {
+                return vmdk_open_vmdk3(bs, file, flags);
+            }
             break;
         case VMDK4_MAGIC:
             return vmdk_open_vmdk4(bs, file, flags);
@@ -718,7 +750,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         }
 
         if (sectors <= 0 ||
-            (strcmp(type, "FLAT") && strcmp(type, "SPARSE")) ||
+            (strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
+             strcmp(type, "VMFSSPARSE")) ||
             (strcmp(access, "RW"))) {
             goto next_line;
         }
@@ -743,7 +776,14 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
             extent->flat_start_offset = flat_offset << 9;
         } else if (!strcmp(type, "SPARSE")) {
             /* SPARSE extent */
-            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags);
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, false);
+            if (ret) {
+                bdrv_delete(extent_file);
+                return ret;
+            }
+        } else if (!strcmp(type, "VMFSSPARSE")) {
+            /* VMFSSPARSE extent */
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, true);
             if (ret) {
                 bdrv_delete(extent_file);
                 return ret;
@@ -789,6 +829,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
         goto exit;
     }
     if (strcmp(ct, "monolithicFlat") &&
+        strcmp(ct, "vmfsSparse") &&
         strcmp(ct, "twoGbMaxExtentSparse") &&
         strcmp(ct, "twoGbMaxExtentFlat")) {
         fprintf(stderr,
@@ -808,7 +849,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags)
     int ret;
     BDRVVmdkState *s = bs->opaque;
 
-    if (vmdk_open_sparse(bs, bs->file, flags) == 0) {
+    if (vmdk_open_sparse(bs, bs->file, flags, false) == 0) {
         s->desc_offset = 0x200;
     } else {
         ret = vmdk_open_desc_file(bs, flags, 0);
Signature · 1 line
1.8.3.1
Signature · 1 line
Fam
#3 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

----- Original Message -----

Quoted 14 lines

From: "Fam Zheng" <[email protected]>
To: "Paolo Bonzini" <[email protected]>
Cc: [email protected], [email protected]
Sent: Monday, August 12, 2013 3:31:44 AM
Subject: Re: [PATCH 1/2] vmdk: support vmfsSparse files

Quoted 7 lines · Paolo Bonzini

VMware ESX hosts use a variant of the VMDK3 format, identified by the vmfsSparse create type ad the VMFSSPARSE extent type.

It has 16 KB grain tables (L2) and a variable-size grain directory (L1). In addition, the grain size is always 512, but that is not a problem because it is included in the header.

Quoted 6 lines
Quoted 5 lines

The format of the extents is documented in the VMDK spec. The format of the descriptor file is not documented precisely, but it can be found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual machine disk (VMDK) descriptor file for delta disks).

I don't have access to this link

It only works from Google. Try Googling for "vmfssparse delta".

Quoted 3 lines

, could you include some documents to
this descriptor format in comment or commit message? IIRC, it's only the type be "VMFSSPARSE", right?

Yes. And "VMFS" for the base (patch 2).

Quoted 1 line

What version of ESX has this format?

At least 4.0 and newer.

Quoted 14 lines

This needs to be rebased, vmdk_add_extent() signature has been changed in:

commit 8aa1331c09a9b899f48d97f097bb49b7d458be1c
Author: Fam Zheng <[email protected]>
Date: Tue Aug 6 15:44:51 2013 +0800

vmdk: check granularity field in opening

Granularity is used to calculate the cluster size and allocate r/w buffer. Check the value from image before using it, so we don't abort()
for unbounded memory allocation.

Quoted 6 lines

Since the new function is a variant of vmdk_open_vmdk3(), would you consider doing a tiny refactor and reduce duplication? And l1dir_size and granularity need to be checked, as in vmdk_open_vmdk4().

I am not sure how to refactor it... in fact, since I'm on vacation I wouldn't mind if somebody else fixes the patch. I can test it either tomorrow or next week.

Paolo

#4 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

Quoted 53 lines · Paolo Bonzini

----- Original Message -----

Quoted 14 lines

From: "Fam Zheng" <[email protected]>
To: "Paolo Bonzini" <[email protected]>
Cc: [email protected], [email protected]
Sent: Monday, August 12, 2013 3:31:44 AM
Subject: Re: [PATCH 1/2] vmdk: support vmfsSparse files

Quoted 7 lines · Paolo Bonzini

VMware ESX hosts use a variant of the VMDK3 format, identified by the vmfsSparse create type ad the VMFSSPARSE extent type.

It has 16 KB grain tables (L2) and a variable-size grain directory (L1). In addition, the grain size is always 512, but that is not a problem because it is included in the header.

Quoted 6 lines
Quoted 5 lines

The format of the extents is documented in the VMDK spec. The format of the descriptor file is not documented precisely, but it can be found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual machine disk (VMDK) descriptor file for delta disks).

I don't have access to this link

It only works from Google. Try Googling for "vmfssparse delta".

Quoted 3 lines

, could you include some documents to
this descriptor format in comment or commit message? IIRC, it's only the type be "VMFSSPARSE", right?

Yes. And "VMFS" for the base (patch 2).

Quoted 1 line

What version of ESX has this format?

At least 4.0 and newer.

Quoted 17 lines

This needs to be rebased, vmdk_add_extent() signature has been changed in:

commit 8aa1331c09a9b899f48d97f097bb49b7d458be1c
Author: Fam Zheng <[email protected]>
Date: Tue Aug 6 15:44:51 2013 +0800

vmdk: check granularity field in opening

Granularity is used to calculate the cluster size and allocate r/w buffer. Check the value from image before using it, so we don't abort()
for unbounded memory allocation.

Quoted 8 lines
Quoted 3 lines

Since the new function is a variant of vmdk_open_vmdk3(), would you consider doing a tiny refactor and reduce duplication? And l1dir_size and granularity need to be checked, as in vmdk_open_vmdk4().

I am not sure how to refactor it... in fact, since I'm on vacation I wouldn't mind if somebody else fixes the patch. I can test it either tomorrow or next week.

OK, I'll take it for your happy vocation. :)

Signature · 1 line
Fam
#5 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

In reply to Paolo Bonzini

Am 11.08.2013 18:13, schrieb Paolo Bonzini:

Quoted 2 lines

VMware ESX hosts use a variant of the VMDK3 format, identified by the vmfsSparse create type ad the VMFSSPARSE extent type.

"and"?

Quoted 36 lines

It has 16 KB grain tables (L2) and a variable-size grain directory (L1). In addition, the grain size is always 512, but that is not a problem because it is included in the header.

The format of the extents is documented in the VMDK spec. The format of the descriptor file is not documented precisely, but it can be found at http://kb.vmware.com/kb/10026353 (Recreating a missing virtual machine disk (VMDK) descriptor file for delta disks).

With these patches, vmfsSparse files only work if opened through the descriptor file. Data files without descriptor files, as far as I could understand, are not supported by ESX.

---
 block/vmdk.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 46 insertions(+), 5 deletions(-)
block/vmdk.c +10 -0
index b16d509..eaf484a 100644
@@ -505,6 +505,34 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
     return ret;
 }
 
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+                                 BlockDriverState *file,
+                                 int flags)
+{
+    int ret;
+    uint32_t magic;
+    VMDK3Header header;
+    VmdkExtent *extent;
+
+    ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));

block/vmdk.c static int vmdk_open_vmdk3(BlockDriverState *bs, · line 527

Quoted 10 lines
block/vmdk.c +10 -0
+    if (ret < 0) {
+        return ret;
+    }
+    extent = vmdk_add_extent(bs, file, false,
+                          le64_to_cpu(header.disk_sectors),
+                          le64_to_cpu(header.l1dir_offset) << 9,
+                          0,
+                          le64_to_cpu(header.l1dir_size) * 4,
+                          4096,
+                          le64_to_cpu(header.granularity)); /* always 512 */

Indentation is 3 off (guessing the variable was called ext before ;)).

Andreas

Quoted 77 lines
block/vmdk.c +26 -5
+    ret = vmdk_init_tables(bs, extent);
+    if (ret) {
+        /* free extent allocated by vmdk_add_extent */
+        vmdk_free_last_extent(bs);
+    }
+    return ret;
+}
+
 static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
                                uint64_t desc_offset);
 
@@ -663,7 +691,7 @@ static int vmdk_parse_description(const char *desc, const char *opt_name,
 /* Open an extent file and append to bs array */
 static int vmdk_open_sparse(BlockDriverState *bs,
                             BlockDriverState *file,
-                            int flags)
+                            int flags, bool vmfs_sparse)
 {
     uint32_t magic;
 
@@ -674,7 +702,11 @@ static int vmdk_open_sparse(BlockDriverState *bs,
     magic = be32_to_cpu(magic);
     switch (magic) {
         case VMDK3_MAGIC:
-            return vmdk_open_vmdk3(bs, file, flags);
+            if (vmfs_sparse) {
+                return vmdk_open_vmfs_sparse(bs, file, flags);
+            } else {
+                return vmdk_open_vmdk3(bs, file, flags);
+            }
             break;
         case VMDK4_MAGIC:
             return vmdk_open_vmdk4(bs, file, flags);
@@ -718,7 +750,8 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         }
 
         if (sectors <= 0 ||
-            (strcmp(type, "FLAT") && strcmp(type, "SPARSE")) ||
+            (strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
+             strcmp(type, "VMFSSPARSE")) ||
             (strcmp(access, "RW"))) {
             goto next_line;
         }
@@ -743,7 +776,14 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
             extent->flat_start_offset = flat_offset << 9;
         } else if (!strcmp(type, "SPARSE")) {
             /* SPARSE extent */
-            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags);
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, false);
+            if (ret) {
+                bdrv_delete(extent_file);
+                return ret;
+            }
+        } else if (!strcmp(type, "VMFSSPARSE")) {
+            /* VMFSSPARSE extent */
+            ret = vmdk_open_sparse(bs, extent_file, bs->open_flags, true);
             if (ret) {
                 bdrv_delete(extent_file);
                 return ret;
@@ -789,6 +829,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
         goto exit;
     }
     if (strcmp(ct, "monolithicFlat") &&
+        strcmp(ct, "vmfsSparse") &&
         strcmp(ct, "twoGbMaxExtentSparse") &&
         strcmp(ct, "twoGbMaxExtentFlat")) {
         fprintf(stderr,
@@ -808,7 +849,7 @@ static int vmdk_open(BlockDriverState *bs, QDict *options, int flags)
     int ret;
     BDRVVmdkState *s = bs->opaque;
 
-    if (vmdk_open_sparse(bs, bs->file, flags) == 0) {
+    if (vmdk_open_sparse(bs, bs->file, flags, false) == 0) {
         s->desc_offset = 0x200;
     } else {
         ret = vmdk_open_desc_file(bs, flags, 0);
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#6 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

In reply to Paolo Bonzini
Quoted 7 lines · Paolo Bonzini
block/vmdk.c +3 -0
@@ -505,6 +505,34 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
     return ret;
 }
 
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+                                 BlockDriverState *file,
+                                 int flags)

block/vmdk.c static int vmdk_open_vmdk3(BlockDriverState *bs, · line 520

Quoted 10 lines
block/vmdk.c +10 -0
+{
+    int ret;
+    uint32_t magic;
+    VMDK3Header header;
+    VmdkExtent *extent;
+
+    ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
+    if (ret < 0) {
+        return ret;
+    }

magic is unused. Did you forget to check it?

#7 lore raw

Re: [Qemu-devel] [PATCH 1/2] vmdk: support vmfsSparse files

Quoted 5 lines · Stefan Hajnoczi
Quoted 4 lines · Paolo Bonzini
block/vmdk.c +0 -0
@@ -505,6 +505,34 @@ static int vmdk_open_vmdk3(BlockDriverState *bs,
     return ret;
 }
 
Quoted 15 lines

block/vmdk.c static int vmdk_open_vmdk3(BlockDriverState *bs, · line 520

Quoted 13 lines
block/vmdk.c +13 -0
+static int vmdk_open_vmfs_sparse(BlockDriverState *bs,
+                                 BlockDriverState *file,
+                                 int flags)
+{
+    int ret;
+    uint32_t magic;
+    VMDK3Header header;
+    VmdkExtent *extent;
+
+    ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header));
+    if (ret < 0) {
+        return ret;
+    }

magic is unused. Did you forget to check it?

Andreas Färber pointed out that we're only using the sizeof(magic), not the actual variable.

Feel free to ignore my comment, at least the code documents that the uint32_t offset belongs to the magic number before the header.

Stefan

#8 lore raw

PATCH 2/2 vmdk: support vmfs files

In reply to Paolo Bonzini

VMware ESX hosts also use different create and extent types for flat files, respectively "vmfs" and "VMFS". This is not documented, but it can be found at http://kb.vmware.com/kb/10002511 (Recreating a missing virtual machine disk (VMDK) descriptor file).

---
 block/vmdk.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/vmdk.c +3 -2
index eaf484a..2a5b63d 100644
@@ -751,7 +751,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
 
         if (sectors <= 0 ||
             (strcmp(type, "FLAT") && strcmp(type, "SPARSE") &&
-             strcmp(type, "VMFSSPARSE")) ||
+             strcmp(type, "VMFS") && strcmp(type, "VMFSSPARSE")) ||
             (strcmp(access, "RW"))) {
             goto next_line;
         }
@@ -764,7 +764,7 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
         }
 
         /* save to extents array */
-        if (!strcmp(type, "FLAT")) {
+        if (!strcmp(type, "FLAT") || !strcmp(type, "VMFS")) {
             /* FLAT extent */
             VmdkExtent *extent;
 
@@ -829,6 +829,7 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
         goto exit;
     }
     if (strcmp(ct, "monolithicFlat") &&
+        strcmp(ct, "vmfs") &&
         strcmp(ct, "vmfsSparse") &&
         strcmp(ct, "twoGbMaxExtentSparse") &&
         strcmp(ct, "twoGbMaxExtentFlat")) {
Signature · 1 line
1.8.3.1