Changeset 91937 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Oct 21, 2021 11:38:29 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r91898 r91937 252 252 /** Number of bins for allocated requests. */ 253 253 #define DRVVD_VDIOREQ_ALLOC_BINS 8 254 255 /** 256 * VD config node. 257 */ 258 typedef struct VDCFGNODE 259 { 260 /** List node for the list of config nodes. */ 261 RTLISTNODE NdLst; 262 /** Pointer to the driver helper callbacks. */ 263 PCPDMDRVHLPR3 pHlp; 264 /** The config node. */ 265 PCFGMNODE pCfgNode; 266 } VDCFGNODE; 267 /** Pointer to a VD config node. */ 268 typedef VDCFGNODE *PVDCFGNODE; 254 269 255 270 /** … … 368 383 PVDREGIONLIST pRegionList; 369 384 385 /** VD config support. 386 * @{ */ 387 /** List head of config nodes. */ 388 RTLISTANCHOR LstCfgNodes; 389 /** @} */ 390 370 391 /** Cryptographic support 371 392 * @{ */ 372 393 /** Pointer to the CFGM node containing the config of the crypto filter 373 394 * if enable. */ 374 PCFGMNODE pCfgCrypto;395 VDCFGNODE CfgCrypto; 375 396 /** Config interface for the encryption filter. */ 376 397 VDINTERFACECONFIG VDIfCfg; … … 902 923 static DECLCALLBACK(bool) drvvdCfgAreKeysValid(void *pvUser, const char *pszzValid) 903 924 { 904 return CFGMR3AreValuesValid((PCFGMNODE)pvUser, pszzValid); 925 PVDCFGNODE pVdCfgNode = (PVDCFGNODE)pvUser; 926 PCPDMDRVHLPR3 pHlp = pVdCfgNode->pHlp; 927 return pHlp->pfnCFGMAreValuesValid(pVdCfgNode->pCfgNode, pszzValid); 905 928 } 906 929 907 930 static DECLCALLBACK(int) drvvdCfgQuerySize(void *pvUser, const char *pszName, size_t *pcb) 908 931 { 909 return CFGMR3QuerySize((PCFGMNODE)pvUser, pszName, pcb); 932 PVDCFGNODE pVdCfgNode = (PVDCFGNODE)pvUser; 933 PCPDMDRVHLPR3 pHlp = pVdCfgNode->pHlp; 934 return pHlp->pfnCFGMQuerySize(pVdCfgNode->pCfgNode, pszName, pcb); 910 935 } 911 936 912 937 static DECLCALLBACK(int) drvvdCfgQuery(void *pvUser, const char *pszName, char *pszString, size_t cchString) 913 938 { 914 return CFGMR3QueryString((PCFGMNODE)pvUser, pszName, pszString, cchString); 939 PVDCFGNODE pVdCfgNode = (PVDCFGNODE)pvUser; 940 PCPDMDRVHLPR3 pHlp = pVdCfgNode->pHlp; 941 return pHlp->pfnCFGMQueryString(pVdCfgNode->pCfgNode, pszName, pszString, cchString); 915 942 } 916 943 917 944 static DECLCALLBACK(int) drvvdCfgQueryBytes(void *pvUser, const char *pszName, void *ppvData, size_t cbData) 918 945 { 919 return CFGMR3QueryBytes((PCFGMNODE)pvUser, pszName, ppvData, cbData); 946 PVDCFGNODE pVdCfgNode = (PVDCFGNODE)pvUser; 947 PCPDMDRVHLPR3 pHlp = pVdCfgNode->pHlp; 948 return pHlp->pfnCFGMQueryBytes(pVdCfgNode->pCfgNode, pszName, ppvData, cbData); 920 949 } 921 950 … … 1378 1407 static int drvvdKeyCheckPrereqs(PVBOXDISK pThis, bool fSetError) 1379 1408 { 1380 if ( pThis-> pCfgCrypto1409 if ( pThis->CfgCrypto.pCfgNode 1381 1410 && !pThis->pIfSecKey) 1382 1411 { … … 1492 1521 } 1493 1522 1494 if ( pThis-> pCfgCrypto1523 if ( pThis->CfgCrypto.pCfgNode 1495 1524 && !pThis->pIfSecKey) 1496 1525 return VERR_VD_DEK_MISSING; … … 1680 1709 int rc = VINF_SUCCESS; 1681 1710 1682 if (pThis-> pCfgCrypto)1711 if (pThis->CfgCrypto.pCfgNode) 1683 1712 { 1684 1713 PVDINTERFACE pVDIfFilter = NULL; … … 1702 1731 1703 1732 rc = VDInterfaceAdd(&pThis->VDIfCfg.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 1704 pThis->pCfgCrypto, sizeof(VDINTERFACECONFIG), &pVDIfFilter);1733 &pThis->CfgCrypto, sizeof(VDINTERFACECONFIG), &pVDIfFilter); 1705 1734 AssertRC(rc); 1706 1735 … … 2173 2202 PVBOXDISK pThis = PDMINS_2_DATA(pDrvIns, PVBOXDISK); 2174 2203 2175 Assert (!pThis-> pCfgCrypto);2204 Assert (!pThis->CfgCrypto.pCfgNode); 2176 2205 2177 2206 switch (enmXferDir) … … 3961 3990 if (RT_SUCCESS(rc)) 3962 3991 { 3992 VDCFGNODE CfgNode; 3993 3963 3994 VDIfConfig.pfnAreKeysValid = drvvdCfgAreKeysValid; 3964 3995 VDIfConfig.pfnQuerySize = drvvdCfgQuerySize; 3965 3996 VDIfConfig.pfnQuery = drvvdCfgQuery; 3966 3997 VDIfConfig.pfnQueryBytes = drvvdCfgQueryBytes; 3998 3999 CfgNode.pHlp = pThis->pDrvIns->pHlpR3; 4000 CfgNode.pCfgNode = pCfgFilterConfig; 3967 4001 rc = VDInterfaceAdd(&VDIfConfig.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 3968 pCfgFilterConfig, sizeof(VDINTERFACECONFIG), &pVDIfsFilter);4002 &CfgNode, sizeof(VDINTERFACECONFIG), &pVDIfsFilter); 3969 4003 AssertRC(rc); 3970 4004 … … 4476 4510 4477 4511 drvvdStatsDeregister(pThis); 4512 4513 PVDCFGNODE pIt; 4514 PVDCFGNODE pItNext; 4515 RTListForEachSafe(&pThis->LstCfgNodes, pIt, pItNext, VDCFGNODE, NdLst) 4516 { 4517 RTListNodeRemove(&pIt->NdLst); 4518 RTMemFreeZ(pIt, sizeof(*pIt)); 4519 } 4478 4520 } 4479 4521 … … 4513 4555 pThis->uMergeSource = VD_LAST_IMAGE; 4514 4556 pThis->uMergeTarget = VD_LAST_IMAGE; 4515 pThis->pCfgCrypto = NULL; 4557 pThis->CfgCrypto.pCfgNode = NULL; 4558 pThis->CfgCrypto.pHlp = pDrvIns->pHlpR3; 4516 4559 pThis->pIfSecKey = NULL; 4517 4560 pThis->hIoReqCache = NIL_RTMEMCACHE; … … 4577 4620 pThis->IMediaEx.pfnIoReqSuspendedLoad = drvvdIoReqSuspendedLoad; 4578 4621 4622 RTListInit(&pThis->LstCfgNodes); 4623 4579 4624 /* Initialize supported VD interfaces. */ 4580 4625 pThis->pVDIfsDisk = NULL; … … 4949 4994 4950 4995 if (pThis->pDrvMediaExPort) 4951 rc = IOBUFMgrCreate(&pThis->hIoBufMgr, cbIoBufMax, pThis-> pCfgCrypto? IOBUFMGR_F_REQUIRE_NOT_PAGABLE : IOBUFMGR_F_DEFAULT);4996 rc = IOBUFMgrCreate(&pThis->hIoBufMgr, cbIoBufMax, pThis->CfgCrypto.pCfgNode ? IOBUFMGR_F_REQUIRE_NOT_PAGABLE : IOBUFMGR_F_DEFAULT); 4952 4997 4953 4998 if ( !fEmptyDrive … … 5084 5129 pImage->VDIfConfig.pfnQuery = drvvdCfgQuery; 5085 5130 pImage->VDIfConfig.pfnQueryBytes = NULL; 5131 5132 PVDCFGNODE pCfgNode = (PVDCFGNODE)RTMemAllocZ(sizeof(*pCfgNode)); 5133 if (RT_UNLIKELY(!pCfgNode)) 5134 { 5135 rc = PDMDRV_SET_ERROR(pDrvIns, VERR_NO_MEMORY, 5136 N_("DrvVD: Failed to allocate memory for config node")); 5137 break; 5138 } 5139 5140 pCfgNode->pHlp = pDrvIns->pHlpR3; 5141 pCfgNode->pCfgNode = pCfgVDConfig; 5142 RTListAppend(&pThis->LstCfgNodes, &pCfgNode->NdLst); 5143 5086 5144 rc = VDInterfaceAdd(&pImage->VDIfConfig.Core, "DrvVD_Config", VDINTERFACETYPE_CONFIG, 5087 pCfg VDConfig, sizeof(VDINTERFACECONFIG), &pImage->pVDIfsImage);5145 pCfgNode, sizeof(VDINTERFACECONFIG), &pImage->pVDIfsImage); 5088 5146 AssertRC(rc); 5089 5147 … … 5096 5154 * crypto stuff. 5097 5155 */ 5098 if (!pThis-> pCfgCrypto)5156 if (!pThis->CfgCrypto.pCfgNode) 5099 5157 { 5100 5158 if (pCfgVDConfig) 5101 pThis-> pCfgCrypto= pHlp->pfnCFGMGetChild(pCfgVDConfig, "CRYPT");5102 5103 if (pThis-> pCfgCrypto)5159 pThis->CfgCrypto.pCfgNode = pHlp->pfnCFGMGetChild(pCfgVDConfig, "CRYPT"); 5160 5161 if (pThis->CfgCrypto.pCfgNode) 5104 5162 { 5105 5163 /* Setup VDConfig interface for disk encryption support. */ … … 5315 5373 && !pThis->fShareable 5316 5374 && !fDiscard 5317 && !pThis-> pCfgCrypto/* Disk encryption disables the block cache for security reasons */5375 && !pThis->CfgCrypto.pCfgNode /* Disk encryption disables the block cache for security reasons */ 5318 5376 && RT_SUCCESS(rc)) 5319 5377 {
Note:
See TracChangeset
for help on using the changeset viewer.