  
          /* First of all we write grain itself, to avoid race condition
           * that may to corrupt the image.
-@@ -1210,6 +1355,7 @@ static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset,
+@@ -1210,6 +1355,7 @@
      uLongf buf_len;
      const uint8_t *write_buf = buf;
      int write_len = nb_sectors * 512;

         error_setg(errp, "VMDK version 3 must be read only");
         return -EINVAL;
     }
@@ -689,11 +715,20 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
     if (ret < 0) {
         return ret;
     }

     /* swap endianness for all header fields */
     header.version = cpu_to_le32(header.version);
     header.flags = cpu_to_le32(header.flags);
@@ -1620,30 +1786,54 @@
         goto exit;
     }
 
