DrvBlock.cpp revision f8a01eb6a7c5030c08407dfc81ae474430f18c6b
77b1a2d8b5dbe2c0b5200794914239fee3c8ee5dvboxsync * VBox storage devices: Generic block 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*******************************************************************************/
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @def VBOX_PERIODIC_FLUSH
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Enable support for periodically flushing the VDI to disk. This may prove
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * useful for those nasty problems with the ultra-slow host filesystems.
a9f41cb889f53e8407561a6155052c441eb0fc5fvboxsync * If this is enabled, it can be configured via the CFGM key
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * "VBoxInternal/Devices/piix3ide/0/LUN#<x>/Config/FlushInterval". <x>
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * must be replaced with the correct LUN number of the disk that should
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * do the periodic flushes. The value of the key is the number of bytes
efff36b306e370346025647a158689021df2e1d1vboxsync * written between flushes. A value of 0 (the default) denotes no flushes. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @def VBOX_IGNORE_FLUSH
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Enable support for ignoring VDI flush requests. This can be useful for
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * filesystems that show bad guest IDE write performance (especially with
590bfe12ce22cd3716448fbb9f4dc51664bfe5e2vboxsync * Windows guests). NOTE that this does not disable the flushes caused by
efff36b306e370346025647a158689021df2e1d1vboxsync * the periodic flush cache feature above.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * If this feature is enabled, it can be configured via the CFGM key
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * "VBoxInternal/Devices/piix3ide/0/LUN#<x>/Config/IgnoreFlush". <x>
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * must be replaced with the correct LUN number of the disk that should
efff36b306e370346025647a158689021df2e1d1vboxsync * ignore flush requests. The value of the key is a boolean. The default
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * is to ignore flushes, i.e. true. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/*******************************************************************************
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync* Structures and Typedefs *
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync*******************************************************************************/
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * Block driver instance data.
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * @implements PDMIBLOCK
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * @implements PDMIBLOCKBIOS
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * @implements PDMIMOUNT
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * @implements PDMIMEDIAASYNCPORT
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync * @implements PDMIBLOCKASYNC
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsynctypedef struct DRVBLOCK
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Pointer driver instance. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Drive type. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Locked indicator. */
9496f2d398b49813176939d7a339ae513d5175efvboxsync /** Mountable indicator. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Visible to the BIOS. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** HACK: Configuration value for number of bytes written after which to flush. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** HACK: Current count for the number of bytes written since the last flush. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync#endif /* VBOX_PERIODIC_FLUSH */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** HACK: Disable flushes for this drive. */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /** Disable async flushes for this drive. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync#endif /* VBOX_IGNORE_FLUSH */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Pointer to the media driver below us.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * This is NULL if the media is not mounted. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Pointer to the block port interface above us. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Pointer to the mount notify interface above us. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Our block interface. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Our block interface. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Our mountable interface. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Pointer to the async media driver below us.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * This is NULL if the media is not mounted. */
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync /** Our media async port. */
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync /** Pointer to the async block port interface above us. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync /** Our async block interface. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync /** Uuid of the drive. */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** BIOS PCHS Geometry. */
ee4d840f54fd2dcea8a73b1b86d5ec0db370b05dvboxsync /** BIOS LCHS Geometry. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/* -=-=-=-=- IBlock -=-=-=-=- */
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** Makes a PDRVBLOCK out of a PPDMIBLOCK. */
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync#define PDMIBLOCK_2_DRVBLOCK(pInterface) ( (PDRVBLOCK)((uintptr_t)pInterface - RT_OFFSETOF(DRVBLOCK, IBlock)) )
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync/** @copydoc PDMIBLOCK::pfnRead */
9496f2d398b49813176939d7a339ae513d5175efvboxsyncstatic DECLCALLBACK(int) drvblockRead(PPDMIBLOCK pInterface, uint64_t off, void *pvBuf, size_t cbRead)
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * Check the state.
9496f2d398b49813176939d7a339ae513d5175efvboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync int rc = pThis->pDrvMedia->pfnRead(pThis->pDrvMedia, off, pvBuf, cbRead);
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc PDMIBLOCK::pfnWrite */
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(int) drvblockWrite(PPDMIBLOCK pInterface, uint64_t off, const void *pvBuf, size_t cbWrite)
16a9adc14900ca18e6909679a579f6833425e030vboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync * Check the state.
9496f2d398b49813176939d7a339ae513d5175efvboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync /* Set an FTM checkpoint as this operation changes the state permanently. */
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync PDMDrvHlpFTSetCheckpoint(pThis->pDrvIns, FTMCHECKPOINTTYPE_STORAGE);
16a9adc14900ca18e6909679a579f6833425e030vboxsync int rc = pThis->pDrvMedia->pfnWrite(pThis->pDrvMedia, off, pvBuf, cbWrite);
a0240ff4f7663045c848fdbc192ea3d4d9f70a11vboxsync#endif /* VBOX_PERIODIC_FLUSH */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync/** @copydoc PDMIBLOCK::pfnFlush */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsyncstatic DECLCALLBACK(int) drvblockFlush(PPDMIBLOCK pInterface)
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync * Check the state.
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync#endif /* VBOX_IGNORE_FLUSH */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync int rc = pThis->pDrvMedia->pfnFlush(pThis->pDrvMedia);
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync/** @copydoc PDMIBLOCK::pfnMerge */
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsyncstatic DECLCALLBACK(int) drvblockMerge(PPDMIBLOCK pInterface,
d80c85a1bc7317da7d0cd1254fae6a20db039c8cvboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Check the state.
16a9adc14900ca18e6909679a579f6833425e030vboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
16a9adc14900ca18e6909679a579f6833425e030vboxsync int rc = pThis->pDrvMedia->pfnMerge(pThis->pDrvMedia, pfnProgress, pvUser);
16a9adc14900ca18e6909679a579f6833425e030vboxsync/** @copydoc PDMIBLOCK::pfnIsReadOnly */
16a9adc14900ca18e6909679a579f6833425e030vboxsyncstatic DECLCALLBACK(bool) drvblockIsReadOnly(PPDMIBLOCK pInterface)
16a9adc14900ca18e6909679a579f6833425e030vboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Check the state.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync return false;
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync bool fRc = pThis->pDrvMedia->pfnIsReadOnly(pThis->pDrvMedia);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/** @copydoc PDMIBLOCK::pfnGetSize */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(uint64_t) drvblockGetSize(PPDMIBLOCK pInterface)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Check the state.
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync uint64_t cb = pThis->pDrvMedia->pfnGetSize(pThis->pDrvMedia);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/** @copydoc PDMIBLOCK::pfnGetType */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(PDMBLOCKTYPE) drvblockGetType(PPDMIBLOCK pInterface)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync LogFlow(("drvblockGetType: returns %d\n", pThis->enmType));
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync/** @copydoc PDMIBLOCK::pfnGetUuid */
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsyncstatic DECLCALLBACK(int) drvblockGetUuid(PPDMIBLOCK pInterface, PRTUUID pUuid)
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync PDRVBLOCK pThis = PDMIBLOCK_2_DRVBLOCK(pInterface);
1bf495e3eec00dd79cecb6b36ef2a97f422c3737vboxsync * Copy the uuid.
9496f2d398b49813176939d7a339ae513d5175efvboxsync/* -=-=-=-=- IBlockAsync -=-=-=-=- */
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync/** Makes a PDRVBLOCK out of a PPDMIBLOCKASYNC. */
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync#define PDMIBLOCKASYNC_2_DRVBLOCK(pInterface) ( (PDRVBLOCK)((uintptr_t)pInterface - RT_OFFSETOF(DRVBLOCK, IBlockAsync)) )
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc PDMIBLOCKASYNC::pfnStartRead */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvblockAsyncReadStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG pSeg, unsigned cSeg, size_t cbRead, void *pvUser)
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Check the state.
7766bf675357fd940d8c49e69a5d72dc6eaa6be4vboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = pThis->pDrvMediaAsync->pfnStartRead(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbRead, pvUser);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIBLOCKASYNC::pfnStartWrite */
d5ea45cc92d7f1d3ade8189944531f665bfe8ed5vboxsyncstatic DECLCALLBACK(int) drvblockAsyncWriteStart(PPDMIBLOCKASYNC pInterface, uint64_t off, PCRTSGSEG pSeg, unsigned cSeg, size_t cbWrite, void *pvUser)
d5ea45cc92d7f1d3ade8189944531f665bfe8ed5vboxsync PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
9496f2d398b49813176939d7a339ae513d5175efvboxsync * Check the state.
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = pThis->pDrvMediaAsync->pfnStartWrite(pThis->pDrvMediaAsync, off, pSeg, cSeg, cbWrite, pvUser);
7766bf675357fd940d8c49e69a5d72dc6eaa6be4vboxsync/** @copydoc PDMIBLOCKASYNC::pfnStartFLush */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvblockAsyncFlushStart(PPDMIBLOCKASYNC pInterface, void *pvUser)
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync PDRVBLOCK pThis = PDMIBLOCKASYNC_2_DRVBLOCK(pInterface);
bbede9c189def47a9880f0ffb03c0c230c774185vboxsync * Check the state.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync#endif /* VBOX_IGNORE_FLUSH */
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync int rc = pThis->pDrvMediaAsync->pfnStartFlush(pThis->pDrvMediaAsync, pvUser);
61d064a54f03596920c3918f58ecc7764074a5d8vboxsync/* -=-=-=-=- IMediaAsyncPort -=-=-=-=- */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/** Makes a PDRVBLOCKASYNC out of a PPDMIMEDIAASYNCPORT. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync#define PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface) ( (PDRVBLOCK((uintptr_t)pInterface - RT_OFFSETOF(DRVBLOCK, IMediaAsyncPort))) )
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvblockAsyncTransferCompleteNotify(PPDMIMEDIAASYNCPORT pInterface, void *pvUser, int rcReq)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVBLOCK pThis = PDMIMEDIAASYNCPORT_2_DRVBLOCK(pInterface);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync return pThis->pDrvBlockAsyncPort->pfnTransferCompleteNotify(pThis->pDrvBlockAsyncPort, pvUser, rcReq);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/* -=-=-=-=- IBlockBios -=-=-=-=- */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/** Makes a PDRVBLOCK out of a PPDMIBLOCKBIOS. */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync#define PDMIBLOCKBIOS_2_DRVBLOCK(pInterface) ( (PDRVBLOCK((uintptr_t)pInterface - RT_OFFSETOF(DRVBLOCK, IBlockBios))) )
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc PDMIBLOCKBIOS::pfnGetPCHSGeometry */
9496f2d398b49813176939d7a339ae513d5175efvboxsyncstatic DECLCALLBACK(int) drvblockGetPCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pPCHSGeometry)
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
9496f2d398b49813176939d7a339ae513d5175efvboxsync * Check the state.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * Use configured/cached values if present.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors));
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync * Call media.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = pThis->pDrvMedia->pfnBiosGetPCHSGeometry(pThis->pDrvMedia, &pThis->PCHSGeometry);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync LogFlow(("%s: returns %Rrc {%d,%d,%d}\n", __FUNCTION__, rc, pThis->PCHSGeometry.cCylinders, pThis->PCHSGeometry.cHeads, pThis->PCHSGeometry.cSectors));
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/** @copydoc PDMIBLOCKBIOS::pfnSetPCHSGeometry */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvblockSetPCHSGeometry(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pPCHSGeometry)
9496f2d398b49813176939d7a339ae513d5175efvboxsync LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
9496f2d398b49813176939d7a339ae513d5175efvboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
9496f2d398b49813176939d7a339ae513d5175efvboxsync * Check the state.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * Call media. Ignore the not implemented return code.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync int rc = pThis->pDrvMedia->pfnBiosSetPCHSGeometry(pThis->pDrvMedia, pPCHSGeometry);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync/** @copydoc PDMIBLOCKBIOS::pfnGetLCHSGeometry */
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsyncstatic DECLCALLBACK(int) drvblockGetLCHSGeometry(PPDMIBLOCKBIOS pInterface, PPDMMEDIAGEOMETRY pLCHSGeometry)
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
9496f2d398b49813176939d7a339ae513d5175efvboxsync * Check the state.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * Use configured/cached values if present.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync LogFlow(("%s: returns VINF_SUCCESS {%d,%d,%d}\n", __FUNCTION__, pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors));
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync * Call media.
ce03ea57fdcf3d48523b1de5b894feb75e1b34davboxsync int rc = pThis->pDrvMedia->pfnBiosGetLCHSGeometry(pThis->pDrvMedia, &pThis->LCHSGeometry);
9496f2d398b49813176939d7a339ae513d5175efvboxsync LogFlow(("%s: returns %Rrc {%d,%d,%d}\n", __FUNCTION__, rc, pThis->LCHSGeometry.cCylinders, pThis->LCHSGeometry.cHeads, pThis->LCHSGeometry.cSectors));
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc PDMIBLOCKBIOS::pfnSetLCHSGeometry */
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsyncstatic DECLCALLBACK(int) drvblockSetLCHSGeometry(PPDMIBLOCKBIOS pInterface, PCPDMMEDIAGEOMETRY pLCHSGeometry)
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync LogFlow(("%s: cCylinders=%d cHeads=%d cSectors=%d\n", __FUNCTION__, pLCHSGeometry->cCylinders, pLCHSGeometry->cHeads, pLCHSGeometry->cSectors));
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync * Check the state.
5341459ca931b65de60b5af2a4cba6836b6b45cavboxsync AssertMsgFailed(("Invalid state! Not mounted!\n"));
9496f2d398b49813176939d7a339ae513d5175efvboxsync * Call media. Ignore the not implemented return code.
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync int rc = pThis->pDrvMedia->pfnBiosSetLCHSGeometry(pThis->pDrvMedia, pLCHSGeometry);
9496f2d398b49813176939d7a339ae513d5175efvboxsync/** @copydoc PDMIBLOCKBIOS::pfnIsVisible */
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsyncstatic DECLCALLBACK(bool) drvblockIsVisible(PPDMIBLOCKBIOS pInterface)
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
c7551981eb6d97331da479f68f14a9c56247e4f7vboxsync LogFlow(("drvblockIsVisible: returns %d\n", pThis->fBiosVisible));
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/** @copydoc PDMIBLOCKBIOS::pfnGetType */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(PDMBLOCKTYPE) drvblockBiosGetType(PPDMIBLOCKBIOS pInterface)
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync PDRVBLOCK pThis = PDMIBLOCKBIOS_2_DRVBLOCK(pInterface);
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync LogFlow(("drvblockBiosGetType: returns %d\n", pThis->enmType));
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/* -=-=-=-=- IMount -=-=-=-=- */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/** Makes a PDRVBLOCK out of a PPDMIMOUNT. */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync#define PDMIMOUNT_2_DRVBLOCK(pInterface) ( (PDRVBLOCK)((uintptr_t)pInterface - RT_OFFSETOF(DRVBLOCK, IMount)) )
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync/** @copydoc PDMIMOUNT::pfnMount */
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsyncstatic DECLCALLBACK(int) drvblockMount(PPDMIMOUNT pInterface, const char *pszFilename, const char *pszCoreDriver)
369a8817da53dbd5ea6ac360ca0376dba003cde4vboxsync LogFlow(("drvblockMount: pszFilename=%p:{%s} pszCoreDriver=%p:{%s}\n", pszFilename, pszFilename, pszCoreDriver, pszCoreDriver));
59d7f5939d42ad9d344fbad8401e00a900db92c5vboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Validate state.
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Prepare configuration.
16a9adc14900ca18e6909679a579f6833425e030vboxsync int rc = PDMDrvHlpMountPrepare(pThis->pDrvIns, pszFilename, pszCoreDriver);
16a9adc14900ca18e6909679a579f6833425e030vboxsync Log(("drvblockMount: Prepare failed for \"%s\" rc=%Rrc\n", pszFilename, rc));
16a9adc14900ca18e6909679a579f6833425e030vboxsync * Attach the media driver and query it's interface.
16a9adc14900ca18e6909679a579f6833425e030vboxsync uint32_t fTachFlags = 0; /** @todo figure attachment flags for mount. */
16a9adc14900ca18e6909679a579f6833425e030vboxsync int rc = PDMDrvHlpAttach(pThis->pDrvIns, fTachFlags, &pBase);
16a9adc14900ca18e6909679a579f6833425e030vboxsync Log(("drvblockMount: Attach failed rc=%Rrc\n", rc));
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA);
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync /** @todo r=klaus missing async handling, this is just a band aid to
975ad9d9bc9c4dc96b41d9f67a65228b1b338e2avboxsync * avoid using stale information */
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync * Initialize state.
9c149a2789022f5011e88fb62f02a1cc8068e88fvboxsync#endif /* VBOX_PERIODIC_FLUSH */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Notify driver/device above us.
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync pThis->pDrvMountNotify->pfnMountNotify(pThis->pDrvMountNotify);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Failed, detatch the media driver.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync int rc2 = PDMDrvHlpDetach(pThis->pDrvIns, fTachFlags);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync/** @copydoc PDMIMOUNT::pfnUnmount */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Validate state.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Media is no longer locked even if it was previously. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Detach the media driver and query it's interface.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync int rc = PDMDrvHlpDetach(pThis->pDrvIns, 0 /*fFlags*/);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync Log(("drvblockUnmount: Detach failed rc=%Rrc\n", rc));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Notify driver/device above us.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->pDrvMountNotify->pfnUnmountNotify(pThis->pDrvMountNotify);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc PDMIMOUNT::pfnIsMounted */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(bool) drvblockIsMounted(PPDMIMOUNT pInterface)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc PDMIMOUNT::pfnLock */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvblockLock(PPDMIMOUNT pInterface)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync Log(("drvblockLock: %d -> %d\n", pThis->fLocked, true));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc PDMIMOUNT::pfnUnlock */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvblockUnlock(PPDMIMOUNT pInterface)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync Log(("drvblockUnlock: %d -> %d\n", pThis->fLocked, false));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc PDMIMOUNT::pfnIsLocked */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(bool) drvblockIsLocked(PPDMIMOUNT pInterface)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/* -=-=-=-=- IBase -=-=-=-=- */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * @interface_method_impl{PDMIBASE,pfnQueryInterface}
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(void *) drvblockQueryInterface(PPDMIBASE pInterface, const char *pszIID)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PPDMDRVINS pDrvIns = PDMIBASE_2_PDMDRV(pInterface);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pDrvIns->IBase);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCK, &pThis->IBlock);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKBIOS, pThis->fBiosVisible ? &pThis->IBlockBios : NULL);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMOUNT, pThis->fMountable ? &pThis->IMount : NULL);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBLOCKASYNC, pThis->pDrvMediaAsync ? &pThis->IBlockAsync : NULL);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDMIBASE_RETURN_INTERFACE(pszIID, PDMIMEDIAASYNCPORT, pThis->pDrvBlockAsyncPort ? &pThis->IMediaAsyncPort : NULL);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/* -=-=-=-=- driver interface -=-=-=-=- */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync/** @copydoc FNPDMDRVDETACH. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(void) drvblockDetach(PPDMDRVINS pDrvIns, uint32_t fFlags)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Reset notification.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @returns VBox status.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @param pDevIns The driver instance data.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsyncstatic DECLCALLBACK(void) drvblockReset(PPDMDRVINS pDrvIns)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Construct a block driver instance.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * @copydoc FNPDMDRVCONSTRUCT
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsyncstatic DECLCALLBACK(int) drvblockConstruct(PPDMDRVINS pDrvIns, PCFGMNODE pCfg, uint32_t fFlags)
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync PDRVBLOCK pThis = PDMINS_2_DATA(pDrvIns, PDRVBLOCK);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync LogFlow(("drvblockConstruct: iInstance=%d\n", pDrvIns->iInstance));
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Validate configuration.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync#if defined(VBOX_PERIODIC_FLUSH) || defined(VBOX_IGNORE_FLUSH)
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync if (!CFGMR3AreValuesValid(pCfg, "Type\0Locked\0BIOSVisible\0AttachFailError\0Cylinders\0Heads\0Sectors\0Mountable\0FlushInterval\0IgnoreFlush\0IgnoreFlushAsync\0"))
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync#else /* !(VBOX_PERIODIC_FLUSH || VBOX_IGNORE_FLUSH) */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync if (!CFGMR3AreValuesValid(pCfg, "Type\0Locked\0BIOSVisible\0AttachFailError\0Cylinders\0Heads\0Sectors\0Mountable\0"))
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync#endif /* !(VBOX_PERIODIC_FLUSH || VBOX_IGNORE_FLUSH) */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync * Initialize most of the data members.
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IBase. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pDrvIns->IBase.pfnQueryInterface = drvblockQueryInterface;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IBlock. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IBlockBios. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockBios.pfnGetPCHSGeometry = drvblockGetPCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IBlockBios.pfnSetPCHSGeometry = drvblockSetPCHSGeometry;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockBios.pfnGetLCHSGeometry = drvblockGetLCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IBlockBios.pfnSetLCHSGeometry = drvblockSetLCHSGeometry;
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->IBlockBios.pfnIsVisible = drvblockIsVisible;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockBios.pfnGetType = drvblockBiosGetType;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IMount. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IBlockAsync. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockAsync.pfnStartRead = drvblockAsyncReadStart;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockAsync.pfnStartWrite = drvblockAsyncWriteStart;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IBlockAsync.pfnStartFlush = drvblockAsyncFlushStart;
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync /* IMediaAsyncPort. */
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync pThis->IMediaAsyncPort.pfnTransferCompleteNotify = drvblockAsyncTransferCompleteNotify;
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync * Get the IBlockPort & IMountNotify interfaces of the above driver/device.
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync pThis->pDrvBlockPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIBLOCKPORT);
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_ABOVE,
4bd3e7685494afe7c303fc131c66e685023b6b4avboxsync /* Try to get the optional async block port interface above. */
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync pThis->pDrvBlockAsyncPort = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIBLOCKASYNCPORT);
4bd3e7685494afe7c303fc131c66e685023b6b4avboxsync pThis->pDrvMountNotify = PDMIBASE_QUERY_INTERFACE(pDrvIns->pUpBase, PDMIMOUNTNOTIFY);
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync * Query configuration.
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync int rc = CFGMR3QueryStringAlloc(pCfg, "Type", &psz);
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_BLOCK_NO_TYPE, N_("Failed to obtain the type"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync PDMDrvHlpVMSetError(pDrvIns, VERR_PDM_BLOCK_UNKNOWN_TYPE, RT_SRC_POS,
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync Log2(("drvblockConstruct: enmType=%d\n", pThis->enmType));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /* Mountable */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCfg, "Mountable", &pThis->fMountable, false);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Mountable\" from the config"));
8dbf70ba2345e69b0b6d45c38cf1add0ef10591cvboxsync /* Locked */
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = CFGMR3QueryBoolDef(pCfg, "Locked", &pThis->fLocked, false);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Locked\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /* BIOS visible */
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = CFGMR3QueryBoolDef(pCfg, "BIOSVisible", &pThis->fBiosVisible, true);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"BIOSVisible\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /** @todo AttachFailError is currently completely ignored. */
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /* Cylinders */
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = CFGMR3QueryU32Def(pCfg, "Cylinders", &pThis->LCHSGeometry.cCylinders, 0);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Cylinders\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /* Heads */
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = CFGMR3QueryU32Def(pCfg, "Heads", &pThis->LCHSGeometry.cHeads, 0);
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Heads\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync /* Sectors */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryU32Def(pCfg, "Sectors", &pThis->LCHSGeometry.cSectors, 0);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Sectors\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"Uuid\" from the config"));
d571b6e3237f0ce89ea27f6fa4635d41c5ee3d88vboxsync rc = CFGMR3QueryU32Def(pCfg, "FlushInterval", &pThis->cbFlushInterval, 0);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"FlushInterval\" from the config"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#endif /* VBOX_PERIODIC_FLUSH */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCfg, "IgnoreFlush", &pThis->fIgnoreFlush, true);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlush\" from the config"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogRel(("DrvBlock: Flushes will be passed to the disk\n"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync rc = CFGMR3QueryBoolDef(pCfg, "IgnoreFlushAsync", &pThis->fIgnoreFlushAsync, false);
51fe8789a74f6c118894aaa12eb69ec155386dbdvboxsync return PDMDRV_SET_ERROR(pDrvIns, rc, N_("Failed to query \"IgnoreFlushAsync\" from the config"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogRel(("DrvBlock: Async flushes will be ignored\n"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync LogRel(("DrvBlock: Async flushes will be passed to the disk\n"));
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync#endif /* VBOX_IGNORE_FLUSH */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Try attach driver below and query it's media interface.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->pDrvMedia = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIA);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync return PDMDRV_SET_ERROR(pDrvIns, VERR_PDM_MISSING_INTERFACE_BELOW,
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* Try to get the optional async interface. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->pDrvMediaAsync = PDMIBASE_QUERY_INTERFACE(pBase, PDMIMEDIAASYNC);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync pThis->pDrvMedia->pfnGetUuid(pThis->pDrvMedia, &pThis->Uuid);
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync * Block driver registration record.
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* u32Version */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* szName */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* szRCMod */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* szR0Mod */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pszDescription */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync "Generic block driver.",
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* fFlags */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* fClass. */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* cMaxInstances */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* cbInstance */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnConstruct */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnDestruct */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnRelocate */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnIOCtl */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnPowerOn */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnReset */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnSuspend */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnResume */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnAttach */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnDetach */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnPowerOff */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* pfnSoftReset */
cc15c3fa4bb2d3fb91e4d0cd15a73133963f86b0vboxsync /* u32EndVersion */