Index: trunk/src/VBox/Devices/Storage/DrvVD.cpp
===================================================================
--- trunk/src/VBox/Devices/Storage/DrvVD.cpp	(revision 91954)
+++ trunk/src/VBox/Devices/Storage/DrvVD.cpp	(revision 91955)
@@ -128,4 +128,6 @@
 typedef struct DRVVDSTORAGEBACKEND
 {
+    /** The virtual disk driver instance. */
+    PVBOXDISK                   pVD;
     /** PDM async completion end point. */
     PPDMASYNCCOMPLETIONENDPOINT pEndpoint;
@@ -647,4 +649,5 @@
     if (pStorageBackend)
     {
+        pStorageBackend->pVD            = pThis;
         pStorageBackend->fSyncIoPending = false;
         pStorageBackend->rcReqLast      = VINF_SUCCESS;
@@ -670,12 +673,13 @@
                     fFlags |= PDMACEP_FILE_FLAGS_HOST_CACHE_ENABLED;
 
-                rc = PDMR3AsyncCompletionEpCreateForFile(&pStorageBackend->pEndpoint,
-                                                         pszLocation, fFlags,
-                                                         pStorageBackend->pTemplate);
+                rc = PDMDrvHlpAsyncCompletionEpCreateForFile(pThis->pDrvIns,
+                                                             &pStorageBackend->pEndpoint,
+                                                             pszLocation, fFlags,
+                                                             pStorageBackend->pTemplate);
 
                 if (RT_SUCCESS(rc))
                 {
                     if (pThis->pszBwGroup)
-                        rc = PDMR3AsyncCompletionEpSetBwMgr(pStorageBackend->pEndpoint, pThis->pszBwGroup);
+                        rc = PDMDrvHlpAsyncCompletionEpSetBwMgr(pThis->pDrvIns, pStorageBackend->pEndpoint, pThis->pszBwGroup);
 
                     if (RT_SUCCESS(rc))
@@ -687,8 +691,8 @@
                     }
 
-                    PDMR3AsyncCompletionEpClose(pStorageBackend->pEndpoint);
+                    PDMDrvHlpAsyncCompletionEpClose(pThis->pDrvIns, pStorageBackend->pEndpoint);
                 }
 
-                PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
+                PDMDrvHlpAsyncCompletionTemplateDestroy(pThis->pDrvIns, pStorageBackend->pTemplate);
             }
             RTSemEventDestroy(pStorageBackend->EventSem);
@@ -706,4 +710,5 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
+    PVBOXDISK pThis = pStorageBackend->pVD;
 
     /*
@@ -714,6 +719,6 @@
      */
 
-    PDMR3AsyncCompletionEpClose(pStorageBackend->pEndpoint);
-    PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
+    PDMDrvHlpAsyncCompletionEpClose(pThis->pDrvIns, pStorageBackend->pEndpoint);
+    PDMDrvHlpAsyncCompletionTemplateDestroy(pThis->pDrvIns, pStorageBackend->pTemplate);
     RTSemEventDestroy(pStorageBackend->EventSem);
     RTMemFree(pStorageBackend);
@@ -726,4 +731,5 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
+    PVBOXDISK pThis = pStorageBackend->pVD;
     RTSGSEG DataSeg;
     PPDMASYNCCOMPLETIONTASK pTask;
@@ -734,5 +740,5 @@
     DataSeg.pvSeg = pvBuf;
 
-    int rc = PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbRead, NULL, &pTask);
+    int rc = PDMDrvHlpAsyncCompletionEpRead(pThis->pDrvIns, pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbRead, NULL, &pTask);
     if (RT_FAILURE(rc))
         return rc;
@@ -758,4 +764,5 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
+    PVBOXDISK pThis = pStorageBackend->pVD;
     RTSGSEG DataSeg;
     PPDMASYNCCOMPLETIONTASK pTask;
@@ -766,5 +773,5 @@
     DataSeg.pvSeg = (void *)pvBuf;
 
-    int rc = PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbWrite, NULL, &pTask);
+    int rc = PDMDrvHlpAsyncCompletionEpWrite(pThis->pDrvIns, pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbWrite, NULL, &pTask);
     if (RT_FAILURE(rc))
         return rc;
@@ -789,4 +796,5 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
+    PVBOXDISK pThis = pStorageBackend->pVD;
     PPDMASYNCCOMPLETIONTASK pTask;
 
@@ -796,5 +804,5 @@
     Assert(!fOld); NOREF(fOld);
 
-    int rc = PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, NULL, &pTask);
+    int rc = PDMDrvHlpAsyncCompletionEpFlush(pThis->pDrvIns, pStorageBackend->pEndpoint, NULL, &pTask);
     if (RT_FAILURE(rc))
         return rc;
