Changeset 54645 in vbox for trunk/src/VBox/Main
- Timestamp:
- Mar 5, 2015 12:12:41 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MediumImpl.h
r54591 r54645 145 145 HRESULT i_createMediumLockList(bool fFailIfInaccessible, 146 146 bool fMediumLockWrite, 147 bool fMediumLockWriteAll, 147 148 Medium *pToBeParent, 148 149 MediumLockList &mediumLockList); -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r54177 r54645 3844 3844 rc = medium->i_createMediumLockList(true /* fFailIfInaccessible */, 3845 3845 true /* fMediumLockWrite */, 3846 false /* fMediumLockWriteAll */, 3846 3847 NULL, 3847 3848 *pMediumLockList); … … 3941 3942 rc = medium->i_createMediumLockList(true /* fFailIfInaccessible */, 3942 3943 true /* fMediumLockWrite */, 3944 false /* fMediumLockWriteAll */, 3943 3945 NULL, 3944 3946 *pMediumLockList); … … 4107 4109 rc = diff->i_createMediumLockList(true /* fFailIfInaccessible */, 4108 4110 true /* fMediumLockWrite */, 4111 false /* fMediumLockWriteAll */, 4109 4112 medium, 4110 4113 *pMediumLockList); … … 4210 4213 rc = medium->i_createMediumLockList(true /* fFailIfInaccessible */, 4211 4214 true /* fMediumLockWrite */, 4215 false /* fMediumLockWriteAll */, 4212 4216 NULL, 4213 4217 *pMediumLockList); … … 10508 10512 rc = pMedium->i_createMediumLockList(true /* fFailIfInaccessible */, 10509 10513 false /* fMediumLockWrite */, 10514 false /* fMediumLockWriteAll */, 10510 10515 NULL, 10511 10516 *pMediumLockList); … … 10759 10764 rc = pMedium->i_createMediumLockList(true /* fFailIfInaccessible */, 10760 10765 false /* fMediumLockWrite */, 10766 false /* fMediumLockWriteAll */, 10761 10767 NULL, 10762 10768 *pMediumLockList); … … 14036 14042 mrc = pMedium->i_createMediumLockList(fIsVitalImage /* fFailIfInaccessible */, 14037 14043 !fIsReadOnlyLock /* fMediumLockWrite */, 14044 false /* fMediumLockWriteAll */, 14038 14045 NULL, 14039 14046 *pMediumLockList); -
trunk/src/VBox/Main/src-server/MachineImplCloneVM.cpp
r54438 r54645 684 684 rc = diff->i_createMediumLockList(true /* fFailIfInaccessible */, 685 685 true /* fMediumLockWrite */, 686 false /* fMediumLockWriteAll */, 686 687 pParent, 687 688 *pMediumLockList); -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r54625 r54645 2558 2558 alock.release(); 2559 2559 HRESULT rc = diff->i_createMediumLockList(true /* fFailIfInaccessible */, 2560 true /* fMediumLockWrite */, 2561 this, 2562 *pMediumLockList); 2560 true /* fMediumLockWrite */, 2561 false /* fMediumLockWriteAll */, 2562 this, 2563 *pMediumLockList); 2563 2564 alock.acquire(); 2564 2565 if (FAILED(rc)) … … 2698 2699 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 2699 2700 false /* fMediumLockWrite */, 2701 false /* fMediumLockWriteAll */, 2700 2702 NULL, 2701 2703 *pSourceMediumLockList); … … 2712 2714 rc = pTarget->i_createMediumLockList(true /* fFailIfInaccessible */, 2713 2715 true /* fMediumLockWrite */, 2716 false /* fMediumLockWriteAll */, 2714 2717 pParent, 2715 2718 *pTargetMediumLockList); … … 2826 2829 rc = i_createMediumLockList(true /* fFailIfInaccessible */ , 2827 2830 true /* fMediumLockWrite */, 2831 false /* fMediumLockWriteAll */, 2828 2832 NULL, 2829 2833 *pMediumLockList); … … 2895 2899 rc = i_createMediumLockList(true /* fFailIfInaccessible */ , 2896 2900 true /* fMediumLockWrite */, 2901 false /* fMediumLockWriteAll */, 2897 2902 NULL, 2898 2903 *pMediumLockList); … … 2977 2982 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 2978 2983 true /* fMediumLockWrite */, 2984 false /* fMediumLockWriteAll */, 2979 2985 NULL, 2980 2986 *pMediumLockList); … … 3049 3055 m->strLocationFull.c_str()); 3050 3056 3051 /* Cannot encrypt child media so far. */3052 if (m->pParent)3053 return setError(VBOX_E_INVALID_OBJECT_STATE,3054 tr("Cannot encrypt medium '%s' because it is a differencing medium"),3055 m->strLocationFull.c_str());3056 3057 3057 /* Cannot encrypt media which are attached to more than one virtual machine. */ 3058 3058 if (m->backRefs.size() > 1) … … 3071 3071 rc = i_createMediumLockList(true /* fFailIfInaccessible */ , 3072 3072 true /* fMediumLockWrite */, 3073 true /* fMediumLockAllWrite */, 3073 3074 NULL, 3074 3075 *pMediumLockList); … … 3087 3088 delete pMediumLockList; 3088 3089 throw setError(rc, 3089 tr("Failed to lock media when compacting'%s'"),3090 tr("Failed to lock media for encryption '%s'"), 3090 3091 i_getLocationFull().c_str()); 3092 } 3093 3094 /* 3095 * Check all media in the chain to not contain any branches or references to 3096 * other virtual machines, we support encrypting only a list of differencing media at the moment. 3097 */ 3098 MediumLockList::Base::const_iterator mediumListBegin = pMediumLockList->GetBegin(); 3099 MediumLockList::Base::const_iterator mediumListEnd = pMediumLockList->GetEnd(); 3100 for (MediumLockList::Base::const_iterator it = mediumListBegin; 3101 it != mediumListEnd; 3102 ++it) 3103 { 3104 const MediumLock &mediumLock = *it; 3105 const ComObjPtr<Medium> &pMedium = mediumLock.GetMedium(); 3106 AutoReadLock mediumReadLock(pMedium COMMA_LOCKVAL_SRC_POS); 3107 3108 Assert(pMedium->m->state == MediumState_LockedWrite); 3109 3110 if (pMedium->m->backRefs.size() > 1) 3111 { 3112 rc = setError(VBOX_E_INVALID_OBJECT_STATE, 3113 tr("Cannot encrypt medium '%s' because it is attached to %d virtual machines"), 3114 pMedium->m->strLocationFull.c_str(), pMedium->m->backRefs.size()); 3115 break; 3116 } 3117 else if (pMedium->m->llChildren.size() > 1) 3118 { 3119 rc = setError(VBOX_E_INVALID_OBJECT_STATE, 3120 tr("Cannot encrypt medium '%s' because it has %d children"), 3121 pMedium->m->strLocationFull.c_str(), pMedium->m->llChildren.size()); 3122 break; 3123 } 3124 } 3125 3126 if (FAILED(rc)) 3127 { 3128 delete pMediumLockList; 3129 throw rc; 3091 3130 } 3092 3131 … … 3094 3133 rc = pProgress->init(m->pVirtualBox, 3095 3134 static_cast <IMedium *>(this), 3096 BstrFmt(tr(" Compacting medium '%s'"), m->strLocationFull.c_str()).raw(),3135 BstrFmt(tr("Encrypting medium '%s'"), m->strLocationFull.c_str()).raw(), 3097 3136 TRUE /* aCancelable */); 3098 3137 if (FAILED(rc)) … … 3942 3981 * inaccessible media are silently skipped and not locked (i.e. their state remains "Inaccessible"); 3943 3982 * this is necessary for a VM's removable media VM startup for which we do not want to fail. 3944 * @param fMediumLockWrite Whether to associate a write lock with this medium. 3945 * @param pToBeParent Medium which will become the parent of this medium. 3946 * @param mediumLockList Where to store the resulting list. 3983 * @param fMediumLockWrite Whether to associate a write lock with this medium. 3984 * @param fMediumLockWriteAll Whether to associate a write lock to all other media too. 3985 * @param pToBeParent Medium which will become the parent of this medium. 3986 * @param mediumLockList Where to store the resulting list. 3947 3987 */ 3948 3988 HRESULT Medium::i_createMediumLockList(bool fFailIfInaccessible, 3949 3989 bool fMediumLockWrite, 3990 bool fMediumLockWriteAll, 3950 3991 Medium *pToBeParent, 3951 3992 MediumLockList &mediumLockList) … … 4015 4056 mediumLockList.Prepend(pMedium, fMediumLockWrite); 4016 4057 else 4017 mediumLockList.Prepend(pMedium, f alse);4058 mediumLockList.Prepend(pMedium, fMediumLockWriteAll); 4018 4059 4019 4060 pMedium = pMedium->i_getParent(); … … 4380 4421 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 4381 4422 true /* fMediumLockWrite */, 4423 false /* fMediumLockWriteAll */, 4382 4424 NULL, 4383 4425 *pMediumLockList); … … 4742 4784 rc = pTarget->i_createMediumLockList(true /* fFailIfInaccessible */, 4743 4785 true /* fMediumLockWrite */, 4786 false /* fMediumLockWriteAll */, 4744 4787 NULL, 4745 4788 *aMediumLockList); … … 4747 4790 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 4748 4791 false /* fMediumLockWrite */, 4792 false /* fMediumLockWriteAll */, 4749 4793 NULL, 4750 4794 *aMediumLockList); … … 5187 5231 HRESULT rc = i_createMediumLockList(true /* fFailIfInaccessible */, 5188 5232 false /* fMediumLockWrite */, 5233 false /* fMediumLockWriteAll */, 5189 5234 this, 5190 5235 mediumLockList); … … 5300 5345 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 5301 5346 false /* fMediumLockWrite */, 5347 false /* fMediumLockWriteAll */, 5302 5348 NULL, 5303 5349 *pSourceMediumLockList); … … 5391 5437 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 5392 5438 true /* fMediumLockWrite */, 5439 false /* fMediumLockWriteAll */, 5393 5440 aParent, 5394 5441 *pTargetMediumLockList); … … 5490 5537 rc = i_createMediumLockList(true /* fFailIfInaccessible */, 5491 5538 false /* fMediumLockWrite */, 5539 false /* fMediumLockWriteAll */, 5492 5540 NULL, 5493 5541 *pSourceMediumLockList); … … 5504 5552 rc = aTarget->i_createMediumLockList(true /* fFailIfInaccessible */, 5505 5553 true /* fMediumLockWrite */, 5554 false /* fMediumLockWriteAll */, 5506 5555 aParent, 5507 5556 *pTargetMediumLockList); … … 8804 8853 Medium::CryptoFilterSettings CryptoSettingsWrite; 8805 8854 8855 ComObjPtr<Medium> pBase = i_getBase(); 8856 8806 8857 uint8_t *pbDek = NULL; 8807 8858 size_t cbDek = 0; … … 8818 8869 * configured is existing. 8819 8870 */ 8820 settings::StringsMap::iterator it = m->mapProperties.find("CRYPT/KeyStore");8821 if (it != m->mapProperties.end())8871 settings::StringsMap::iterator it = pBase->m->mapProperties.find("CRYPT/KeyStore"); 8872 if (it != pBase->m->mapProperties.end()) 8822 8873 throw setError(VBOX_E_INVALID_OBJECT_STATE, 8823 8874 tr("The password given for the encrypted image is incorrect")); … … 8825 8876 else 8826 8877 { 8827 settings::StringsMap::iterator it = m->mapProperties.find("CRYPT/KeyStore");8828 if (it == m->mapProperties.end())8878 settings::StringsMap::iterator it = pBase->m->mapProperties.find("CRYPT/KeyStore"); 8879 if (it == pBase->m->mapProperties.end()) 8829 8880 throw setError(VBOX_E_INVALID_OBJECT_STATE, 8830 8881 tr("The image is not configured for encryption")); … … 8877 8928 AutoReadLock alock(pMedium COMMA_LOCKVAL_SRC_POS); 8878 8929 8879 /* sanity check */ 8880 if (it == mediumListLast) 8881 Assert(pMedium->m->state == MediumState_LockedWrite); 8882 else 8883 Assert(pMedium->m->state == MediumState_LockedRead); 8930 Assert(pMedium->m->state == MediumState_LockedWrite); 8884 8931 8885 8932 /* Open all media but last in read-only mode. Do not handle … … 8913 8960 thisLock.acquire(); 8914 8961 /* If everything went well set the new key store. */ 8915 settings::StringsMap::iterator it = m->mapProperties.find("CRYPT/KeyStore");8916 if (it != m->mapProperties.end())8917 m->mapProperties.erase(it);8918 8919 it = m->mapProperties.find("CRYPT/KeyId");8920 if (it != m->mapProperties.end())8921 m->mapProperties.erase(it);8962 settings::StringsMap::iterator it = pBase->m->mapProperties.find("CRYPT/KeyStore"); 8963 if (it != pBase->m->mapProperties.end()) 8964 pBase->m->mapProperties.erase(it); 8965 8966 it = pBase->m->mapProperties.find("CRYPT/KeyId"); 8967 if (it != pBase->m->mapProperties.end()) 8968 pBase->m->mapProperties.erase(it); 8922 8969 8923 8970 if (CryptoSettingsWrite.pszKeyStore) 8924 8971 { 8925 m->mapProperties["CRYPT/KeyStore"] = Utf8Str(CryptoSettingsWrite.pszKeyStore);8926 m->mapProperties["CRYPT/KeyId"] = task.mstrNewPasswordId;8972 pBase->m->mapProperties["CRYPT/KeyStore"] = Utf8Str(CryptoSettingsWrite.pszKeyStore); 8973 pBase->m->mapProperties["CRYPT/KeyId"] = task.mstrNewPasswordId; 8927 8974 } 8928 8975 8929 8976 thisLock.release(); 8930 i_markRegistriesModified();8977 pBase->i_markRegistriesModified(); 8931 8978 m->pVirtualBox->i_saveModifiedRegistries(); 8932 8979 }
Note:
See TracChangeset
for help on using the changeset viewer.