Changeset 35836 in vbox
- Timestamp:
- Feb 3, 2011 2:55:17 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r35755 r35836 782 782 HRESULT saveStateSettings(int aFlags); 783 783 784 void addMediumToRegistry(ComObjPtr<Medium> &pMedium, 785 GuidList &llRegistriesThatNeedSaving, 786 Guid *puuid); 787 784 788 HRESULT createImplicitDiffs(IProgress *aProgress, 785 789 ULONG aWeight, -
trunk/src/VBox/Main/include/MediumImpl.h
r35638 r35836 177 177 bool addRegistry(const Guid& id); 178 178 bool isInRegistry(const Guid& id); 179 const Guid& getFirstRegistryMachineId() const;179 bool getFirstRegistryMachineId(Guid &uuid) const; 180 180 HRESULT addToRegistryIDList(GuidList &llRegistryIDs); 181 181 -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r35757 r35836 3624 3624 ComObjPtr<Medium> diff; 3625 3625 diff.createObject(); 3626 // store this diff in the same registry as the parent 3627 Guid uuidRegistryParent; 3628 if (!medium->getFirstRegistryMachineId(uuidRegistryParent)) 3629 { 3630 // parent image has no registry: this can happen if we're attaching a new immutable 3631 // image that has not yet been attached (medium then points to the base and we're 3632 // creating the diff image for the immutable, and the parent is not yet registered); 3633 // put the parent in the machine registry then 3634 addMediumToRegistry(medium, llRegistriesThatNeedSaving, &uuidRegistryParent); 3635 } 3626 3636 rc = diff->init(mParent, 3627 3637 medium->getPreferredDiffFormat(), 3628 3638 strFullSnapshotFolder.append(RTPATH_SLASH_STR), 3629 medium->getFirstRegistryMachineId(), // store this diff in the same registry as the parent3639 uuidRegistryParent, 3630 3640 &llRegistriesThatNeedSaving); 3631 3641 if (FAILED(rc)) return rc; … … 3702 3712 if (FAILED(rc)) return rc; 3703 3713 3704 // and decide which medium registry to use now that the medium is attached: 3705 Guid uuid; 3706 if (mData->pMachineConfigFile->canHaveOwnMediaRegistry()) 3707 // machine XML is VirtualBox 4.0 or higher: 3708 uuid = getId(); // machine UUID 3709 else 3710 uuid = mParent->getGlobalRegistryId(); // VirtualBox global registry UUID 3711 3712 if (medium->addRegistry(uuid)) 3713 // registry actually changed: 3714 mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, uuid); 3714 addMediumToRegistry(medium, 3715 llRegistriesThatNeedSaving, 3716 NULL /* Guid *puuid */); 3715 3717 } 3716 3718 … … 3948 3950 pMedium->addBackReference(mData->mUuid); 3949 3951 3950 // and decide which medium registry to use now that the medium is attached: 3951 Guid uuid; 3952 if (mData->pMachineConfigFile->canHaveOwnMediaRegistry()) 3953 // machine XML is VirtualBox 4.0 or higher: 3954 uuid = getId(); // machine UUID 3955 else 3956 uuid = mParent->getGlobalRegistryId(); // VirtualBox global registry UUID 3957 3958 if (pMedium->addRegistry(uuid)) 3959 // registry actually changed: 3960 mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, uuid); 3952 addMediumToRegistry(pMedium, llRegistriesThatNeedSaving, NULL /* Guid *puuid */ ); 3961 3953 } 3962 3954 … … 8739 8731 8740 8732 /** 8733 * Ensures that the given medium is added to a media registry. If this machine 8734 * was created with 4.0 or later, then the machine registry is used. Otherwise 8735 * the global VirtualBox media registry is used. If the medium was actually 8736 * added to a registry (because it wasn't in the registry yet), the UUID of 8737 * that registry is added to the given list so that the caller can save the 8738 * registry. 8739 * 8740 * Caller must hold machine read lock! 8741 * 8742 * @param pMedium 8743 * @param llRegistriesThatNeedSaving 8744 * @param puuid Optional buffer that receives the registry UUID that was used. 8745 */ 8746 void Machine::addMediumToRegistry(ComObjPtr<Medium> &pMedium, 8747 GuidList &llRegistriesThatNeedSaving, 8748 Guid *puuid) 8749 { 8750 // decide which medium registry to use now that the medium is attached: 8751 Guid uuid; 8752 if (mData->pMachineConfigFile->canHaveOwnMediaRegistry()) 8753 // machine XML is VirtualBox 4.0 or higher: 8754 uuid = getId(); // machine UUID 8755 else 8756 uuid = mParent->getGlobalRegistryId(); // VirtualBox global registry UUID 8757 8758 if (pMedium->addRegistry(uuid)) 8759 // registry actually changed: 8760 mParent->addGuidToListUniquely(llRegistriesThatNeedSaving, uuid); 8761 8762 if (puuid) 8763 *puuid = uuid; 8764 } 8765 8766 /** 8741 8767 * Creates differencing hard disks for all normal hard disks attached to this 8742 8768 * machine and a new set of attachments to refer to created disks. … … 8894 8920 ComObjPtr<Medium> diff; 8895 8921 diff.createObject(); 8922 // store the diff in the same registry as the parent 8923 // (this cannot fail here because we can't create implicit diffs for 8924 // unregistered images) 8925 Guid uuidRegistryParent; 8926 Assert(pMedium->getFirstRegistryMachineId(uuidRegistryParent)); 8896 8927 rc = diff->init(mParent, 8897 8928 pMedium->getPreferredDiffFormat(), 8898 8929 strFullSnapshotFolder.append(RTPATH_SLASH_STR), 8899 pMedium->getFirstRegistryMachineId(), // store the diff in the same registry as the parent8930 uuidRegistryParent, 8900 8931 pllRegistriesThatNeedSaving); 8901 8932 if (FAILED(rc)) throw rc; -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r35803 r35836 3131 3131 * machine XML this medium is listed). 3132 3132 * 3133 * Every medium must now (4.0) reside in at least one media registry, which is identified by3134 * a UUID. This is either a machine UUID if the machine is from 4.0 or newer, in which case3133 * Every attached medium must now (4.0) reside in at least one media registry, which is identified 3134 * by a UUID. This is either a machine UUID if the machine is from 4.0 or newer, in which case 3135 3135 * machines have their own media registries, or it is the pseudo-UUID of the VirtualBox 3136 3136 * object if the machine is old and still needs the global registry in VirtualBox.xml. … … 3141 3141 * case, only VM2's registry is used for the disk in question.) 3142 3142 * 3143 * If there is no medium registry, particularly if the medium has not been attached yet, this 3144 * does not modify uuid and returns false. 3145 * 3143 3146 * ISOs and RAWs, by contrast, can be in more than one repository to make things easier for 3144 3147 * the user. … … 3146 3149 * Must have caller + locking! 3147 3150 * 3148 * @return 3149 */ 3150 const Guid& Medium::getFirstRegistryMachineId() const 3151 { 3152 return m->llRegistryIDs.front(); 3151 * @param uuid Receives first registry machine UUID, if available. 3152 * @return true if uuid was set. 3153 */ 3154 bool Medium::getFirstRegistryMachineId(Guid &uuid) const 3155 { 3156 if (m->llRegistryIDs.size()) 3157 { 3158 uuid = m->llRegistryIDs.front(); 3159 return true; 3160 } 3161 return false; 3153 3162 } 3154 3163
Note:
See TracChangeset
for help on using the changeset viewer.