DrvVD.cpp revision a5e6836247bf89fb87d0fdf08c1ac8c79dd979ad
77b1a2d8b5dbe2c0b5200794914239fee3c8ee5dvboxsync * DrvVD - Generic VBox disk media driver.
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2010 Oracle Corporation
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * available from http://www.virtualbox.org. This file is free software;
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * General Public License (GPL) as published by the Free Software
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a16eb14ad7a4b5ef91ddc22d3e8e92d930f736fcvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Header files *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/* All lwip header files are not C++ safe. So hack around this. */
efff36b306e370346025647a158689021df2e1d1vboxsync#endif /* VBOX_WITH_INIP */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/* Small hack to get at lwIP initialized status */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncextern bool DevINIPConfigured(void);
efff36b306e370346025647a158689021df2e1d1vboxsync#endif /* VBOX_WITH_INIP */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Defined types, constants and macros *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/** Converts a pointer to VBOXDISK::IMedia to a PVBOXDISK. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync ( (PVBOXDISK)((uintptr_t)pInterface - RT_OFFSETOF(VBOXDISK, IMedia)) )
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** Converts a pointer to PDMDRVINS::IBase to a PPDMDRVINS. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync ( (PPDMDRVINS)((uintptr_t)pInterface - RT_OFFSETOF(PDMDRVINS, IBase)) )
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** Converts a pointer to PDMDRVINS::IBase to a PVBOXDISK. */
0abd77741a608f6c41c8dfcd4781b8b84adf1044vboxsync ( PDMINS_2_DATA(PDMIBASE_2_DRVINS(pInterface), PVBOXDISK) )
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** Converts a pointer to VBOXDISK::IMediaAsync to a PVBOXDISK. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync ( (PVBOXDISK)((uintptr_t)pInterface - RT_OFFSETOF(VBOXDISK, IMediaAsync)) )
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * VBox disk container, image information, private part.
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsynctypedef struct VBOXIMAGE
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Pointer to next image. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Pointer to list of VD interfaces. Per-image. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Common structure for the configuration information interface. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /** Common structure for the supported TCP network stack interface. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /** Common structure for the supported I/O interface. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * Storage backend data.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** PDM async completion end point. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** The template. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Event semaphore for synchronous operations. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Flag whether a synchronous operation is currently pending. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync volatile bool fSyncIoPending;
7766bf675357fd940d8c49e69a5d72dc6eaa6be4vboxsync /** Return code of the last completed request. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Callback routine */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * VBox disk container media main structure, private part.
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIMEDIA
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements PDMIMEDIAASYNC
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements VDINTERFACEERROR
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements VDINTERFACETCPNET
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements VDINTERFACEASYNCIO
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @implements VDINTERFACECONFIG
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsynctypedef struct VBOXDISK
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** The VBox disk container. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** The media interface. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync /** Media port. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Pointer to the driver instance. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Flag whether suspend has changed image open mode to read only. */
21029597fc4b76d0db0c9542daee201447281781vboxsync /** Flag whether to use the runtime (true) or startup error facility. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Pointer to list of VD interfaces. Per-disk. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Common structure for the supported error interface. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Callback table for error interface. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Common structure for the supported thread synchronization interface. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Callback table for thread synchronization interface. */
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync /** Callback table for the configuration information interface. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /** Callback table for TCP network stack interface. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /** Callback table for I/O interface. */
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync /** Flag whether opened disk supports async I/O operations. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** The async media interface. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** The async media port interface above. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Pointer to the list of data we need to keep per image. */
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync /** Flag whether the media should allow concurrent open for writing. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Flag whether a merge operation has been set up. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Synchronization to prevent destruction before merge finishes. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Synchronization between merge and other image accesses. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Source image index for merging. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** Target image index for merging. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Flag whether boot acceleration is enabled. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Flag whether boot acceleration is currently active. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Size of the disk, used for read truncation. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Size of the configured buffer. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Start offset for which the buffer holds data. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** Number of valid bytes in the buffer. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /** The disk buffer. */
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync /** Bandwidth group the disk is assigned to. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync /** I/O interface for a cache image. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync /** Interface list for the cache image. */
009d45aa55691312278d41edb20154dc208d9cd8vboxsync /** The block cache handle if configured. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync* Internal Functions *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * Internal: allocate new image descriptor and put it in the list
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PVBOXIMAGE pImage = (PVBOXIMAGE)RTMemAllocZ(sizeof(VBOXIMAGE));
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * Internal: free the list of images descriptors.
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Make the image temporarily read-only.
16a9adc14900ca18e6909679a579f6833425e030vboxsync * @returns VBox status code.
16a9adc14900ca18e6909679a579f6833425e030vboxsync * @param pThis The driver instance data.
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Undo the temporary read-only status of the image.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @returns VBox status code.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pThis The driver instance data.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/*******************************************************************************
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync* Error reporting callback *
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync*******************************************************************************/
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic void drvvdErrorCallback(void *pvUser, int rc, RT_SRC_POS_DECL,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync /* We must not pass VMSETRTERR_FLAGS_FATAL as it could lead to a
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * deadlock: We are probably executed in a thread context != EMT
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * and the EM thread would wait until every thread is suspended
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * but we would wait for the EM thread ... */
a9d49c8f2b28a72e6a4db86eee91e4569290157bvboxsync PDMDrvHlpVMSetRuntimeErrorV(pDrvIns, /* fFlags=*/ 0, "DrvVD", pszFormat, va);
a9d49c8f2b28a72e6a4db86eee91e4569290157bvboxsync PDMDrvHlpVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
9496f2d398b49813176939d7a339ae513d5175efvboxsync/*******************************************************************************
9496f2d398b49813176939d7a339ae513d5175efvboxsync* VD Async I/O interface implementation *
9496f2d398b49813176939d7a339ae513d5175efvboxsync*******************************************************************************/
22ec733a5e041fcdfe02fce2eafc9faf8b0077ddvboxsyncstatic DECLCALLBACK(void) drvvdAsyncTaskCompleted(PPDMDRVINS pDrvIns, void *pvTemplateUser, void *pvUser, int rcReq)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pvTemplateUser;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogFlowFunc(("pDrvIns=%#p pvTemplateUser=%#p pvUser=%#p rcReq\n",
bbede9c189def47a9880f0ffb03c0c230c774185vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOOpen(void *pvUser, const char *pszLocation,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)RTMemAllocZ(sizeof(DRVVDSTORAGEBACKEND));
fbf08fabb4c4b383d6aa2830c2bd5b943a26f10cvboxsync rc = PDMDrvHlpAsyncCompletionTemplateCreate(pThis->pDrvIns, &pStorageBackend->pTemplate,
fbf08fabb4c4b383d6aa2830c2bd5b943a26f10cvboxsync drvvdAsyncTaskCompleted, pStorageBackend, "AsyncTaskCompleted");
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync uint32_t fFlags = (fOpen & RTFILE_O_ACCESS_MASK) == RTFILE_O_READ
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync Assert((fOpen & RTFILE_O_DENY_MASK) == RTFILE_O_DENY_NONE);
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync rc = PDMR3AsyncCompletionEpCreateForFile(&pStorageBackend->pEndpoint,
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync rc = PDMR3AsyncCompletionEpSetBwMgr(pStorageBackend->pEndpoint, pThis->pszBwGroup);
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync PDMR3AsyncCompletionEpClose(pStorageBackend->pEndpoint);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOClose(void *pvUser, void *pStorage)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDMR3AsyncCompletionEpClose(pStorageBackend->pEndpoint);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOReadSync(void *pvUser, void *pStorage, uint64_t uOffset,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbRead, NULL, &pTask);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOWriteSync(void *pvUser, void *pStorage, uint64_t uOffset,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync const void *pvBuf, size_t cbWrite, size_t *pcbWritten)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbWrite, NULL, &pTask);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOFlushSync(void *pvUser, void *pStorage)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogFlowFunc(("pvUser=%#p pStorage=%#p\n", pvUser, pStorage));
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, NULL, &pTask);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOReadAsync(void *pvUser, void *pStorage, uint64_t uOffset,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync int rc = PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, paSegments, cSegments, cbRead,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOWriteAsync(void *pvUser, void *pStorage, uint64_t uOffset,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync int rc = PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, paSegments, cSegments, cbWrite,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOFlushAsync(void *pvUser, void *pStorage,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync int rc = PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, pvCompletion,
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOGetSize(void *pvUser, void *pStorage, uint64_t *pcbSize)
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync return PDMR3AsyncCompletionEpGetSize(pStorageBackend->pEndpoint, pcbSize);
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOSetSize(void *pvUser, void *pStorage, uint64_t cbSize)
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync rc = PDMR3AsyncCompletionEpSetSize(pStorageBackend->pEndpoint, cbSize);
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync#endif /* VBOX_WITH_PDM_ASYNC_COMPLETION */
16a9adc14900ca18e6909679a579f6833425e030vboxsync/*******************************************************************************
16a9adc14900ca18e6909679a579f6833425e030vboxsync* VD Thread Synchronization interface implementation *
16a9adc14900ca18e6909679a579f6833425e030vboxsync*******************************************************************************/
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdThreadStartRead(void *pvUser)
16a9adc14900ca18e6909679a579f6833425e030vboxsync return RTSemRWRequestRead(pThis->MergeLock, RT_INDEFINITE_WAIT);
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdThreadFinishRead(void *pvUser)
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdThreadStartWrite(void *pvUser)
16a9adc14900ca18e6909679a579f6833425e030vboxsync return RTSemRWRequestWrite(pThis->MergeLock, RT_INDEFINITE_WAIT);
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdThreadFinishWrite(void *pvUser)
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync/*******************************************************************************
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync* VD Configuration interface implementation *
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync*******************************************************************************/
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsyncstatic bool drvvdCfgAreKeysValid(void *pvUser, const char *pszzValid)
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync return CFGMR3AreValuesValid((PCFGMNODE)pvUser, pszzValid);
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsyncstatic int drvvdCfgQuerySize(void *pvUser, const char *pszName, size_t *pcb)
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync return CFGMR3QuerySize((PCFGMNODE)pvUser, pszName, pcb);
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsyncstatic int drvvdCfgQuery(void *pvUser, const char *pszName, char *pszString, size_t cchString)
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync return CFGMR3QueryString((PCFGMNODE)pvUser, pszName, pszString, cchString);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/*******************************************************************************
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync* VD TCP network stack interface implementation - INIP case *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsynctypedef struct INIPSOCKET
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPFlush(VDSOCKET Sock);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSocketCreate */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPSocketCreate(uint32_t fFlags, PVDSOCKET pSock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * The extended select method is not supported because it is impossible to wakeup
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * the thread.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (fFlags & VD_INTERFACETCPNET_CONNECT_EXTENDED_SELECT)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pSocketInt = (PINIPSOCKET)RTMemAllocZ(sizeof(INIPSOCKET));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSocketCreate */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPSocketDestroy(VDSOCKET Sock)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnClientConnect */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPClientConnect(VDSOCKET Sock, const char *pszAddress, uint32_t uPort)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Check whether lwIP is set up in this VM instance. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* Resolve hostname. As there is no standard resolver for lwIP yet,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * just accept numeric IP addresses for now. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogRelFunc(("cannot resolve IP %s\n", pszAddress));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* Create socket and connect. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (!lwip_connect(iSock, (struct sockaddr *)&InAddr, sizeof(InAddr)))
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync rc = VERR_NET_CONNECTION_REFUSED; /* @todo real solution needed */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync rc = VERR_NET_CONNECTION_REFUSED; /* @todo real solution needed */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnClientClose */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPClientClose(VDSOCKET Sock)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return VINF_SUCCESS; /** @todo real solution needed */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnIsClientConnected */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(bool) drvvdINIPIsClientConnected(VDSOCKET Sock)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnSelectOne */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPSelectOne(VDSOCKET Sock, RTMSINTERVAL cMillies)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = lwip_select(pSocketInt->hSock + 1, &fdsetR, NULL, &fdsetE, NULL);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = lwip_select(pSocketInt->hSock + 1, &fdsetR, NULL, &fdsetE, &timeout);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution needed */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnRead */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPRead(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* Do params checking */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Read loop.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * If pcbRead is NULL we have to fill the entire buffer!
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /** @todo this clipping here is just in case (the send function
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * needed it, so I added it here, too). Didn't investigate if this
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * really has issues. Better be safe than sorry. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync ssize_t cbBytesRead = lwip_recv(pSocketInt->hSock, (char *)pvBuffer + cbRead,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution */
59a2c1c0a4a0762b46bc5ff056f5705ec9c0a660vboxsync if (cbBytesRead == 0 && errno) /** @todo r=bird: lwip_recv will not touch errno on Windows. This may apply to other hosts as well */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* return partial data */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* read more? */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnWrite */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPWrite(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /** @todo lwip send only supports up to 65535 bytes in a single
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * send (stupid limitation buried in the code), so make sure we
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * don't get any wraparounds. This should be moved to DevINIP
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * stack interface once that's implemented. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync ssize_t cbWritten = lwip_send(pSocketInt->hSock, (void *)pvBuffer,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution needed */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync AssertMsg(cbBuffer >= (size_t)cbWritten, ("Wrote more than we requested!!! cbWritten=%d cbBuffer=%d\n",
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync/** @copydoc VDINTERFACETCPNET::pfnSgWrite */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPSgWrite(VDSOCKET Sock, PCRTSGBUF pSgBuf)
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync /* This is an extremely crude emulation, however it's good enough
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync * for our iSCSI code. INIP has no sendmsg(). */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc VDINTERFACETCPNET::pfnFlush */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPFlush(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync lwip_setsockopt(pSocketInt->hSock, IPPROTO_TCP, TCP_NODELAY,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync lwip_setsockopt(pSocketInt->hSock, IPPROTO_TCP, TCP_NODELAY,
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync/** @copydoc VDINTERFACETCPNET::pfnSetSendCoalescing */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPSetSendCoalescing(VDSOCKET Sock, bool fEnable)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync lwip_setsockopt(pSocketInt->hSock, IPPROTO_TCP, TCP_NODELAY,
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetLocalAddress */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPGetLocalAddress(VDSOCKET Sock, PRTNETADDR pAddr)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (!lwip_getsockname(pSocketInt->hSock, &u.Addr, &cbAddr))
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * Convert the address.
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetPeerAddress */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPGetPeerAddress(VDSOCKET Sock, PRTNETADDR pAddr)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (!lwip_getpeername(pSocketInt->hSock, &u.Addr, &cbAddr))
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * Convert the address.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSelectOneEx */
51a01524909c95ee04b636218b6a89b29fb81825vboxsyncstatic DECLCALLBACK(int) drvvdINIPSelectOneEx(VDSOCKET Sock, uint32_t fEvents, uint32_t *pfEvents, RTMSINTERVAL cMillies)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnPoke */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdINIPPoke(VDSOCKET Sock)
efff36b306e370346025647a158689021df2e1d1vboxsync#endif /* VBOX_WITH_INIP */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/*******************************************************************************
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync* VD TCP network stack interface implementation - Host TCP case *
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync*******************************************************************************/
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Socket data.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsynctypedef struct VDSOCKETINT
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** IPRT socket handle. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** Pollset with the wakeup pipe and socket. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** Pipe endpoint - read (in the pollset). */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** Pipe endpoint - write. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** Flag whether the thread was woken up. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync volatile bool fWokenUp;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /** Flag whether the thread is waiting in the select call. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync volatile bool fWaiting;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync /** Old event mask. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** Pollset id of the socket. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** Pollset id of the pipe. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSocketCreate */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpSocketCreate(uint32_t fFlags, PVDSOCKET pSock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pSockInt = (PVDSOCKETINT)RTMemAllocZ(sizeof(VDSOCKETINT));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (fFlags & VD_INTERFACETCPNET_CONNECT_EXTENDED_SELECT)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Init pipe and pollset. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPipeCreate(&pSockInt->hPipeR, &pSockInt->hPipeW, 0);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPollSetAddPipe(pSockInt->hPollSet, pSockInt->hPipeR,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync RTPollSetRemove(pSockInt->hPollSet, VDSOCKET_POLL_ID_PIPE);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSocketDestroy */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpSocketDestroy(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Destroy the pipe and pollset if necessary. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPollSetRemove(pSockInt->hPollSet, VDSOCKET_POLL_ID_SOCKET);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync Assert(RT_SUCCESS(rc) || rc == VERR_POLL_HANDLE_ID_NOT_FOUND);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPollSetRemove(pSockInt->hPollSet, VDSOCKET_POLL_ID_PIPE);
a2f96875f61628e5a5fd33785f8c0bbb310f981fvboxsync rc = RTTcpClientCloseEx(pSockInt->hSocket, false /*fGracefulShutdown*/);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnClientConnect */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpClientConnect(VDSOCKET Sock, const char *pszAddress, uint32_t uPort)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTTcpClientConnect(pszAddress, uPort, &pSockInt->hSocket);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Add to the pollset if required. */
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pSockInt->fEventsOld = RTPOLL_EVT_READ | RTPOLL_EVT_WRITE | RTPOLL_EVT_ERROR;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPollSetAddSocket(pSockInt->hPollSet, pSockInt->hSocket,
a2f96875f61628e5a5fd33785f8c0bbb310f981fvboxsync rc = RTTcpClientCloseEx(pSockInt->hSocket, false /*fGracefulShutdown*/);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnClientClose */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpClientClose(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPollSetRemove(pSockInt->hPollSet, VDSOCKET_POLL_ID_SOCKET);
a2f96875f61628e5a5fd33785f8c0bbb310f981fvboxsync rc = RTTcpClientCloseEx(pSockInt->hSocket, false /*fGracefulShutdown*/);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnIsClientConnected */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(bool) drvvdTcpIsClientConnected(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSelectOne */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpSelectOne(VDSOCKET Sock, RTMSINTERVAL cMillies)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpSelectOne(pSockInt->hSocket, cMillies);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnRead */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpRead(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpRead(pSockInt->hSocket, pvBuffer, cbBuffer, pcbRead);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnWrite */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpWrite(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpWrite(pSockInt->hSocket, pvBuffer, cbBuffer);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSgWrite */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpSgWrite(VDSOCKET Sock, PCRTSGBUF pSgBuf)
51a01524909c95ee04b636218b6a89b29fb81825vboxsync/** @copydoc VDINTERFACETCPNET::pfnReadNB */
51a01524909c95ee04b636218b6a89b29fb81825vboxsyncstatic DECLCALLBACK(int) drvvdTcpReadNB(VDSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)
51a01524909c95ee04b636218b6a89b29fb81825vboxsync return RTTcpReadNB(pSockInt->hSocket, pvBuffer, cbBuffer, pcbRead);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync/** @copydoc VDINTERFACETCPNET::pfnWriteNB */
51a01524909c95ee04b636218b6a89b29fb81825vboxsyncstatic DECLCALLBACK(int) drvvdTcpWriteNB(VDSOCKET Sock, const void *pvBuffer, size_t cbBuffer, size_t *pcbWritten)
51a01524909c95ee04b636218b6a89b29fb81825vboxsync return RTTcpWriteNB(pSockInt->hSocket, pvBuffer, cbBuffer, pcbWritten);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync/** @copydoc VDINTERFACETCPNET::pfnSgWriteNB */
51a01524909c95ee04b636218b6a89b29fb81825vboxsyncstatic DECLCALLBACK(int) drvvdTcpSgWriteNB(VDSOCKET Sock, PRTSGBUF pSgBuf, size_t *pcbWritten)
51a01524909c95ee04b636218b6a89b29fb81825vboxsync return RTTcpSgWriteNB(pSockInt->hSocket, pSgBuf, pcbWritten);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnFlush */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpFlush(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnSetSendCoalescing */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpSetSendCoalescing(VDSOCKET Sock, bool fEnable)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpSetSendCoalescing(pSockInt->hSocket, fEnable);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetLocalAddress */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpGetLocalAddress(VDSOCKET Sock, PRTNETADDR pAddr)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpGetLocalAddress(pSockInt->hSocket, pAddr);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetPeerAddress */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpGetPeerAddress(VDSOCKET Sock, PRTNETADDR pAddr)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return RTTcpGetPeerAddress(pSockInt->hSocket, pAddr);
b0b15690f00527424b2d5fb88456d747252322f7vboxsyncstatic int drvvdTcpSelectOneExPoll(VDSOCKET Sock, uint32_t fEvents,
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = RTPollSetEventsChange(pSockInt->hPollSet, VDSOCKET_POLL_ID_SOCKET, fPollEvents);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = RTPoll(pSockInt->hPollSet, cMillies, &fEventsRecv, &id);
217fa436516d137a409bb493cb7d350898f64666vboxsync Assert((fEventsRecv & RTPOLL_EVT_VALID_MASK) == RTPOLL_EVT_READ);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* We got interrupted, drain the pipe. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPipeRead(pSockInt->hPipeR, abBuf, sizeof(abBuf), &cbRead);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync/** @copydoc VDINTERFACETCPNET::pfnSelectOneEx */
b0b15690f00527424b2d5fb88456d747252322f7vboxsyncstatic DECLCALLBACK(int) drvvdTcpSelectOneExNoPoll(VDSOCKET Sock, uint32_t fEvents,
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * Only the pipe is configured or the caller doesn't wait for a socket event,
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * wait until there is something to read from the pipe.
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTPipeReadBlocking(pSockInt->hPipeR, &ch, 1, &cbRead);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* Make sure the socket is not in the pollset. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTPollSetRemove(pSockInt->hPollSet, VDSOCKET_POLL_ID_SOCKET);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync Assert(RT_SUCCESS(rc) || rc == VERR_POLL_HANDLE_ID_NOT_FOUND);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* Check the socket. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTTcpSelectOneEx(pSockInt->hSocket, fSelectEvents, &fEventsRecv, 0);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync break; /* Quit */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync Assert((fEventsRecv & RTPOLL_EVT_VALID_MASK) == RTPOLL_EVT_READ);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* We got interrupted, drain the pipe. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTPipeRead(pSockInt->hPipeR, abBuf, sizeof(abBuf), &cbRead);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync else /* The caller waits for a socket event. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* Loop until we got woken up or a socket event occurred. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /** @todo find an adaptive wait algorithm based on the
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * number of wakeups in the past. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTTcpSelectOneEx(pSockInt->hSocket, fSelectEvents, &fEventsRecv, 5);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* Check if there is an event pending. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTPipeRead(pSockInt->hPipeR, &ch, 1, &cbRead);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync break; /* Quit */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync break; /* Quit */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc VDINTERFACETCPNET::pfnPoke */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdTcpPoke(VDSOCKET Sock)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = RTPipeWrite(pSockInt->hPipeW, "", 1, &cbWritten);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Media interface methods *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnRead */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdRead(PPDMIMEDIA pInterface,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync LogFlowFunc(("off=%#llx pvBuf=%p cbRead=%d\n", off, pvBuf, cbRead));
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /* Can we serve the request from the buffer? */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync size_t cbToCopy = RT_MIN(cbRead, pThis->offDisk + pThis->cbDataValid - off);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync memcpy(pvBuf, pThis->pbData + (off - pThis->offDisk), cbToCopy);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /* Increase request to the buffer size and read. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync pThis->cbDataValid = RT_MIN(pThis->cbDisk - off, pThis->cbBootAccelBuffer);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync rc = VDRead(pThis->pDisk, off, pThis->pbData, pThis->cbDataValid);
ff88d4153cd65650577e8c2d1a5a3fdfa0404a80vboxsync Log2(("%s: off=%#llx pvBuf=%p cbRead=%d %.*Rhxd\n", __FUNCTION__,
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnWrite */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdWrite(PPDMIMEDIA pInterface,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync LogFlowFunc(("off=%#llx pvBuf=%p cbWrite=%d\n", off, pvBuf, cbWrite));
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
ff88d4153cd65650577e8c2d1a5a3fdfa0404a80vboxsync Log2(("%s: off=%#llx pvBuf=%p cbWrite=%d %.*Rhxd\n", __FUNCTION__,
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /* Invalidate any buffer if boot acceleration is enabled. */
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync int rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnFlush */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdFlush(PPDMIMEDIA pInterface)
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
16a9adc14900ca18e6909679a579f6833425e030vboxsync/** @copydoc PDMIMEDIA::pfnMerge */
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdMerge(PPDMIMEDIA pInterface,
16a9adc14900ca18e6909679a579f6833425e030vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
16a9adc14900ca18e6909679a579f6833425e030vboxsync /* Note: There is an unavoidable race between destruction and another
16a9adc14900ca18e6909679a579f6833425e030vboxsync * thread invoking this function. This is handled safely and gracefully by
16a9adc14900ca18e6909679a579f6833425e030vboxsync * atomically invalidating the lock handle in drvvdDestruct. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync int rc2 = RTSemFastMutexRequest(pThis->MergeCompleteMutex);
16a9adc14900ca18e6909679a579f6833425e030vboxsync /* Take shortcut: PFNSIMPLEPROGRESS is exactly the same type as
16a9adc14900ca18e6909679a579f6833425e030vboxsync * PFNVDPROGRESS, so there's no need for a conversion function. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** @todo maybe introduce a conversion which limits update frequency. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync VDIProgressCallbacks.cbSize = sizeof(VDINTERFACEPROGRESS);
16a9adc14900ca18e6909679a579f6833425e030vboxsync VDIProgressCallbacks.enmInterface = VDINTERFACETYPE_PROGRESS;
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc2 = VDInterfaceAdd(&VDIProgress, "DrvVD_VDIProgress", VDINTERFACETYPE_PROGRESS,
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc2 = RTSemFastMutexRelease(pThis->MergeCompleteMutex);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnGetSize */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(uint64_t) drvvdGetSize(PPDMIMEDIA pInterface)
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync uint64_t cb = VDGetSize(pThis->pDisk, VD_LAST_IMAGE);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnIsReadOnly */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(bool) drvvdIsReadOnly(PPDMIMEDIA pInterface)
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsync/** @copydoc PDMIMEDIA::pfnBiosGetPCHSGeometry */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdBiosGetPCHSGeometry(PPDMIMEDIA pInterface,
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync int rc = VDGetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsync/** @copydoc PDMIMEDIA::pfnBiosSetPCHSGeometry */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdBiosSetPCHSGeometry(PPDMIMEDIA pInterface,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync int rc = VDSetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo);
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsync/** @copydoc PDMIMEDIA::pfnBiosGetLCHSGeometry */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdBiosGetLCHSGeometry(PPDMIMEDIA pInterface,
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync int rc = VDGetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsync/** @copydoc PDMIMEDIA::pfnBiosSetLCHSGeometry */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdBiosSetLCHSGeometry(PPDMIMEDIA pInterface,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync int rc = VDSetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, &geo);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIMEDIA::pfnGetUuid */
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid)
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync LogFlowFunc(("returns %Rrc ({%RTuuid})\n", rc, pUuid));
9496f2d398b49813176939d7a339ae513d5175efvboxsync/*******************************************************************************
9496f2d398b49813176939d7a339ae513d5175efvboxsync* Async Media interface methods *
9496f2d398b49813176939d7a339ae513d5175efvboxsync*******************************************************************************/
f687f34bd232be13744edbc0cc5155fa5d4540edvboxsyncstatic void drvvdAsyncReqComplete(void *pvUser1, void *pvUser2, int rcReq)
009d45aa55691312278d41edb20154dc208d9cd8vboxsync int rc = pThis->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pThis->pDrvMediaAsyncPort,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, (PPDMBLKCACHEIOXFER)pvUser2, rcReq);
b7a5b3f9f9ecce32ddacf8404c625ce0451bbdc1vboxsyncstatic DECLCALLBACK(int) drvvdStartRead(PPDMIMEDIAASYNC pInterface, uint64_t uOffset,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync LogFlowFunc(("uOffset=%#llx paSeg=%#p cSeg=%u cbRead=%d pvUser=%#p\n",
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncRead(pThis->pDisk, uOffset, cbRead, &SgBuf,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = PDMR3BlkCacheRead(pThis->pBlkCache, uOffset, &SgBuf, cbRead, pvUser);
9496f2d398b49813176939d7a339ae513d5175efvboxsyncstatic DECLCALLBACK(int) drvvdStartWrite(PPDMIMEDIAASYNC pInterface, uint64_t uOffset,
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync LogFlowFunc(("uOffset=%#llx paSeg=%#p cSeg=%u cbWrite=%d pvUser=%#p\n",
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncWrite(pThis->pDisk, uOffset, cbWrite, &SgBuf,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = PDMR3BlkCacheWrite(pThis->pBlkCache, uOffset, &SgBuf, cbWrite, pvUser);
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsyncstatic DECLCALLBACK(int) drvvdStartFlush(PPDMIMEDIAASYNC pInterface, void *pvUser)
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncFlush(pThis->pDisk, drvvdAsyncReqComplete, pThis, pvUser);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync/** @copydoc FNPDMBLKCACHEXFERCOMPLETEDRV */
009d45aa55691312278d41edb20154dc208d9cd8vboxsyncstatic void drvvdBlkCacheXferComplete(PPDMDRVINS pDrvIns, void *pvUser, int rcReq)
009d45aa55691312278d41edb20154dc208d9cd8vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync int rc = pThis->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pThis->pDrvMediaAsyncPort,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync/** @copydoc FNPDMBLKCACHEXFERENQUEUEDRV */
009d45aa55691312278d41edb20154dc208d9cd8vboxsyncstatic int drvvdBlkCacheXferEnqueue(PPDMDRVINS pDrvIns,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncRead(pThis->pDisk, off, cbXfer, pcSgBuf, drvvdAsyncReqComplete,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncWrite(pThis->pDisk, off, cbXfer, pcSgBuf, drvvdAsyncReqComplete,
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = VDAsyncFlush(pThis->pDisk, drvvdAsyncReqComplete, pThis, hIoXfer);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync AssertMsgFailed(("Invalid transfer type %d\n", enmXferDir));
009d45aa55691312278d41edb20154dc208d9cd8vboxsync PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, VINF_SUCCESS);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync else if (RT_FAILURE(rc) && rc != VERR_VD_ASYNC_IO_IN_PROGRESS)
009d45aa55691312278d41edb20154dc208d9cd8vboxsync PDMR3BlkCacheIoXferComplete(pThis->pBlkCache, hIoXfer, rc);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Base interface methods *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsyncstatic DECLCALLBACK(void *) drvvdQueryInterface(PPDMIBASE pInterface, const char *pszIID)
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
a39ea3668b7019c23a68936259545f9b71bce1aavboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIA, &pThis->IMedia);
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNC, pThis->fAsyncIOSupported ? &pThis->IMediaAsync : NULL);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/*******************************************************************************
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync* Saved state notification methods *
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync*******************************************************************************/
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Load done callback for re-opening the image writable during teleportation.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * This is called both for successful and failed load runs, we only care about
ad27e1d5e48ca41245120c331cc88b50464813cevboxsync * successful ones.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @returns VBox status code.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pDrvIns The driver instance.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pSSM The saved state handle.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(int) drvvdLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync /* Drop out if we don't have any work to do or if it's a failed load. */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync if (RT_FAILURE(rc)) /** @todo does the bugger set any errors? */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Driver methods *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * VM resume notification that we use to undo what the temporary read-only image
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * mode set by drvvdSuspend.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Also switch to runtime error mode if we're resuming after a state load
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * without having been powered on first.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pDrvIns The driver instance data.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @todo The VMSetError vs VMSetRuntimeError mess must be fixed elsewhere,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * we're making assumptions about Main behavior here!
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(void) drvvdResume(PPDMDRVINS pDrvIns)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * The VM is being suspended, temporarily change to read-only image mode.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * This is important for several reasons:
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * -# It makes sure that there are no pending writes to the image. Most
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * backends implements this by closing and reopening the image in read-only
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * -# It allows Main to read the images during snapshotting without having
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * to account for concurrent writes.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * -# This is essential for making teleportation targets sharing images work
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * right. Both with regards to caching and with regards to file sharing
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * locks (RTFILE_O_DENY_*). (See also drvvdLoadDone.)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pDrvIns The driver instance data.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(void) drvvdSuspend(PPDMDRVINS pDrvIns)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * VM PowerOn notification for undoing the TempReadOnly config option and
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * changing to runtime error mode.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @param pDrvIns The driver instance data.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @todo The VMSetError vs VMSetRuntimeError mess must be fixed elsewhere,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * we're making assumptions about Main behavior here!
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(void) drvvdPowerOn(PPDMDRVINS pDrvIns)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync * @copydoc FNPDMDRVRESET
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsyncstatic DECLCALLBACK(void) drvvdReset(PPDMDRVINS pDrvIns)
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * @copydoc FNPDMDRVDESTRUCT
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(void) drvvdDestruct(PPDMDRVINS pDrvIns)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
c7ff622115966b69b482bd2896662e40d823b22fvboxsync ASMAtomicXchgHandle(&pThis->MergeCompleteMutex, NIL_RTSEMFASTMUTEX, &mutex);
16a9adc14900ca18e6909679a579f6833425e030vboxsync /* Request the semaphore to wait until a potentially running merge
16a9adc14900ca18e6909679a579f6833425e030vboxsync * operation has been finished. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Construct a VBox disk media driver instance.
cba6719bd64ec749967bbe931230452664109857vboxsync * @copydoc FNPDMDRVCONSTRUCT
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsyncstatic DECLCALLBACK(int) drvvdConstruct(PPDMDRVINS pDrvIns,
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync char *pszName = NULL; /**< The path of the disk image file. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync char *pszFormat = NULL; /**< The format backed to use for this image. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync char *pszCachePath = NULL; /**< The path to the cache image. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync char *pszCacheFormat = NULL; /**< The format backend to use for the cache image. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync bool fReadOnly; /**< True if the media is read-only. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync bool fMaybeReadOnly; /**< True if the media may or may not be read-only. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync bool fHonorZeroWrites; /**< True if zero blocks should be written. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Init the static parts.
8083a259c13e6e26e56ca2582edbad4a8cfac25avboxsync pDrvIns->IBase.pfnQueryInterface = drvvdQueryInterface;
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* IMedia */
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry;
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry;
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry;
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry;
9496f2d398b49813176939d7a339ae513d5175efvboxsync /* IMediaAsync */
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->IMediaAsync.pfnStartWrite = drvvdStartWrite;
fc78e01f665145ab3641c5f8095e9ae984ddcb84vboxsync pThis->IMediaAsync.pfnStartFlush = drvvdStartFlush;
9496f2d398b49813176939d7a339ae513d5175efvboxsync /* Initialize supported VD interfaces. */
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIErrorCallbacks.cbSize = sizeof(VDINTERFACEERROR);
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIErrorCallbacks.pfnError = drvvdErrorCallback;
68a4ee3a31a0807abd03eae881c1bbaf4d42ee6dvboxsync rc = VDInterfaceAdd(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync &pThis->VDIErrorCallbacks, pDrvIns, &pThis->pVDIfsDisk);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /* This is just prepared here, the actual interface is per-image, so it's
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * added later. No need to have separate callback tables. */
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIConfigCallbacks.cbSize = sizeof(VDINTERFACECONFIG);
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIConfigCallbacks.enmInterface = VDINTERFACETYPE_CONFIG;
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync pThis->VDIConfigCallbacks.pfnAreKeysValid = drvvdCfgAreKeysValid;
548ca31b6b47c36bacce49bed3339cb8075b9681vboxsync pThis->VDIConfigCallbacks.pfnQuerySize = drvvdCfgQuerySize;
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync pThis->VDIConfigCallbacks.pfnQuery = drvvdCfgQuery;
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /* List of images is empty now. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync pThis->pDrvMediaPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAPORT);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
9496f2d398b49813176939d7a339ae513d5175efvboxsync /* Try to attach async media port interface above.*/
da3503c04ce76e653401396fe2795a9bc2427a1dvboxsync pThis->pDrvMediaAsyncPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAASYNCPORT);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Validate configuration and find all parent images.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * It's sort of up side down from the image dependency tree.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync bool fHostIP = false;
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync bool fUseNewIo = false;
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync unsigned iLevel = 0;
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync /* Toplevel configuration additionally contains the global image
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync * open flags. Some might be converted to per-image flags later. */
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync "Format\0Path\0"
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync "ReadOnly\0MaybeReadOnly\0TempReadOnly\0Shareable\0HonorZeroWrites\0"
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync "HostIPStack\0UseNewIo\0BootAcceleration\0BootAccelerationBuffer\0"
009d45aa55691312278d41edb20154dc208d9cd8vboxsync "SetupMerge\0MergeSource\0MergeTarget\0BwGroup\0Type\0BlockCache\0"
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync "CachePath\0CacheFormat\0");
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync /* All other image configurations only contain image name and
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync * the format information. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync fValid = CFGMR3AreValuesValid(pCurNode, "Format\0Path\0"
16a9adc14900ca18e6909679a579f6833425e030vboxsync "MergeSource\0MergeTarget\0");
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync RT_SRC_POS, N_("DrvVD: Configuration error: keys incorrect at level %d"), iLevel);
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync rc = CFGMR3QueryBoolDef(pCurNode, "HostIPStack", &fHostIP, true);
0ccdfa1953b2f57311fb9ec01a2baf5e1e366f5avboxsync N_("DrvVD: Configuration error: Querying \"HostIPStack\" as boolean failed"));
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync rc = CFGMR3QueryBoolDef(pCurNode, "HonorZeroWrites", &fHonorZeroWrites, false);
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync N_("DrvVD: Configuration error: Querying \"HonorZeroWrites\" as boolean failed"));
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync rc = CFGMR3QueryBoolDef(pCurNode, "ReadOnly", &fReadOnly, false);
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync N_("DrvVD: Configuration error: Querying \"ReadOnly\" as boolean failed"));
24a0cc1776a88752cc25446a98e2a3881e623216vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "MaybeReadOnly", &fMaybeReadOnly, false);
24a0cc1776a88752cc25446a98e2a3881e623216vboxsync N_("DrvVD: Configuration error: Querying \"MaybeReadOnly\" as boolean failed"));
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync rc = CFGMR3QueryBoolDef(pCurNode, "TempReadOnly", &pThis->fTempReadOnly, false);
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync N_("DrvVD: Configuration error: Querying \"TempReadOnly\" as boolean failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync N_("DrvVD: Configuration error: Both \"ReadOnly\" and \"TempReadOnly\" are set"));
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "Shareable", &pThis->fShareable, false);
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync N_("DrvVD: Configuration error: Querying \"Shareable\" as boolean failed"));
44fc72ff17b23a9b970505fcf8d6da1019ddcec5vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "UseNewIo", &fUseNewIo, false);
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync N_("DrvVD: Configuration error: Querying \"UseNewIo\" as boolean failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "SetupMerge", &pThis->fMergePending, false);
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Querying \"SetupMerge\" as boolean failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Both \"ReadOnly\" and \"MergePending\" are set"));
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "BootAcceleration", &pThis->fBootAccelEnabled, false);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync N_("DrvVD: Configuration error: Querying \"BootAcceleration\" as boolean failed"));
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync rc = CFGMR3QueryU32Def(pCurNode, "BootAccelerationBuffer", (uint32_t *)&pThis->cbBootAccelBuffer, 16 * _1K);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync N_("DrvVD: Configuration error: Querying \"BootAccelerationBuffer\" as integer failed"));
009d45aa55691312278d41edb20154dc208d9cd8vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "BlockCache", &fUseBlockCache, false);
009d45aa55691312278d41edb20154dc208d9cd8vboxsync N_("DrvVD: Configuration error: Querying \"BlockCache\" as boolean failed"));
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "BwGroup", &pThis->pszBwGroup);
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND)
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync N_("DrvVD: Configuration error: Querying \"BwGroup\" as string failed"));
ee00a0b29854e7f513198772bccb6650f6dd2184vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type"));
ee00a0b29854e7f513198772bccb6650f6dd2184vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS,
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "CachePath", &pszCachePath);
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync if (RT_FAILURE(rc) && rc != VERR_CFGM_VALUE_NOT_FOUND)
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync N_("DrvVD: Configuration error: Querying \"CachePath\" as string failed"));
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "CacheFormat", &pszCacheFormat);
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync N_("DrvVD: Configuration error: Querying \"CacheFormat\" as string failed"));
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync PCFGMNODE pParent = CFGMR3GetChild(pCurNode, "Parent");
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Create the image container and the necessary interfaces.
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /* Construct TCPNET callback table depending on the config. This is
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * done unconditionally, as uninterested backends will ignore it. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.cbSize = sizeof(VDINTERFACETCPNET);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.enmInterface = VDINTERFACETYPE_TCPNET;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSocketCreate = drvvdTcpSocketCreate;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSocketDestroy = drvvdTcpSocketDestroy;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientConnect = drvvdTcpClientConnect;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnIsClientConnected = drvvdTcpIsClientConnected;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientClose = drvvdTcpClientClose;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSelectOne = drvvdTcpSelectOne;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnWrite = drvvdTcpWrite;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSgWrite = drvvdTcpSgWrite;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pThis->VDITcpNetCallbacks.pfnReadNB = drvvdTcpReadNB;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pThis->VDITcpNetCallbacks.pfnWriteNB = drvvdTcpWriteNB;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pThis->VDITcpNetCallbacks.pfnSgWriteNB = drvvdTcpSgWriteNB;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnFlush = drvvdTcpFlush;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSetSendCoalescing = drvvdTcpSetSendCoalescing;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetLocalAddress = drvvdTcpGetLocalAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetPeerAddress = drvvdTcpGetPeerAddress;
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * There is a 15ms delay between receiving the data and marking the socket
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * as readable on Windows XP which hurts async I/O performance of
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * TCP backends badly. Provide a different select method without
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * using poll on XP.
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * This is only used on XP because it is not as efficient as the one using poll
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * and all other Windows versions are working fine.
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, &szOS[0], sizeof(szOS));
b0b15690f00527424b2d5fb88456d747252322f7vboxsync if (RT_SUCCESS(rc) && !strncmp(szOS, "Windows XP", 10))
b0b15690f00527424b2d5fb88456d747252322f7vboxsync LogRel(("VD: Detected Windows XP, disabled poll based waiting for TCP\n"));
b0b15690f00527424b2d5fb88456d747252322f7vboxsync pThis->VDITcpNetCallbacks.pfnSelectOneEx = drvvdTcpSelectOneExNoPoll;
b0b15690f00527424b2d5fb88456d747252322f7vboxsync pThis->VDITcpNetCallbacks.pfnSelectOneEx = drvvdTcpSelectOneExPoll;
a3369a746b56a8966dd78619f4d191c9662f400dvboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
efff36b306e370346025647a158689021df2e1d1vboxsync RT_SRC_POS, N_("DrvVD: Configuration error: TCP over Internal Networking not compiled in"));
efff36b306e370346025647a158689021df2e1d1vboxsync#else /* VBOX_WITH_INIP */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.cbSize = sizeof(VDINTERFACETCPNET);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.enmInterface = VDINTERFACETYPE_TCPNET;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSocketCreate = drvvdINIPSocketCreate;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSocketDestroy = drvvdINIPSocketDestroy;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.pfnClientConnect = drvvdINIPClientConnect;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.pfnClientClose = drvvdINIPClientClose;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnIsClientConnected = drvvdINIPIsClientConnected;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.pfnSelectOne = drvvdINIPSelectOne;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.pfnWrite = drvvdINIPWrite;
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync pThis->VDITcpNetCallbacks.pfnSgWrite = drvvdINIPSgWrite;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->VDITcpNetCallbacks.pfnFlush = drvvdINIPFlush;
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync pThis->VDITcpNetCallbacks.pfnSetSendCoalescing = drvvdINIPSetSendCoalescing;
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync pThis->VDITcpNetCallbacks.pfnGetLocalAddress = drvvdINIPGetLocalAddress;
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync pThis->VDITcpNetCallbacks.pfnGetPeerAddress = drvvdINIPGetPeerAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSelectOneEx = drvvdINIPSelectOneEx;
efff36b306e370346025647a158689021df2e1d1vboxsync#endif /* VBOX_WITH_INIP */
c8cedf818a53e003ce5a59c552d2f15c1b51f64cvboxsync /** @todo quick hack to work around problems in the async I/O
c8cedf818a53e003ce5a59c552d2f15c1b51f64cvboxsync * implementation (rw semaphore thread ownership problem)
c8cedf818a53e003ce5a59c552d2f15c1b51f64cvboxsync * while a merge is running. Remove once this is fixed. */
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.cbSize = sizeof(VDINTERFACEIO);
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.enmInterface = VDINTERFACETYPE_IO;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnClose = drvvdAsyncIOClose;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnGetSize = drvvdAsyncIOGetSize;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnSetSize = drvvdAsyncIOSetSize;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnReadSync = drvvdAsyncIOReadSync;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnWriteSync = drvvdAsyncIOWriteSync;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnFlushSync = drvvdAsyncIOFlushSync;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnReadAsync = drvvdAsyncIOReadAsync;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnWriteAsync = drvvdAsyncIOWriteAsync;
037bb2a3e9d81a494a15e37911a8e5cdc565fb5dvboxsync pThis->VDIIOCallbacks.pfnFlushAsync = drvvdAsyncIOFlushAsync;
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync#else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in"));
27b178e99b06a68ef52353b15bc647674d2006bcvboxsync#endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = RTSemFastMutexCreate(&pThis->MergeCompleteMutex);
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.cbSize = sizeof(VDINTERFACETHREADSYNC);
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.enmInterface = VDINTERFACETYPE_THREADSYNC;
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.pfnStartRead = drvvdThreadStartRead;
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.pfnFinishRead = drvvdThreadFinishRead;
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.pfnStartWrite = drvvdThreadStartWrite;
16a9adc14900ca18e6909679a579f6833425e030vboxsync pThis->VDIThreadSyncCallbacks.pfnFinishWrite = drvvdThreadFinishWrite;
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = VDInterfaceAdd(&pThis->VDIThreadSync, "DrvVD_ThreadSync", VDINTERFACETYPE_THREADSYNC,
16a9adc14900ca18e6909679a579f6833425e030vboxsync &pThis->VDIThreadSyncCallbacks, pThis, &pThis->pVDIfsDisk);
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Failed to create semaphores for \"MergePending\""));
ee00a0b29854e7f513198772bccb6650f6dd2184vboxsync rc = VDCreate(pThis->pVDIfsDisk, enmType, &pThis->pDisk);
a3369a746b56a8966dd78619f4d191c9662f400dvboxsync /* Error message is already set correctly. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync unsigned iImageIdx = 0;
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /* Allocate per-image data. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Read the image configuration.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "Path", &pszName);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync N_("DrvVD: Configuration error: Querying \"Path\" as string failed"));
0ccdfa1953b2f57311fb9ec01a2baf5e1e366f5avboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "Format", &pszFormat);
d9d5fbda1b8f7a6f7fae555db60d0e636fd03af8vboxsync N_("DrvVD: Configuration error: Querying \"Format\" as string failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "MergeSource", &fMergeSource, false);
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Querying \"MergeSource\" as boolean failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Multiple \"MergeSource\" occurrences"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "MergeTarget", &fMergeTarget, false);
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Querying \"MergeTarget\" as boolean failed"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Multiple \"MergeTarget\" occurrences"));
670b83d458bceb92123155b5b47a39b9d24e3266vboxsync PCFGMNODE pCfgVDConfig = CFGMR3GetChild(pCurNode, "VDConfig");
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync rc = VDInterfaceAdd(&pImage->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
670b83d458bceb92123155b5b47a39b9d24e3266vboxsync &pThis->VDIConfigCallbacks, pCfgVDConfig, &pImage->pVDIfsImage);
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /* Unconditionally insert the TCPNET interface, don't bother to check
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * if an image really needs it. Will be ignored. Since the TCPNET
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * interface is per image we could make this more flexible in the
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * future if we want to. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync rc = VDInterfaceAdd(&pImage->VDITcpNet, "DrvVD_TCPNET",
c0a370e600bb60153a269fb32b5f709347c35768vboxsync VDINTERFACETYPE_TCPNET, &pThis->VDITcpNetCallbacks,
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /* Insert the custom I/O interface only if we're told to use new IO.
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * Since the I/O interface is per image we could make this more
c0a370e600bb60153a269fb32b5f709347c35768vboxsync * flexible in the future if we want to. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync rc = VDInterfaceAdd(&pImage->VDIIO, "DrvVD_IO", VDINTERFACETYPE_IO,
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Open the image.
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync if (fReadOnly || pThis->fTempReadOnly || iLevel != 0)
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync /* Try to open backend in async I/O mode first. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write"));
6b223679d40f5e57e55e867e806a9f194e2cde12vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_VD_IMAGE_READ_ONLY, RT_SRC_POS,
f35c44bfc9e1036d0cb376fb144cdae416c7ef3avboxsync N_("Failed to open image '%s' for writing due to wrong permissions"),
6b223679d40f5e57e55e867e806a9f194e2cde12vboxsync N_("Failed to open image '%s' in %s mode rc=%Rrc"), pszName,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync (uOpenFlags & VD_OPEN_FLAGS_READONLY) ? "read-only" : "read-write", rc);
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync /* Open the cache image if set. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync /* Insert the custom I/O interface only if we're told to use new IO.
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync * Since the I/O interface is per image we could make this more
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync * flexible in the future if we want to. */
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync rc = VDInterfaceAdd(&pThis->VDIIOCache, "DrvVD_IO", VDINTERFACETYPE_IO,
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync rc = VDCacheOpen(pThis->pDisk, pszCacheFormat, pszCachePath, VD_OPEN_FLAGS_NORMAL, pThis->pVDIfsCache);
681fd85cc7cd49e9cf66a917d6ae9ff36eb7d9e9vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, rc, N_("DrvVD: Could not open cache image"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
16a9adc14900ca18e6909679a579f6833425e030vboxsync N_("DrvVD: Configuration error: Inconsistent image merge data"));
009d45aa55691312278d41edb20154dc208d9cd8vboxsync /* Create the block cache if enabled. */
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * We need a unique ID for the block cache (to identify the owner of data
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * blocks in a saved state). UUIDs are not really suitable because
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * there are image formats which don't support them. Furthermore it is
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * possible that a new diff image was attached after a saved state
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * which changes the UUID.
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * However the device "name + device instance + LUN" triple the disk is
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync * attached to is always constant for saved states.
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync rc = pThis->pDrvMediaPort->pfnQueryDeviceLocation(pThis->pDrvMediaPort, &pcszController,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync N_("DrvVD: Configuration error: Could not query device data"));
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync int cbStr = RTStrAPrintf(&pszId, "%s-%d-%d", pcszController, iInstance, iLUN);
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync rc = PDMDrvHlpBlkCacheRetain(pDrvIns, &pThis->pBlkCache,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync rc = PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_DRIVER_INVALID_PROPERTIES,
cab115cfa31c584def7069312a1e23c3fc88533bvboxsync N_("DrvVD: Out of memory when creating block cache"));
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Register a load-done callback so we can undo TempReadOnly config before
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * we get to drvvdResume. Autoamtically deregistered upon destruction.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync rc = PDMDrvHlpSSMRegisterEx(pDrvIns, 0 /* version */, 0 /* cbGuess */,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync NULL /*pfnDonePrep*/, NULL /*pfnLoadExec*/, drvvdLoadDone);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync /* Setup the boot acceleration stuff if enabled. */
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync pThis->cbDisk = VDGetSize(pThis->pDisk, VD_LAST_IMAGE);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync pThis->pbData = (uint8_t *)RTMemAllocZ(pThis->cbBootAccelBuffer);
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync LogRel(("VD: Boot acceleration, out of memory, disabled\n"));
4a23807f02e9920d92c8449bd93d84501add460avboxsync /* drvvdDestruct does the rest. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * VBox disk container media driver registration record.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* u32Version */
5b465a7c1237993faf8bb50120d247f3f0319adavboxsync /* szName */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szRCMod */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* szR0Mod */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pszDescription */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync "Generic VBox disk media driver.",
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* fFlags */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* fClass. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* cMaxInstances */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* cbInstance */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnConstruct */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnDestruct */
ad77e3ec3cde24263bc7537575f5cae442bee3b1vboxsync /* pfnRelocate */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnIOCtl */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnPowerOn */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnReset */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnSuspend */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnResume */
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnAttach */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /* pfnDetach */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /* pfnPowerOff */
cba6719bd64ec749967bbe931230452664109857vboxsync /* pfnSoftReset */
cba6719bd64ec749967bbe931230452664109857vboxsync /* u32EndVersion */