Index: /trunk/src/VBox/Storage/VDI.cpp
===================================================================
--- /trunk/src/VBox/Storage/VDI.cpp	(revision 43601)
+++ /trunk/src/VBox/Storage/VDI.cpp	(revision 43602)
@@ -326,5 +326,6 @@
 static void vdiInitHeader(PVDIHEADER pHeader, uint32_t uImageFlags,
                           const char *pszComment, uint64_t cbDisk,
-                          uint32_t cbBlock, uint32_t cbBlockExtra)
+                          uint32_t cbBlock, uint32_t cbBlockExtra,
+                          uint32_t cbDataAlign)
 {
     pHeader->uVersion = VDI_IMAGE_VERSION;
@@ -360,6 +361,6 @@
 
     /* Init offsets. */
-    pHeader->u.v1plus.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1PLUS), VDI_DATA_ALIGN);
-    pHeader->u.v1plus.offData = RT_ALIGN_32(pHeader->u.v1plus.offBlocks + (pHeader->u.v1plus.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), VDI_DATA_ALIGN);
+    pHeader->u.v1plus.offBlocks = RT_ALIGN_32(sizeof(VDIPREHEADER) + sizeof(VDIHEADER1PLUS), cbDataAlign);
+    pHeader->u.v1plus.offData = RT_ALIGN_32(pHeader->u.v1plus.offBlocks + (pHeader->u.v1plus.cBlocks * sizeof(VDIIMAGEBLOCKPOINTER)), cbDataAlign);
 
     /* Init uuids. */
@@ -521,5 +522,5 @@
                           unsigned uOpenFlags, PFNVDPROGRESS pfnProgress,
                           void *pvUser, unsigned uPercentStart,
-                          unsigned uPercentSpan)
+                          unsigned uPercentSpan, PVDINTERFACECONFIG pIfCfg)
 {
     int rc;
@@ -527,4 +528,5 @@
     uint64_t cbFill;
     uint64_t uOff;
+    uint32_t cbDataAlign = VDI_DATA_ALIGN;
 
     AssertPtr(pPCHSGeometry);
@@ -544,6 +546,18 @@
     }
 
+    if (pIfCfg)
+    {
+        rc = VDCFGQueryU32Def(pIfCfg, "DataAlignment", &cbDataAlign, VDI_DATA_ALIGN);
+        if (RT_FAILURE(rc))
+        {
+            rc = vdIfError(pImage->pIfError, rc, RT_SRC_POS,
+                           N_("VDI: Getting data alignment for '%s' failed (%Rrc)"), pImage->pszFilename);
+            goto out;
+        }
+    }
+
     vdiInitPreHeader(&pImage->PreHeader);
-    vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0);
+    vdiInitHeader(&pImage->Header, uImageFlags, pszComment, cbSize, VDI_IMAGE_DEFAULT_BLOCK_SIZE, 0,
+                  cbDataAlign);
     /* Save PCHS geometry. Not much work, and makes the flow of information
      * quite a bit clearer - relying on the higher level isn't obvious. */
@@ -1476,4 +1490,6 @@
     }
 
+    PVDINTERFACECONFIG pIfCfg = VDIfConfigGet(pVDIfsOperation);
+
     /* Check the image flags. */
     if ((uImageFlags & ~VD_VDI_IMAGE_FLAGS_MASK) != 0)
@@ -1525,5 +1541,6 @@
     rc = vdiCreateImage(pImage, cbSize, uImageFlags, pszComment,
                         pPCHSGeometry, pLCHSGeometry, pUuid, uOpenFlags,
-                        pfnProgress, pvUser, uPercentStart, uPercentSpan);
+                        pfnProgress, pvUser, uPercentStart, uPercentSpan,
+                        pIfCfg);
     if (RT_SUCCESS(rc))
     {
