Changeset 51925 in vbox
- Timestamp:
- Jul 8, 2014 11:13:51 AM (11 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/ConsoleImpl.h
r51753 r51925 844 844 HRESULT i_consoleParseDiskEncryption(const char *psz, const char **ppszEnd); 845 845 HRESULT i_configureEncryptionForDisk(const char *pszUuid); 846 HRESULT i_clearDiskEncryptionKeysOnAllAttachments(void); 846 847 int i_consoleParseKeyValue(const char *psz, const char **ppszEnd, 847 848 char **ppszKey, char **ppszVal); -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r51903 r51925 4380 4380 4381 4381 /** 4382 * Removes the key interfaces from all disk attachments, useful when 4383 * changing the key store or dropping it. 4384 */ 4385 HRESULT Console::i_clearDiskEncryptionKeysOnAllAttachments(void) 4386 { 4387 HRESULT hrc = S_OK; 4388 SafeIfaceArray<IMediumAttachment> sfaAttachments; 4389 4390 AutoCaller autoCaller(this); 4391 AssertComRCReturnRC(autoCaller.rc()); 4392 4393 /* Get the VM - must be done before the read-locking. */ 4394 SafeVMPtr ptrVM(this); 4395 if (!ptrVM.isOk()) 4396 return ptrVM.rc(); 4397 4398 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 4399 4400 hrc = mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(sfaAttachments)); 4401 AssertComRCReturnRC(hrc); 4402 4403 /* Find the correct attachment. */ 4404 for (unsigned i = 0; i < sfaAttachments.size(); i++) 4405 { 4406 const ComPtr<IMediumAttachment> &pAtt = sfaAttachments[i]; 4407 4408 /* 4409 * Query storage controller, port and device 4410 * to identify the correct driver. 4411 */ 4412 ComPtr<IStorageController> pStorageCtrl; 4413 Bstr storageCtrlName; 4414 LONG lPort, lDev; 4415 ULONG ulStorageCtrlInst; 4416 4417 hrc = pAtt->COMGETTER(Controller)(storageCtrlName.asOutParam()); 4418 AssertComRC(hrc); 4419 4420 hrc = pAtt->COMGETTER(Port)(&lPort); 4421 AssertComRC(hrc); 4422 4423 hrc = pAtt->COMGETTER(Device)(&lDev); 4424 AssertComRC(hrc); 4425 4426 hrc = mMachine->GetStorageControllerByName(storageCtrlName.raw(), pStorageCtrl.asOutParam()); 4427 AssertComRC(hrc); 4428 4429 hrc = pStorageCtrl->COMGETTER(Instance)(&ulStorageCtrlInst); 4430 AssertComRC(hrc); 4431 4432 StorageControllerType_T enmCtrlType; 4433 hrc = pStorageCtrl->COMGETTER(ControllerType)(&enmCtrlType); 4434 AssertComRC(hrc); 4435 const char *pcszDevice = i_convertControllerTypeToDev(enmCtrlType); 4436 4437 StorageBus_T enmBus; 4438 hrc = pStorageCtrl->COMGETTER(Bus)(&enmBus); 4439 AssertComRC(hrc); 4440 4441 unsigned uLUN; 4442 hrc = Console::i_convertBusPortDeviceToLun(enmBus, lPort, lDev, uLUN); 4443 AssertComRC(hrc); 4444 4445 PPDMIBASE pIBase = NULL; 4446 PPDMIMEDIA pIMedium = NULL; 4447 int rc = PDMR3QueryDriverOnLun(ptrVM.rawUVM(), pcszDevice, ulStorageCtrlInst, uLUN, "VD", &pIBase); 4448 if (RT_SUCCESS(rc)) 4449 { 4450 if (pIBase) 4451 { 4452 pIMedium = (PPDMIMEDIA)pIBase->pfnQueryInterface(pIBase, PDMIMEDIA_IID); 4453 if (pIMedium) 4454 { 4455 rc = pIMedium->pfnSetSecKeyIf(pIMedium, NULL); 4456 Assert(RT_SUCCESS(rc) || rc == VERR_NOT_SUPPORTED); 4457 } 4458 } 4459 } 4460 } 4461 4462 return hrc; 4463 } 4464 4465 /** 4382 4466 * Configures the encryption support for the disk identified by the gien UUID with 4383 4467 * the given key. … … 4484 4568 if (!pIMedium) 4485 4569 return setError(E_FAIL, tr("could not query medium interface of controller")); 4570 else 4571 { 4572 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey); 4573 if (RT_FAILURE(rc)) 4574 return setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc); 4575 } 4486 4576 } 4487 4577 else 4488 4578 return setError(E_FAIL, tr("could not query base interface of controller")); 4489 4579 } 4490 4491 rc = pIMedium->pfnSetSecKeyIf(pIMedium, mpIfSecKey);4492 if (RT_FAILURE(rc))4493 return setError(E_FAIL, tr("Failed to set the encryption key (%Rrc)"), rc);4494 4580 } 4495 4581 } … … 5965 6051 if (RT_FAILURE(vrc)) 5966 6052 hrc = setError(VBOX_E_VM_ERROR, tr("Could not suspend the machine execution (%Rrc)"), vrc); 6053 else 6054 { 6055 /* Unconfigure disk encryption from all attachments. */ 6056 i_clearDiskEncryptionKeysOnAllAttachments(); 6057 6058 /* Clear any keys we have stored. */ 6059 for (SecretKeyMap::iterator it = m_mapSecretKeys.begin(); 6060 it != m_mapSecretKeys.end(); 6061 it++) 6062 delete it->second; 6063 m_mapSecretKeys.clear(); 6064 } 5967 6065 5968 6066 LogFlowThisFunc(("hrc=%Rhrc\n", hrc));
Note:
See TracChangeset
for help on using the changeset viewer.