- Timestamp:
- Nov 28, 2014 9:30:29 AM (10 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvVD.cpp
r53148 r53407 199 199 /** The secret key interface used to retrieve keys. */ 200 200 PPDMISECKEY pIfSecKey; 201 /** The secret key helper interface used to notify about missing keys. */ 202 PPDMISECKEYHLP pIfSecKeyHlp; 201 203 /** @} */ 202 204 } VBOXDISK, *PVBOXDISK; … … 1537 1539 } 1538 1540 1541 /** 1542 * Checks the prerequisites for encrypted I/O. 1543 * 1544 * @returns VBox status code. 1545 * @param pThis The VD driver instance data. 1546 */ 1547 static int drvvdKeyCheckPrereqs(PVBOXDISK pThis) 1548 { 1549 if ( pThis->pCfgCrypto 1550 && !pThis->pIfSecKey) 1551 { 1552 AssertPtr(pThis->pIfSecKeyHlp); 1553 pThis->pIfSecKeyHlp->pfnKeyMissingNotify(pThis->pIfSecKeyHlp); 1554 1555 int rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1556 N_("VD: The DEK for this disk is missing")); 1557 AssertRC(rc); 1558 return VERR_VD_DEK_MISSING; 1559 } 1560 1561 return VINF_SUCCESS; 1562 } 1539 1563 1540 1564 /******************************************************************************* … … 1551 1575 PVBOXDISK pThis = PDMIMEDIA_2_VBOXDISK(pInterface); 1552 1576 1553 if ( pThis->pCfgCrypto 1554 && !pThis->pIfSecKey) 1555 { 1556 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1557 N_("VD: The DEK for this disk is missing")); 1558 AssertRC(rc); 1559 return VERR_VD_DEK_MISSING; 1560 } 1577 rc = drvvdKeyCheckPrereqs(pThis); 1578 if (RT_FAILURE(rc)) 1579 return rc; 1561 1580 1562 1581 if (!pThis->fBootAccelActive) … … 1666 1685 off, pvBuf, cbWrite, cbWrite, pvBuf)); 1667 1686 1668 if ( pThis->pCfgCrypto 1669 && !pThis->pIfSecKey) 1670 { 1671 int rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1672 N_("VD: The DEK for this disk is missing")); 1673 AssertRC(rc); 1674 return VERR_VD_DEK_MISSING; 1675 } 1687 int rc = drvvdKeyCheckPrereqs(pThis); 1688 if (RT_FAILURE(rc)) 1689 return rc; 1676 1690 1677 1691 /* Invalidate any buffer if boot acceleration is enabled. */ … … 1682 1696 } 1683 1697 1684 intrc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite);1698 rc = VDWrite(pThis->pDisk, off, pvBuf, cbWrite); 1685 1699 LogFlowFunc(("returns %Rrc\n", rc)); 1686 1700 return rc; … … 1733 1747 1734 1748 /** @copydoc PDMIMEDIA::pfnSetKey */ 1735 static DECLCALLBACK(int) drvvdSetSecKeyIf(PPDMIMEDIA pInterface, PPDMISECKEY pIfSecKey )1749 static DECLCALLBACK(int) drvvdSetSecKeyIf(PPDMIMEDIA pInterface, PPDMISECKEY pIfSecKey, PPDMISECKEYHLP pIfSecKeyHlp) 1736 1750 { 1737 1751 LogFlowFunc(("\n")); … … 1742 1756 { 1743 1757 PVDINTERFACE pVDIfFilter = NULL; 1758 1759 pThis->pIfSecKeyHlp = pIfSecKeyHlp; 1744 1760 1745 1761 if ( pThis->pIfSecKey … … 1987 2003 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 1988 2004 1989 if ( pThis->pCfgCrypto 1990 && !pThis->pIfSecKey) 1991 { 1992 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 1993 N_("VD: The DEK for this disk is missing")); 1994 AssertRC(rc); 1995 return VERR_VD_DEK_MISSING; 1996 } 2005 rc = drvvdKeyCheckPrereqs(pThis); 2006 if (RT_FAILURE(rc)) 2007 return rc; 1997 2008 1998 2009 pThis->fBootAccelActive = false; … … 2025 2036 PVBOXDISK pThis = PDMIMEDIAASYNC_2_VBOXDISK(pInterface); 2026 2037 2027 if ( pThis->pCfgCrypto 2028 && !pThis->pIfSecKey) 2029 { 2030 rc = PDMDrvHlpVMSetRuntimeError(pThis->pDrvIns, VMSETRTERR_FLAGS_SUSPEND | VMSETRTERR_FLAGS_NO_WAIT, "DrvVD_DEKMISSING", 2031 N_("VD: The DEK for this disk is missing")); 2032 AssertRC(rc); 2033 return VERR_VD_DEK_MISSING; 2034 } 2038 rc = drvvdKeyCheckPrereqs(pThis); 2039 if (RT_FAILURE(rc)) 2040 return rc; 2035 2041 2036 2042 pThis->fBootAccelActive = false; -
trunk/src/VBox/Main/include/ConsoleImpl.h
r53062 r53407 806 806 static DECLCALLBACK(int) i_pdmIfSecKey_KeyRelease(PPDMISECKEY pInterface, const char *pszId); 807 807 808 static DECLCALLBACK(int) i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface); 809 808 810 int mcAudioRefs; 809 811 volatile uint32_t mcVRDPClients; … … 981 983 } *mpIfSecKey; 982 984 985 /** Pointer to the key helpers -> provider (that's us) callbacks. */ 986 struct MYPDMISECKEYHLP : public PDMISECKEYHLP 987 { 988 Console *pConsole; 989 } *mpIfSecKeyHlp; 990 983 991 /* Note: FreeBSD needs this whether netflt is used or not. */ 984 992 #if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD)) -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r53066 r53407 423 423 , mBusMgr(NULL) 424 424 , mpIfSecKey(NULL) 425 , mpIfSecKeyHlp(NULL) 425 426 , mVMStateChangeCallbackDisabled(false) 426 427 , mfUseHostClipboard(true) … … 467 468 pIfSecKey->pConsole = this; 468 469 mpIfSecKey = pIfSecKey; 470 471 MYPDMISECKEYHLP *pIfSecKeyHlp = (MYPDMISECKEYHLP *)RTMemAllocZ(sizeof(*mpIfSecKeyHlp) + sizeof(Console *)); 472 if (!pIfSecKeyHlp) 473 return E_OUTOFMEMORY; 474 pIfSecKeyHlp->pfnKeyMissingNotify = Console::i_pdmIfSecKeyHlp_KeyMissingNotify; 475 pIfSecKeyHlp->pConsole = this; 476 mpIfSecKeyHlp = pIfSecKeyHlp; 469 477 470 478 return BaseFinalConstruct(); … … 701 709 RTMemFree((void *)mpIfSecKey); 702 710 mpIfSecKey = NULL; 711 } 712 713 if (mpIfSecKeyHlp) 714 { 715 RTMemFree((void *)mpIfSecKeyHlp); 716 mpIfSecKeyHlp = NULL; 703 717 } 704 718 … … 4457 4471 if (pIMedium) 4458 4472 { 4459 rc = pIMedium->pfnSetSecKeyIf(pIMedium, NULL );4473 rc = pIMedium->pfnSetSecKeyIf(pIMedium, NULL, mpIfSecKeyHlp); 4460 4474 Assert(RT_SUCCESS(rc) || rc == VERR_NOT_SUPPORTED); 4461 4475 } … … 4574 4588 else 4575 4589 { 4576 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey );4590 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey, mpIfSecKeyHlp); 4577 4591 if (RT_FAILURE(rc)) 4578 4592 return setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc); … … 8224 8238 } 8225 8239 8240 case VMSTATE_POWERING_ON: 8241 { 8242 /* 8243 * We have to set the secret key helper interface for the VD drivers to 8244 * get notified about missing keys. 8245 */ 8246 that->i_clearDiskEncryptionKeysOnAllAttachments(); 8247 break; 8248 } 8249 8226 8250 default: /* shut up gcc */ 8227 8251 break; … … 8893 8917 LogRel(("Console: VM runtime error: fatal=%RTbool, errorID=%s message=\"%s\"\n", 8894 8918 fFatal, pszErrorId, message.c_str())); 8895 8896 /* Set guest property if the reason of the error is a missing DEK for a disk. */8897 if (!RTStrCmp(pszErrorId, "DrvVD_DEKMISSING"))8898 {8899 that->mMachine->DeleteGuestProperty(Bstr("/VirtualBox/HostInfo/DekMissing").raw());8900 that->mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/DekMissing").raw(),8901 Bstr("1").raw(), Bstr("RDONLYGUEST").raw());8902 that->mMachine->SaveSettings();8903 }8904 8905 8919 8906 8920 that->i_onRuntimeError(BOOL(fFatal), Bstr(pszErrorId).raw(), Bstr(message).raw()); … … 10258 10272 } 10259 10273 10274 /** 10275 * @interface_method_impl{PDMISECKEYHLP,pfnKeyMissingNotify} 10276 */ 10277 /*static*/ DECLCALLBACK(int) 10278 Console::i_pdmIfSecKeyHlp_KeyMissingNotify(PPDMISECKEYHLP pInterface) 10279 { 10280 Console *pConsole = ((MYPDMISECKEYHLP *)pInterface)->pConsole; 10281 10282 /* Set guest property only, the VM is paused in the media driver calling us. */ 10283 pConsole->mMachine->DeleteGuestProperty(Bstr("/VirtualBox/HostInfo/DekMissing").raw()); 10284 pConsole->mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/DekMissing").raw(), 10285 Bstr("1").raw(), Bstr("RDONLYGUEST").raw()); 10286 pConsole->mMachine->SaveSettings(); 10287 10288 return VINF_SUCCESS; 10289 } 10260 10290 10261 10291 -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r53330 r53407 3968 3968 AssertRCReturn(rc, rc); 3969 3969 3970 /* 3971 * Make the secret key helper interface known to the VD driver if it is attached, 3972 * so we can get notified about missing keys. 3973 */ 3974 PPDMIBASE pIBase = NULL; 3975 rc = PDMR3QueryDriverOnLun(pUVM, pcszDevice, uInstance, uLUN, "VD", &pIBase); 3976 if (RT_SUCCESS(rc) && pIBase) 3977 { 3978 PPDMIMEDIA pIMedium = (PPDMIMEDIA)pIBase->pfnQueryInterface(pIBase, PDMIMEDIA_IID); 3979 if (pIMedium) 3980 { 3981 rc = pIMedium->pfnSetSecKeyIf(pIMedium, NULL, mpIfSecKeyHlp); 3982 Assert(RT_SUCCESS(rc) || rc == VERR_NOT_SUPPORTED); 3983 } 3984 } 3985 3970 3986 /* There is no need to handle removable medium mounting, as we 3971 3987 * unconditionally replace everthing including the block driver level.
Note:
See TracChangeset
for help on using the changeset viewer.