@@ -820,7 +828,9 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
-
-    int rc = PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, paSegments, (unsigned)cSegments, cbRead,
-                                        pvCompletion, (PPPDMASYNCCOMPLETIONTASK)ppTask);
+    PVBOXDISK pThis = pStorageBackend->pVD;
+
+    int rc = PDMDrvHlpAsyncCompletionEpRead(pThis->pDrvIns, pStorageBackend->pEndpoint,
+                                            uOffset, paSegments, (unsigned)cSegments, cbRead,
+                                            pvCompletion, (PPPDMASYNCCOMPLETIONTASK)ppTask);
     if (rc == VINF_AIO_TASK_PENDING)
         rc = VERR_VD_ASYNC_IO_IN_PROGRESS;
@@ -836,7 +846,9 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
-
-    int rc = PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, paSegments, (unsigned)cSegments, cbWrite,
-                                         pvCompletion, (PPPDMASYNCCOMPLETIONTASK)ppTask);
+    PVBOXDISK pThis = pStorageBackend->pVD;
+
+    int rc = PDMDrvHlpAsyncCompletionEpWrite(pThis->pDrvIns, pStorageBackend->pEndpoint,
+                                             uOffset, paSegments, (unsigned)cSegments, cbWrite,
+                                             pvCompletion, (PPPDMASYNCCOMPLETIONTASK)ppTask);
     if (rc == VINF_AIO_TASK_PENDING)
         rc = VERR_VD_ASYNC_IO_IN_PROGRESS;
@@ -850,7 +862,8 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
-
-    int rc = PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, pvCompletion,
-                                         (PPPDMASYNCCOMPLETIONTASK)ppTask);
+    PVBOXDISK pThis = pStorageBackend->pVD;
+
+    int rc = PDMDrvHlpAsyncCompletionEpFlush(pThis->pDrvIns, pStorageBackend->pEndpoint, pvCompletion,
+                                             (PPPDMASYNCCOMPLETIONTASK)ppTask);
     if (rc == VINF_AIO_TASK_PENDING)
         rc = VERR_VD_ASYNC_IO_IN_PROGRESS;
@@ -863,6 +876,7 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
-
-    return PDMR3AsyncCompletionEpGetSize(pStorageBackend->pEndpoint, pcbSize);
+    PVBOXDISK pThis = pStorageBackend->pVD;
+
+    return PDMDrvHlpAsyncCompletionEpGetSize(pThis->pDrvIns, pStorageBackend->pEndpoint, pcbSize);
 }
 
@@ -871,6 +885,7 @@
     RT_NOREF(pvUser);
     PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
-
-    return PDMR3AsyncCompletionEpSetSize(pStorageBackend->pEndpoint, cbSize);
+    PVBOXDISK pThis = pStorageBackend->pVD;
+
+    return PDMDrvHlpAsyncCompletionEpSetSize(pThis->pDrvIns, pStorageBackend->pEndpoint, cbSize);
 }
 
@@ -2181,5 +2196,5 @@
 
     AssertPtr(pThis->pBlkCache);
-    PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, (PPDMBLKCACHEIOXFER)pvUser2, rcReq);
+    PDMDrvHlpBlkCacheIoXferComplete(pThis->pDrvIns, pThis->pBlkCache, (PPDMBLKCACHEIOXFER)pvUser2, rcReq);
 }
 
@@ -2223,7 +2238,7 @@
 
     if (rc == VINF_VD_ASYNC_IO_FINISHED)
-        PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, VINF_SUCCESS);
+        PDMDrvHlpBlkCacheIoXferComplete(pThis->pDrvIns, pThis->pBlkCache, hIoXfer, VINF_SUCCESS);
     else if (RT_FAILURE(rc) && rc != VERR_VD_ASYNC_IO_IN_PROGRESS)
-        PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, rc);
+        PDMDrvHlpBlkCacheIoXferComplete(pThis->pDrvIns, pThis->pBlkCache, hIoXfer, rc);
 
     return VINF_SUCCESS;
@@ -2241,7 +2256,7 @@
 
     if (rc == VINF_VD_ASYNC_IO_FINISHED)
-        PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, VINF_SUCCESS);
+        PDMDrvHlpBlkCacheIoXferComplete(pThis->pDrvIns, pThis->pBlkCache, hIoXfer, VINF_SUCCESS);
     else if (RT_FAILURE(rc) && rc != VERR_VD_ASYNC_IO_IN_PROGRESS)
-        PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, rc);
+        PDMDrvHlpBlkCacheIoXferComplete(pThis->pDrvIns, pThis->pBlkCache, hIoXfer, rc);
 
     return VINF_SUCCESS;
