Changeset 33067 in vbox for trunk/src/VBox/Main/MachineImpl.cpp
- Timestamp:
- Oct 12, 2010 1:39:13 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r33051 r33067 406 406 unconst(mData->mUuid) = mData->pMachineConfigFile->uuid; 407 407 408 rc = loadMachineDataFromSettings(*mData->pMachineConfigFile); 408 rc = loadMachineDataFromSettings(*mData->pMachineConfigFile, 409 NULL /* puuidRegistry */); 409 410 if (FAILED(rc)) throw rc; 410 411 … … 496 497 unconst(mData->mUuid).create(); 497 498 498 rc = loadMachineDataFromSettings(config); 499 rc = loadMachineDataFromSettings(config, 500 &mData->mUuid); // puuidRegistry: initialize media with this registry ID 499 501 500 502 // override VM name as well, it may be different … … 655 657 mParent->settingsFilePath().c_str()); 656 658 657 rc = loadMachineDataFromSettings(*mData->pMachineConfigFile); 659 rc = loadMachineDataFromSettings(*mData->pMachineConfigFile, 660 NULL /* const Guid *puuidRegistry */); 658 661 if (FAILED(rc)) throw rc; 659 662 } … … 6813 6816 * depending on the caller's use case, so the caller needs to set that herself. 6814 6817 * 6815 * @param config 6816 * @param fAllowStorage 6818 * This gets called in several contexts during machine initialization: 6819 * 6820 * -- When machine XML exists on disk already and needs to be loaded into memory, 6821 * for example, from registeredInit() to load all registered machines on 6822 * VirtualBox startup. In this case, puuidRegistry is NULL because the media 6823 * attached to the machine should be part of some media registry already. 6824 * 6825 * -- During OVF import, when a machine config has been constructed from an 6826 * OVF file. In this case, puuidRegistry is set to the machine UUID to 6827 * ensure that the media listed as attachments in the config (which have 6828 * been imported from the OVF) receive the correct registry ID. 6829 * 6830 * @param config Machine settings from XML. 6831 * @param puuidRegistry If != NULL, Medium::setRegistryIdIfFirst() gets called with this registry ID for each attached medium in the config. 6832 * @return 6817 6833 */ 6818 HRESULT Machine::loadMachineDataFromSettings(const settings::MachineConfigFile &config) 6834 HRESULT Machine::loadMachineDataFromSettings(const settings::MachineConfigFile &config, 6835 const Guid *puuidRegistry) 6819 6836 { 6820 6837 // copy name, description, OS type, teleporter, UTC etc. … … 6886 6903 6887 6904 // load storage controllers 6888 rc = loadStorageControllers(config.storageMachine); 6905 rc = loadStorageControllers(config.storageMachine, 6906 puuidRegistry, 6907 NULL /* puuidSnapshot */); 6889 6908 if (FAILED(rc)) return rc; 6890 6909 6891 6910 /* 6892 6893 6894 6895 6896 6911 * NOTE: the assignment below must be the last thing to do, 6912 * otherwise it will be not possible to change the settings 6913 * somewehere in the code above because all setters will be 6914 * blocked by checkStateDependency(MutableStateDep). 6915 */ 6897 6916 6898 6917 /* set the machine state to Aborted or Saved when appropriate */ … … 7205 7224 } 7206 7225 7207 /** 7208 * @param aNode <StorageControllers> node. 7209 */ 7226 /** 7227 * Called from loadMachineDataFromSettings() for the storage controller data, including media. 7228 * 7229 * @param data 7230 * @param puuidRegistry media registry ID to set media to or NULL; see Machine::loadMachineDataFromSettings() 7231 * @param puuidSnapshot 7232 * @return 7233 */ 7210 7234 HRESULT Machine::loadStorageControllers(const settings::Storage &data, 7211 const Guid *aSnapshotId /* = NULL */) 7235 const Guid *puuidRegistry, 7236 const Guid *puuidSnapshot) 7212 7237 { 7213 7238 AssertReturn(!isSessionMachine(), E_FAIL); … … 7261 7286 rc = loadStorageDevices(pCtl, 7262 7287 ctlData, 7263 aSnapshotId); 7288 puuidRegistry, 7289 puuidSnapshot); 7264 7290 if (FAILED(rc)) return rc; 7265 7291 } … … 7269 7295 7270 7296 /** 7271 * @param aNode <HardDiskAttachments> node. 7272 * @param fAllowStorage if false, we produce an error if the config requests media attachments 7273 * (used with importing unregistered machines which cannot have media attachments) 7297 * Called from loadStorageControllers for a controller's devices. 7298 * 7299 * @param aStorageController 7300 * @param data 7301 * @param puuidRegistry media registry ID to set media to or NULL; see Machine::loadMachineDataFromSettings() 7274 7302 * @param aSnapshotId pointer to the snapshot ID if this is a snapshot machine 7275 * 7276 * @note Lock mParent for reading and hard disks for writing before calling. 7303 * @return 7277 7304 */ 7278 7305 HRESULT Machine::loadStorageDevices(StorageController *aStorageController, 7279 7306 const settings::StorageController &data, 7280 const Guid *aSnapshotId /*= NULL*/) 7307 const Guid *puuidRegistry, 7308 const Guid *puuidSnapshot) 7281 7309 { 7282 7310 HRESULT rc = S_OK; … … 7340 7368 return setError(E_FAIL, 7341 7369 tr("A differencing image of snapshot {%RTuuid} could not be found. %ls"), 7342 aSnapshotId->raw(),7370 puuidSnapshot->raw(), 7343 7371 info.getText().raw()); 7344 7372 } … … 7357 7385 medium->getLocationFull().c_str(), 7358 7386 dev.uuid.raw(), 7359 aSnapshotId->raw(),7387 puuidSnapshot->raw(), 7360 7388 mUserData->s.strName.c_str(), 7361 7389 mData->m_strConfigFileFull.c_str()); … … 7421 7449 { 7422 7450 if (isSnapshotMachine()) 7423 rc = medium->addBackReference(mData->mUuid, * aSnapshotId);7451 rc = medium->addBackReference(mData->mUuid, *puuidSnapshot); 7424 7452 else 7425 7453 rc = medium->addBackReference(mData->mUuid); 7454 7455 if (puuidRegistry) 7456 // caller wants registry ID to be set on all attached media (OVF import case) 7457 medium->setRegistryIdIfFirst(*puuidRegistry); 7426 7458 } 7427 7459
Note:
See TracChangeset
for help on using the changeset viewer.