DrvVD.cpp revision 369a8817da53dbd5ea6ac360ca0376dba003cde4
77b1a2d8b5dbe2c0b5200794914239fee3c8ee5dvboxsync * DrvVD - Generic VBox disk media driver.
d1aab951b0bd1de1a8a51daca46fce06daaed8d7vboxsync * Copyright (C) 2006-2010 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * additional information or have any questions.
cd6f71bc352f550074f1ba2c830a2cf2f0b3dd46vboxsync/*******************************************************************************
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync* Header files *
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync*******************************************************************************/
47579c4cc64e7dff9b4de48841a2c4df3b96ab38vboxsync/* All lwip header files are not C++ safe. So hack around this. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync#endif /* VBOX_WITH_INIP */
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync/* Small hack to get at lwIP initialized status */
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsyncextern bool DevINIPConfigured(void);
efff36b306e370346025647a158689021df2e1d1vboxsync#endif /* VBOX_WITH_INIP */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
efff36b306e370346025647a158689021df2e1d1vboxsync* Defined types, constants and macros *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
efff36b306e370346025647a158689021df2e1d1vboxsync/** 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. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync ( 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. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** Common structure for the configuration information interface. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * 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;
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Callback routine */
7766bf675357fd940d8c49e69a5d72dc6eaa6be4vboxsync /** Pointer to the optional thread synchronization interface of the disk. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Pointer to the optional thread synchronization callbacks of the disk. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PVDINTERFACETHREADSYNC pInterfaceThreadSyncCallbacks;
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 /** Pointer to the driver instance. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Flag whether suspend has changed image open mode to read only. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Flag whether to use the runtime (true) or startup error facility. */
21029597fc4b76d0db0c9542daee201447281781vboxsync /** Pointer to list of VD interfaces. Per-disk. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Common structure for the supported error interface. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** Callback table for error interface. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** Common structure for the supported TCP network stack interface. */
c0a370e600bb60153a269fb32b5f709347c35768vboxsync /** Callback table for TCP network stack interface. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** Common structure for the supported async I/O interface. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Callback table for async I/O interface. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Callback table for the configuration information interface. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Flag whether opened disk suppports async I/O operations. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** The async media interface. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** The async media port interface above. */
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync /** Pointer to the list of data we need to keep per image. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync/*******************************************************************************
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync* Internal Functions *
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync*******************************************************************************/
63c12491acc2b8b95c8ac454f1c48b98eec8f7d8vboxsync * Internal: allocate new image descriptor and put it in the list
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync PVBOXIMAGE pImage = (PVBOXIMAGE)RTMemAllocZ(sizeof(VBOXIMAGE));
e4f367251aede667a6de69baa54ef9eb5f150871vboxsync * Internal: free the list of images descriptors.
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync * Undo the temporary read-only status of the image.
eeebcc1f7aedfdbcaf7c4dae90ad932d5d9c03c8vboxsync * @returns VBox status code.
eeebcc1f7aedfdbcaf7c4dae90ad932d5d9c03c8vboxsync * @param pThis The driver instance data.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync/*******************************************************************************
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync* Error reporting callback *
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync*******************************************************************************/
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsyncstatic void drvvdErrorCallback(void *pvUser, int rc, RT_SRC_POS_DECL,
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /* We must not pass VMSETRTERR_FLAGS_FATAL as it could lead to a
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * deadlock: We are probably executed in a thread context != EMT
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * and the EM thread would wait until every thread is suspended
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * but we would wait for the EM thread ... */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PDMDrvHlpVMSetRuntimeErrorV(pDrvIns, /* fFlags=*/ 0, "DrvVD", pszFormat, va);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PDMDrvHlpVMSetErrorV(pDrvIns, rc, RT_SRC_POS_ARGS, pszFormat, va);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync/*******************************************************************************
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync* VD Async I/O interface implementation *
16a9adc14900ca18e6909679a579f6833425e030vboxsync*******************************************************************************/
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(void) drvvdAsyncTaskCompleted(PPDMDRVINS pDrvIns, void *pvTemplateUser, void *pvUser)
16a9adc14900ca18e6909679a579f6833425e030vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
16a9adc14900ca18e6909679a579f6833425e030vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pvTemplateUser;
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = pStorageBackend->pfnCompleted(pvUser, &pvCallerUser);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync /* If thread synchronization is active, then signal the end of the
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * this disk read/write operation. */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync /** @todo provide a way to determine the type of task (read/write)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * which was completed, see also VBoxHDD.cpp. */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync if (RT_UNLIKELY(pStorageBackend->pInterfaceThreadSyncCallbacks))
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync int rc2 = pStorageBackend->pInterfaceThreadSyncCallbacks->pfnFinishWrite(pStorageBackend->pInterfaceThreadSync->pvUser);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync rc = pThis->pDrvMediaAsyncPort->pfnTransferCompleteNotify(pThis->pDrvMediaAsyncPort, pvCallerUser);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync AssertMsg(rc == VERR_VD_ASYNC_IO_IN_PROGRESS, ("Invalid return code from disk backend rc=%Rrc\n", rc));
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOOpen(void *pvUser, const char *pszLocation,
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)RTMemAllocZ(sizeof(DRVVDSTORAGEBACKEND));
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync pStorageBackend->pInterfaceThreadSyncCallbacks = NULL;
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync pStorageBackend->pInterfaceThreadSync = VDInterfaceGet(pVDIfsDisk, VDINTERFACETYPE_THREADSYNC);
a9d49c8f2b28a72e6a4db86eee91e4569290157bvboxsync if (RT_UNLIKELY(pStorageBackend->pInterfaceThreadSync))
a9d49c8f2b28a72e6a4db86eee91e4569290157bvboxsync pStorageBackend->pInterfaceThreadSyncCallbacks = VDGetInterfaceThreadSync(pStorageBackend->pInterfaceThreadSync);
9496f2d398b49813176939d7a339ae513d5175efvboxsync rc = PDMDrvHlpPDMAsyncCompletionTemplateCreate(pDrvVD->pDrvIns, &pStorageBackend->pTemplate,
9496f2d398b49813176939d7a339ae513d5175efvboxsync drvvdAsyncTaskCompleted, pStorageBackend, "AsyncTaskCompleted");
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync rc = PDMR3AsyncCompletionEpCreateForFile(&pStorageBackend->pEndpoint, pszLocation,
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync uOpenFlags & VD_INTERFACEASYNCIO_OPEN_FLAGS_READONLY
22ec733a5e041fcdfe02fce2eafc9faf8b0077ddvboxsync ? PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_CACHING
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
d5ea45cc92d7f1d3ade8189944531f665bfe8ed5vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOClose(void *pvUser, void *pStorage)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDMR3AsyncCompletionEpClose(pStorageBackend->pEndpoint);
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync PDMR3AsyncCompletionTemplateDestroy(pStorageBackend->pTemplate);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOReadSync(void *pvUser, void *pStorage, uint64_t uOffset,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbRead, NULL, &pTask);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
61b5982fad4660d0fe3dd6ceba9eda85eb32f7e8vboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOWriteSync(void *pvUser, void *pStorage, uint64_t uOffset,
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync size_t cbWrite, const void *pvBuf, size_t *pcbWritten)
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
b5ad839a3757b305d4e98d7264da2b53c9cd27f0vboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, &DataSeg, 1, cbWrite, NULL, &pTask);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOFlushSync(void *pvUser, void *pStorage)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
9496f2d398b49813176939d7a339ae513d5175efvboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, true);
1189c7dde5d7f6c26f338ced3d40fc830b822e68vboxsync int rc = PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, NULL, &pTask);
a0a5ab4e085a7ee5b95bdfae04cec7de95792c3cvboxsync rc = RTSemEventWait(pStorageBackend->EventSem, RT_INDEFINITE_WAIT);
9496f2d398b49813176939d7a339ae513d5175efvboxsync ASMAtomicXchgBool(&pStorageBackend->fSyncIoPending, false);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOReadAsync(void *pvUser, void *pStorage, uint64_t uOffset,
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync return PDMR3AsyncCompletionEpRead(pStorageBackend->pEndpoint, uOffset, paSegments, cSegments, cbRead,
7766bf675357fd940d8c49e69a5d72dc6eaa6be4vboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOWriteAsync(void *pvUser, void *pStorage, uint64_t uOffset,
16a9adc14900ca18e6909679a579f6833425e030vboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync return PDMR3AsyncCompletionEpWrite(pStorageBackend->pEndpoint, uOffset, paSegments, cSegments, cbWrite,
a0a5ab4e085a7ee5b95bdfae04cec7de95792c3cvboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOFlushAsync(void *pvUser, void *pStorage,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync return PDMR3AsyncCompletionEpFlush(pStorageBackend->pEndpoint, pvCompletion,
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOGetSize(void *pvUser, void *pStorage, uint64_t *pcbSize)
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync return PDMR3AsyncCompletionEpGetSize(pStorageBackend->pEndpoint, pcbSize);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvvdAsyncIOSetSize(void *pvUser, void *pStorage, uint64_t cbSize)
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDRVVDSTORAGEBACKEND pStorageBackend = (PDRVVDSTORAGEBACKEND)pStorage;
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = PDMR3AsyncCompletionEpSetSize(pStorageBackend->pEndpoint, cbSize);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#endif /* VBOX_WITH_PDM_ASYNC_COMPLETION */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/*******************************************************************************
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync* VD Configuration interface implementation *
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync*******************************************************************************/
9496f2d398b49813176939d7a339ae513d5175efvboxsyncstatic bool drvvdCfgAreKeysValid(void *pvUser, const char *pszzValid)
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync return CFGMR3AreValuesValid((PCFGMNODE)pvUser, pszzValid);
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsyncstatic int drvvdCfgQuerySize(void *pvUser, const char *pszName, size_t *pcb)
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync return CFGMR3QuerySize((PCFGMNODE)pvUser, pszName, pcb);
9496f2d398b49813176939d7a339ae513d5175efvboxsyncstatic int drvvdCfgQuery(void *pvUser, const char *pszName, char *pszString, size_t cchString)
9496f2d398b49813176939d7a339ae513d5175efvboxsync return CFGMR3QueryString((PCFGMNODE)pvUser, pszName, pszString, cchString);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/*******************************************************************************
9496f2d398b49813176939d7a339ae513d5175efvboxsync* VD TCP network stack interface implementation - INIP case *
16a9adc14900ca18e6909679a579f6833425e030vboxsync*******************************************************************************/
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc VDINTERFACETCPNET::pfnClientConnect */
a0a5ab4e085a7ee5b95bdfae04cec7de95792c3cvboxsyncstatic DECLCALLBACK(int) drvvdINIPClientConnect(const char *pszAddress, uint32_t uPort, PRTSOCKET pSock)
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync /* First check whether lwIP is set up in this VM instance. */
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync /* Resolve hostname. As there is no standard resolver for lwIP yet,
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * just accept numeric IP addresses for now. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync LogRelFunc(("cannot resolve IP %s\n", pszAddress));
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync /* Create socket and connect. */
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync RTSOCKET Sock = lwip_socket(PF_INET, SOCK_STREAM, 0);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync if (!lwip_connect(Sock, (struct sockaddr *)&InAddr, sizeof(InAddr)))
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync rc = VERR_NET_CONNECTION_REFUSED; /* @todo real solution needed */
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync rc = VERR_NET_CONNECTION_REFUSED; /* @todo real solution needed */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/** @copydoc VDINTERFACETCPNET::pfnClientClose */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(int) drvvdINIPClientClose(RTSOCKET Sock)
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync return VINF_SUCCESS; /** @todo real solution needed */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/** @copydoc VDINTERFACETCPNET::pfnSelectOne */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(int) drvvdINIPSelectOne(RTSOCKET Sock, RTMSINTERVAL cMillies)
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync rc = lwip_select(Sock + 1, &fdsetR, NULL, &fdsetE, NULL);
16a9adc14900ca18e6909679a579f6833425e030vboxsync rc = lwip_select(Sock + 1, &fdsetR, NULL, &fdsetE, &timeout);
16a9adc14900ca18e6909679a579f6833425e030vboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution needed */
16a9adc14900ca18e6909679a579f6833425e030vboxsync/** @copydoc VDINTERFACETCPNET::pfnRead */
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvvdINIPRead(RTSOCKET Sock, void *pvBuffer, size_t cbBuffer, size_t *pcbRead)
16a9adc14900ca18e6909679a579f6833425e030vboxsync /* Do params checking */
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Read loop.
16a9adc14900ca18e6909679a579f6833425e030vboxsync * If pcbRead is NULL we have to fill the entire buffer!
16a9adc14900ca18e6909679a579f6833425e030vboxsync /** @todo this clipping here is just in case (the send function
16a9adc14900ca18e6909679a579f6833425e030vboxsync * needed it, so I added it here, too). Didn't investigate if this
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync * really has issues. Better be safe than sorry. */
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync ssize_t cbBytesRead = lwip_recv(Sock, (char *)pvBuffer + cbRead,
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution */
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution */
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync /* return partial data */
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync /* read more? */
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync/** @copydoc VDINTERFACETCPNET::pfnWrite */
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsyncstatic DECLCALLBACK(int) drvvdINIPWrite(RTSOCKET Sock, const void *pvBuffer, size_t cbBuffer)
1741b757f7a570a7e6d48db46c3f4cd50f2ee296vboxsync /** @todo lwip send only supports up to 65535 bytes in a single
1741b757f7a570a7e6d48db46c3f4cd50f2ee296vboxsync * send (stupid limitation buried in the code), so make sure we
1741b757f7a570a7e6d48db46c3f4cd50f2ee296vboxsync * don't get any wraparounds. This should be moved to DevINIP
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync * stack interface once that's implemented. */
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync ssize_t cbWritten = lwip_send(Sock, (void *)pvBuffer,
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync return VERR_NET_CONNECTION_REFUSED; /** @todo real solution needed */
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync AssertMsg(cbBuffer >= (size_t)cbWritten, ("Wrote more than we requested!!! cbWritten=%d cbBuffer=%d\n",
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsync/** @copydoc VDINTERFACETCPNET::pfnFlush */
c5abe3ea9c7ac6dec34f42af30612534bea951ffvboxsyncstatic DECLCALLBACK(int) drvvdINIPFlush(RTSOCKET Sock)
d1aab951b0bd1de1a8a51daca46fce06daaed8d7vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetLocalAddress */
d1aab951b0bd1de1a8a51daca46fce06daaed8d7vboxsyncstatic DECLCALLBACK(int) drvvdINIPGetLocalAddress(RTSOCKET Sock, PRTNETADDR pAddr)
d1aab951b0bd1de1a8a51daca46fce06daaed8d7vboxsync * Convert the address.
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync/** @copydoc VDINTERFACETCPNET::pfnGetPeerAddress */
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsyncstatic DECLCALLBACK(int) drvvdINIPGetPeerAddress(RTSOCKET Sock, PRTNETADDR pAddr)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Convert the address.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#endif /* VBOX_WITH_INIP */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/*******************************************************************************
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync* Media interface methods *
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync*******************************************************************************/
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnRead */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdRead(PPDMIMEDIA pInterface,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogFlow(("%s: off=%#llx pvBuf=%p cbRead=%d\n", __FUNCTION__,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync Log2(("%s: off=%#llx pvBuf=%p cbRead=%d %.*Rhxd\n", __FUNCTION__,
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync/** @copydoc PDMIMEDIA::pfnWrite */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdWrite(PPDMIMEDIA pInterface,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("%s: off=%#llx pvBuf=%p cbWrite=%d\n", __FUNCTION__,
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync Log2(("%s: off=%#llx pvBuf=%p cbWrite=%d %.*Rhxd\n", __FUNCTION__,
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync int rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnFlush */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdFlush(PPDMIMEDIA pInterface)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync/** @copydoc PDMIMEDIA::pfnGetSize */
1e9e76e4273dcc2e3d560a0f3605c46f0013eb7bvboxsyncstatic DECLCALLBACK(uint64_t) drvvdGetSize(PPDMIMEDIA pInterface)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync uint64_t cb = VDGetSize(pThis->pDisk, VD_LAST_IMAGE);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("%s: returns %#llx (%llu)\n", __FUNCTION__, cb, cb));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnIsReadOnly */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(bool) drvvdIsReadOnly(PPDMIMEDIA pInterface)
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync/** @copydoc PDMIMEDIA::pfnBiosGetPCHSGeometry */
30c39307775310ba50de9d9b74f1ea9e12524102vboxsyncstatic DECLCALLBACK(int) drvvdBiosGetPCHSGeometry(PPDMIMEDIA pInterface,
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync int rc = VDGetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync Log(("%s: geometry not available.\n", __FUNCTION__));
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync LogFlow(("%s: returns %Rrc (CHS=%d/%d/%d)\n", __FUNCTION__,
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync rc, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc PDMIMEDIA::pfnBiosSetPCHSGeometry */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdBiosSetPCHSGeometry(PPDMIMEDIA pInterface,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync int rc = VDSetPCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pPCHSGeometry);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnBiosGetLCHSGeometry */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdBiosGetLCHSGeometry(PPDMIMEDIA pInterface,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync int rc = VDGetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync Log(("%s: geometry not available.\n", __FUNCTION__));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogFlow(("%s: returns %Rrc (CHS=%d/%d/%d)\n", __FUNCTION__,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnBiosSetLCHSGeometry */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdBiosSetLCHSGeometry(PPDMIMEDIA pInterface,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync int rc = VDSetLCHSGeometry(pThis->pDisk, VD_LAST_IMAGE, pLCHSGeometry);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMEDIA::pfnGetUuid */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdGetUuid(PPDMIMEDIA pInterface, PRTUUID pUuid)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("%s: returns %Rrc ({%RTuuid})\n", __FUNCTION__, rc, pUuid));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/*******************************************************************************
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync* Async Media interface methods *
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdStartRead(PPDMIMEDIAASYNC pInterface, uint64_t uOffset,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbRead=%d\n pvUser=%#p", __FUNCTION__,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync int rc = VDAsyncRead(pThis->pDisk, uOffset, cbRead, paSeg, cSeg, pvUser);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdStartWrite(PPDMIMEDIAASYNC pInterface, uint64_t uOffset,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("%s: uOffset=%#llx paSeg=%#p cSeg=%u cbWrite=%d\n pvUser=%#p", __FUNCTION__,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync int rc = VDAsyncWrite(pThis->pDisk, uOffset, cbWrite, paSeg, cSeg, pvUser);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/*******************************************************************************
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync* Async transport port interface methods *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvvdTasksCompleteNotify(PPDMDRVINS pDrvIns, void *pvUser)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/*******************************************************************************
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync* Base interface methods *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(void *) drvvdQueryInterface(PPDMIBASE pInterface, const char *pszIID)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PPDMDRVINS pDrvIns = PDMIBASE_2_DRVINS(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIA, &pThis->IMedia);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNC, pThis->fAsyncIOSupported ? &pThis->IMediaAsync : NULL);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/*******************************************************************************
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync* Saved state notification methods *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Load done callback for re-opening the image writable during teleportation.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * This is called both for successful and failed load runs, we only care about
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * successfull ones.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @returns VBox status code.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @param pDrvIns The driver instance.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @param pSSM The saved state handle.
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsyncstatic DECLCALLBACK(int) drvvdLoadDone(PPDMDRVINS pDrvIns, PSSMHANDLE pSSM)
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync /* Drop out if we don't have any work to do or if it's a failed load. */
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync if (RT_FAILURE(rc)) /** @todo does the bugger set any errors? */
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync/*******************************************************************************
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync* Driver methods *
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync*******************************************************************************/
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(void) drvvdPowerOff(PPDMDRVINS pDrvIns)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * We must close the disk here to ensure that
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * the backend closes all files before the
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync * async transport driver is destructed.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * VM resume notification that we use to undo what the temporary read-only image
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * mode set by drvvdSuspend.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Also switch to runtime error mode if we're resuming after a state load
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * without having been powered on first.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @param pDrvIns The driver instance data.
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * @todo The VMSetError vs VMSetRuntimeError mess must be fixed elsewhere,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * we're making assumptions about Main behavior here!
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(void) drvvdResume(PPDMDRVINS pDrvIns)
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * The VM is being suspended, temporarily change to read-only image mode.
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * This is important for several reasons:
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * -# It makes sure that there are no pending writes to the image. Most
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * backends implements this by closing and reopening the image in read-only
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * -# It allows Main to read the images during snapshotting without having
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * to account for concurrent writes.
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync * -# This is essential for making teleportation targets sharing images work
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync * right. Both with regards to caching and with regards to file sharing
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync * locks (RTFILE_O_DENY_*). (See also drvvdLoadDone.)
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync * @param pDrvIns The driver instance data.
30c39307775310ba50de9d9b74f1ea9e12524102vboxsyncstatic DECLCALLBACK(void) drvvdSuspend(PPDMDRVINS pDrvIns)
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync int rc = VDGetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, &uOpenFlags);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = VDSetOpenFlags(pThis->pDisk, VD_LAST_IMAGE, uOpenFlags);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * VM PowerOn notification for undoing the TempReadOnly config option and
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * changing to runtime error mode.
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * @param pDrvIns The driver instance data.
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * @todo The VMSetError vs VMSetRuntimeError mess must be fixed elsewhere,
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync * we're making assumptions about Main behavior here!
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsyncstatic DECLCALLBACK(void) drvvdPowerOn(PPDMDRVINS pDrvIns)
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync * @copydoc FNPDMDRVDESTRUCT
30c39307775310ba50de9d9b74f1ea9e12524102vboxsyncstatic DECLCALLBACK(void) drvvdDestruct(PPDMDRVINS pDrvIns)
30c39307775310ba50de9d9b74f1ea9e12524102vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Construct a VBox disk media driver instance.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * @copydoc FNPDMDRVCONSTRUCT
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvvdConstruct(PPDMDRVINS pDrvIns,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK);
efff36b306e370346025647a158689021df2e1d1vboxsync char *pszName = NULL; /**< The path of the disk image file. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync char *pszFormat = NULL; /**< The format backed to use for this image. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync bool fReadOnly; /**< True if the media is read-only. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync bool fHonorZeroWrites; /**< True if zero blocks should be written. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Init the static parts.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pDrvIns->IBase.pfnQueryInterface = drvvdQueryInterface;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* IMedia */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IMedia.pfnBiosGetPCHSGeometry = drvvdBiosGetPCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IMedia.pfnBiosSetPCHSGeometry = drvvdBiosSetPCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IMedia.pfnBiosGetLCHSGeometry = drvvdBiosGetLCHSGeometry;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pThis->IMedia.pfnBiosSetLCHSGeometry = drvvdBiosSetLCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* IMediaAsync */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IMediaAsync.pfnStartWrite = drvvdStartWrite;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Initialize supported VD interfaces. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIErrorCallbacks.cbSize = sizeof(VDINTERFACEERROR);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIErrorCallbacks.enmInterface = VDINTERFACETYPE_ERROR;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIErrorCallbacks.pfnError = drvvdErrorCallback;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = VDInterfaceAdd(&pThis->VDIError, "DrvVD_VDIError", VDINTERFACETYPE_ERROR,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync &pThis->VDIErrorCallbacks, pDrvIns, &pThis->pVDIfsDisk);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* This is just prepared here, the actual interface is per-image, so it's
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * added later. No need to have separate callback tables. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIConfigCallbacks.cbSize = sizeof(VDINTERFACECONFIG);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIConfigCallbacks.enmInterface = VDINTERFACETYPE_CONFIG;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIConfigCallbacks.pfnAreKeysValid = drvvdCfgAreKeysValid;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIConfigCallbacks.pfnQuerySize = drvvdCfgQuerySize;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIConfigCallbacks.pfnQuery = drvvdCfgQuery;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* List of images is empty now. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Try to attach async media port interface above.*/
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->pDrvMediaAsyncPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMEDIAASYNCPORT);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Validate configuration and find all parent images.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * It's sort of up side down from the image dependency tree.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync bool fHostIP = false;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync bool fUseNewIo = false;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync unsigned iLevel = 0;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Toplevel configuration additionally contains the global image
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * open flags. Some might be converted to per-image flags later. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync "Format\0Path\0"
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync "ReadOnly\0TempReadOnly\0HonorZeroWrites\0"
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync "HostIPStack\0UseNewIo\0");
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* All other image configurations only contain image name and
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * the format information. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync fValid = CFGMR3AreValuesValid(pCurNode, "Format\0Path\0");
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync RT_SRC_POS, N_("DrvVD: Configuration error: keys incorrect at level %d"), iLevel);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "HostIPStack", &fHostIP, true);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"HostIPStack\" as boolean failed"));
b0b15690f00527424b2d5fb88456d747252322f7vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "HonorZeroWrites", &fHonorZeroWrites, false);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"HonorZeroWrites\" as boolean failed"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "ReadOnly", &fReadOnly, false);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"ReadOnly\" as boolean failed"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "TempReadOnly", &pThis->fTempReadOnly, false);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"TempReadOnly\" as boolean failed"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Both \"ReadOnly\" and \"TempReadOnly\" are set"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCurNode, "UseNewIo", &fUseNewIo, false);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync N_("DrvVD: Configuration error: Querying \"UseNewIo\" as boolean failed"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PCFGMNODE pParent = CFGMR3GetChild(pCurNode, "Parent");
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Open the images.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* First of all figure out what kind of TCP networking stack interface
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * to use. This is done unconditionally, as backends which don't need
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * it will just ignore it. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.cbSize = sizeof(VDINTERFACETCPNET);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.enmInterface = VDINTERFACETYPE_TCPNET;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientConnect = RTTcpClientConnect;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientClose = RTTcpClientClose;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSelectOne = RTTcpSelectOne;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetLocalAddress = RTTcpGetLocalAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetPeerAddress = RTTcpGetPeerAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync RT_SRC_POS, N_("DrvVD: Configuration error: TCP over Internal Networking not compiled in"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#else /* VBOX_WITH_INIP */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.cbSize = sizeof(VDINTERFACETCPNET);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.enmInterface = VDINTERFACETYPE_TCPNET;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientConnect = drvvdINIPClientConnect;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnClientClose = drvvdINIPClientClose;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnSelectOne = drvvdINIPSelectOne;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnWrite = drvvdINIPWrite;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnFlush = drvvdINIPFlush;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetLocalAddress = drvvdINIPGetLocalAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDITcpNetCallbacks.pfnGetPeerAddress = drvvdINIPGetPeerAddress;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#endif /* VBOX_WITH_INIP */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = VDInterfaceAdd(&pThis->VDITcpNet, "DrvVD_INIP",
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.cbSize = sizeof(VDINTERFACEASYNCIO);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.enmInterface = VDINTERFACETYPE_ASYNCIO;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnOpen = drvvdAsyncIOOpen;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnClose = drvvdAsyncIOClose;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnGetSize = drvvdAsyncIOGetSize;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnSetSize = drvvdAsyncIOSetSize;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnReadSync = drvvdAsyncIOReadSync;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnWriteSync = drvvdAsyncIOWriteSync;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnFlushSync = drvvdAsyncIOFlushSync;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnReadAsync = drvvdAsyncIOReadAsync;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->VDIAsyncIOCallbacks.pfnWriteAsync = drvvdAsyncIOWriteAsync;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync pThis->VDIAsyncIOCallbacks.pfnFlushAsync = drvvdAsyncIOFlushAsync;
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = VDInterfaceAdd(&pThis->VDIAsyncIO, "DrvVD_AsyncIO", VDINTERFACETYPE_ASYNCIO,
51a01524909c95ee04b636218b6a89b29fb81825vboxsync &pThis->VDIAsyncIOCallbacks, pThis, &pThis->pVDIfsDisk);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync#else /* !VBOX_WITH_PDM_ASYNC_COMPLETION */
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_DRVINS_UNKNOWN_CFG_VALUES,
51a01524909c95ee04b636218b6a89b29fb81825vboxsync RT_SRC_POS, N_("DrvVD: Configuration error: Async Completion Framework not compiled in"));
51a01524909c95ee04b636218b6a89b29fb81825vboxsync#endif /* !VBOX_WITH_PDM_ASYNC_COMPLETION */
51a01524909c95ee04b636218b6a89b29fb81825vboxsync /** @todo implement and set up the thread synchronization interface
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * if enabled by some CFGM key. If this is enabled then there also
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * needs to be a way for the console object to query the pDisk pointer
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * (so that it can perform the merge in parallel), or alternatively
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * some code needs to be added here which does the merge. The latter
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * might be preferred, as a running merge must block the destruction
51a01524909c95ee04b636218b6a89b29fb81825vboxsync * of the disk, or things will go really wrong. */
51a01524909c95ee04b636218b6a89b29fb81825vboxsync /* Error message is already set correctly. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Allocate per-image data. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Read the image configuration.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "Path", &pszName);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"Path\" as string failed"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryStringAlloc(pCurNode, "Format", &pszFormat);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("DrvVD: Configuration error: Querying \"Format\" as string failed"));
b0b15690f00527424b2d5fb88456d747252322f7vboxsync PCFGMNODE pCfgVDConfig = CFGMR3GetChild(pCurNode, "VDConfig");
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = VDInterfaceAdd(&pImage->VDIConfig, "DrvVD_Config", VDINTERFACETYPE_CONFIG,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync &pThis->VDIConfigCallbacks, pCfgVDConfig, &pImage->pVDIfsImage);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Open the image.
217fa436516d137a409bb493cb7d350898f64666vboxsync if (fReadOnly || pThis->fTempReadOnly || iLevel != 0)
51a01524909c95ee04b636218b6a89b29fb81825vboxsync /* Try to open backend in async I/O mode first. */
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage);
51a01524909c95ee04b636218b6a89b29fb81825vboxsync rc = VDOpen(pThis->pDisk, pszFormat, pszName, uOpenFlags, pImage->pVDIfsImage);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync Log(("%s: %d - Opened '%s' in %s mode\n", __FUNCTION__,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync VDIsReadOnly(pThis->pDisk) ? "read-only" : "read-write"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = PDMDrvHlpVMSetError(pDrvIns, VERR_VD_IMAGE_READ_ONLY, RT_SRC_POS,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync N_("Failed to open image '%s' for writing due to wrong permissions"),
51a01524909c95ee04b636218b6a89b29fb81825vboxsync N_("Failed to open image '%s' in %s mode rc=%Rrc"), pszName,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync (uOpenFlags & VD_OPEN_FLAGS_READONLY) ? "read-only" : "read-write", rc);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Register a load-done callback so we can undo TempReadOnly config before
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * we get to drvvdResume. Autoamtically deregistered upon destruction.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = PDMDrvHlpSSMRegisterEx(pDrvIns, 0 /* version */, 0 /* cbGuess */,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync NULL /*pfnLivePrep*/, NULL /*pfnLiveExec*/, NULL /*pfnLiveVote*/,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync NULL /*pfnSavePrep*/, NULL /*pfnSaveExec*/, NULL /*pfnSaveDone*/,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync NULL /*pfnDonePrep*/, NULL /*pfnLoadExec*/, drvvdLoadDone);
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* drvvdDestruct does the rest. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync * VBox disk container media driver registration record.
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* u32Version */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* szName */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* szRCMod */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* szR0Mod */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pszDescription */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync "Generic VBox disk media driver.",
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* fFlags */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* fClass. */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* cMaxInstances */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* cbInstance */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnConstruct */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnDestruct */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnRelocate */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnIOCtl */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnPowerOn */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnReset */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnSuspend */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnResume */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnAttach */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnDetach */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnPowerOff */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* pfnSoftReset */
b0b15690f00527424b2d5fb88456d747252322f7vboxsync /* u32EndVersion */