@@ -2735,6 +2750,6 @@
         if (pThis->pBlkCache)
         {
-            rc = PDMR3BlkCacheRead(pThis->pBlkCache, pIoReq->ReadWrite.offStart,
-                                   pIoReq->ReadWrite.pSgBuf, cbReqIo, pIoReq);
+            rc = PDMDrvHlpBlkCacheRead(pThis->pDrvIns, pThis->pBlkCache, pIoReq->ReadWrite.offStart,
+                                       pIoReq->ReadWrite.pSgBuf, cbReqIo, pIoReq);
             if (rc == VINF_SUCCESS)
                 rc = VINF_VD_ASYNC_IO_FINISHED;
@@ -2784,6 +2799,6 @@
         if (pThis->pBlkCache)
         {
-            rc = PDMR3BlkCacheWrite(pThis->pBlkCache, pIoReq->ReadWrite.offStart,
-                                    pIoReq->ReadWrite.pSgBuf, cbReqIo, pIoReq);
+            rc = PDMDrvHlpBlkCacheWrite(pThis->pDrvIns, pThis->pBlkCache, pIoReq->ReadWrite.offStart,
+                                        pIoReq->ReadWrite.pSgBuf, cbReqIo, pIoReq);
             if (rc == VINF_SUCCESS)
                 rc = VINF_VD_ASYNC_IO_FINISHED;
@@ -2847,5 +2862,5 @@
             if (pThis->pBlkCache)
             {
-                rc = PDMR3BlkCacheFlush(pThis->pBlkCache, pIoReq);
+                rc = PDMDrvHlpBlkCacheFlush(pThis->pDrvIns, pThis->pBlkCache, pIoReq);
                 if (rc == VINF_SUCCESS)
                     rc = VINF_VD_ASYNC_IO_FINISHED;
@@ -2893,5 +2908,7 @@
         if (pThis->pBlkCache)
         {
-            rc = PDMR3BlkCacheDiscard(pThis->pBlkCache, pIoReq->Discard.paRanges, pIoReq->Discard.cRanges, pIoReq);
+            rc = PDMDrvHlpBlkCacheDiscard(pThis->pDrvIns, pThis->pBlkCache,
+                                          pIoReq->Discard.paRanges, pIoReq->Discard.cRanges,
+                                          pIoReq);
             if (rc == VINF_SUCCESS)
                 rc = VINF_VD_ASYNC_IO_FINISHED;
@@ -4267,5 +4284,5 @@
     if (RT_VALID_PTR(pThis->pBlkCache))
     {
-        PDMR3BlkCacheRelease(pThis->pBlkCache);
+        PDMDrvHlpBlkCacheRelease(pThis->pDrvIns, pThis->pBlkCache);
         pThis->pBlkCache = NULL;
     }
@@ -4317,5 +4334,5 @@
     if (pThis->pBlkCache)
     {
-        int rc = PDMR3BlkCacheResume(pThis->pBlkCache);
+        int rc = PDMDrvHlpBlkCacheResume(pThis->pDrvIns, pThis->pBlkCache);
         AssertRC(rc);
     }
@@ -4424,5 +4441,5 @@
     if (pThis->pBlkCache)
     {
-        int rc = PDMR3BlkCacheSuspend(pThis->pBlkCache);
+        int rc = PDMDrvHlpBlkCacheSuspend(pThis->pDrvIns, pThis->pBlkCache);
         AssertRC(rc);
     }
@@ -4452,5 +4469,5 @@
     if (pThis->pBlkCache)
     {
-        int rc = PDMR3BlkCacheClear(pThis->pBlkCache);
+        int rc = PDMDrvHlpBlkCacheClear(pThis->pDrvIns, pThis->pBlkCache);
         AssertRC(rc);
     }
Index: trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp
===================================================================
--- trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp	(revision 91954)
+++ trunk/src/VBox/VMM/VMMR3/PDMDriver.cpp	(revision 91955)
@@ -2238,4 +2238,13 @@
     PDMR3ThreadResume,
     pdmR3DrvHlp_AsyncCompletionTemplateCreate,
+    PDMR3AsyncCompletionTemplateDestroy,
+    PDMR3AsyncCompletionEpCreateForFile,
+    PDMR3AsyncCompletionEpClose,
+    PDMR3AsyncCompletionEpGetSize,
+    PDMR3AsyncCompletionEpSetSize,
+    PDMR3AsyncCompletionEpSetBwMgr,
+    PDMR3AsyncCompletionEpFlush,
+    PDMR3AsyncCompletionEpRead,
+    PDMR3AsyncCompletionEpWrite,
     pdmR3DrvHlp_NetShaperAttach,
     pdmR3DrvHlp_NetShaperDetach,
@@ -2258,4 +2267,13 @@
     pdmR3DrvHlp_CallR0,
     pdmR3DrvHlp_BlkCacheRetain,
+    PDMR3BlkCacheRelease,
+    PDMR3BlkCacheClear,
+    PDMR3BlkCacheSuspend,
+    PDMR3BlkCacheResume,
+    PDMR3BlkCacheIoXferComplete,
+    PDMR3BlkCacheRead,
+    PDMR3BlkCacheWrite,
+    PDMR3BlkCacheFlush,
+    PDMR3BlkCacheDiscard,
     pdmR3DrvHlp_VMGetSuspendReason,
     pdmR3DrvHlp_VMGetResumeReason,
