Changeset 31615 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 12, 2010 6:12:39 PM (14 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/ApplianceImplExport.cpp
r31562 r31615 1504 1504 // create a new hard disk interface for the destination disk image 1505 1505 Log(("Creating target disk \"%s\"\n", strTargetFilePath.c_str())); 1506 rc = mVirtualBox->CreateHardDisk(bstrSrcFormat, Bstr(strTargetFilePath), pTargetDisk.asOutParam()); 1506 rc = mVirtualBox->CreateHardDisk(bstrSrcFormat, 1507 Bstr(strTargetFilePath), 1508 pTargetDisk.asOutParam()); 1507 1509 if (FAILED(rc)) throw rc; 1508 1510 -
trunk/src/VBox/Main/ApplianceImplImport.cpp
r31568 r31615 1316 1316 srcFormat = L"VMDK"; 1317 1317 // create an empty hard disk 1318 rc = mVirtualBox->CreateHardDisk(srcFormat, Bstr(strTargetPath), pTargetHD.asOutParam()); 1318 rc = mVirtualBox->CreateHardDisk(srcFormat, 1319 Bstr(strTargetPath), 1320 pTargetHD.asOutParam()); 1319 1321 if (FAILED(rc)) DebugBreakThrow(rc); 1320 1322 … … 1354 1356 if (FAILED(rc)) DebugBreakThrow(rc); 1355 1357 /* Create a new hard disk interface for the destination disk image */ 1356 rc = mVirtualBox->CreateHardDisk(srcFormat, Bstr(strTargetPath), pTargetHD.asOutParam()); 1358 rc = mVirtualBox->CreateHardDisk(srcFormat, 1359 Bstr(strTargetPath), 1360 pTargetHD.asOutParam()); 1357 1361 if (FAILED(rc)) DebugBreakThrow(rc); 1358 1362 /* Clone the source disk image */ … … 1707 1711 rc = pNewMachine->COMGETTER(Id)(bstrNewMachineId.asOutParam()); 1708 1712 if (FAILED(rc)) DebugBreakThrow(rc); 1709 m->llGuidsMachinesCreated.push_back(Guid(bstrNewMachineId)); 1713 Guid uuidNewMachine(bstrNewMachineId); 1714 m->llGuidsMachinesCreated.push_back(uuidNewMachine); 1710 1715 1711 1716 // Add floppies and CD-ROMs to the appropriate controllers. … … 1874 1879 rc = stack.pSession->COMGETTER(Machine)(sMachine.asOutParam()); 1875 1880 if (FAILED(rc)) DebugBreakThrow(rc); 1876 Bstr hdId;1877 rc = pTargetHD->COMGETTER(Id)(hdId.asOutParam());1878 if (FAILED(rc)) DebugBreakThrow(rc);1879 1881 1880 1882 // find the hard disk controller to which we should attach … … 1897 1899 mhda.lDevice, // long device 1898 1900 DeviceType_HardDisk, // DeviceType_T type 1899 hdId); // uuid id1901 pTargetHD); 1900 1902 if (FAILED(rc)) DebugBreakThrow(rc); 1901 1903 -
trunk/src/VBox/Main/MachineImpl.cpp
r31574 r31615 3097 3097 LONG aDevice, 3098 3098 DeviceType_T aType, 3099 I N_BSTR aId)3099 IMedium *aMedium) 3100 3100 { 3101 3101 LogFlowThisFunc(("aControllerName=\"%ls\" aControllerPort=%d aDevice=%d aType=%d aId=\"%ls\"\n", 3102 aControllerName, aControllerPort, aDevice, aType, a Id));3102 aControllerName, aControllerPort, aDevice, aType, aMedium)); 3103 3103 3104 3104 CheckComArgStrNotEmptyOrNull(aControllerName); … … 3109 3109 // if this becomes true then we need to call saveSettings in the end 3110 3110 // @todo r=dj there is no error handling so far... 3111 bool fNeeds SaveSettings = false;3111 bool fNeedsGlobalSaveSettings = false; 3112 3112 3113 3113 // request the host lock first, since might be calling Host methods for getting host drives; … … 3165 3165 } 3166 3166 3167 Guid uuid(aId); 3168 3169 ComObjPtr<Medium> medium; 3170 3171 switch (aType) 3172 { 3173 case DeviceType_HardDisk: 3174 /* find a hard disk by UUID */ 3175 rc = mParent->findHardDisk(&uuid, Utf8Str::Empty, true /* aSetError */, &medium); 3176 if (FAILED(rc)) return rc; 3177 break; 3178 3179 case DeviceType_DVD: 3180 case DeviceType_Floppy: 3181 rc = mParent->findRemoveableMedium(aType, uuid, true /* fRefresh */, medium); 3182 break; 3183 3184 default: 3185 return setError(E_INVALIDARG, 3186 tr("The device type %d is not recognized"), 3187 (int)aType); 3188 } 3167 ComObjPtr<Medium> medium = static_cast<Medium*>(aMedium); 3168 if (aMedium && medium.isNull()) 3169 return setError(E_INVALIDARG, "The given medium pointer is invalid"); 3189 3170 3190 3171 AutoCaller mediumCaller(medium); … … 3223 3204 { 3224 3205 /* the simplest case: restore the whole attachment 3225 * and return, nothing else to do */3206 * and return, nothing else to do */ 3226 3207 mMediaData->mAttachments.push_back(pAttachTemp); 3227 3208 return S_OK; … … 3229 3210 3230 3211 /* bus/channel/device differ; we need a new attachment object, 3231 3212 * but don't try to associate it again */ 3232 3213 associate = false; 3233 3214 break; … … 3394 3375 medium->getPreferredDiffFormat(), 3395 3376 Utf8Str(mUserData->m_strSnapshotFolderFull).append(RTPATH_SLASH_STR), 3396 &fNeedsSaveSettings); 3377 medium->getRegistryMachineId(), // store this diff in the same registry as the parent 3378 &fNeedsGlobalSaveSettings); 3397 3379 if (FAILED(rc)) return rc; 3398 3380 … … 3426 3408 NULL /* aProgress */, 3427 3409 true /* aWait */, 3428 &fNeeds SaveSettings);3410 &fNeedsGlobalSaveSettings); 3429 3411 3430 3412 alock.enter(); … … 3463 3445 if (associate && !medium.isNull()) 3464 3446 { 3465 / * as the last step, associate the medium to the VM */3447 // as the last step, associate the medium to the VM 3466 3448 rc = medium->addBackReference(mData->mUuid); 3467 /* here we can fail because of Deleting, or being in process of 3468 * creating a Diff */ 3449 // here we can fail because of Deleting, or being in process of creating a Diff 3469 3450 if (FAILED(rc)) return rc; 3451 3452 // and decide which medium registry to use now that the medium is attached: 3453 if (mData->pMachineConfigFile->canHaveOwnMediaRegistry()) 3454 medium->setRegistryIdIfFirst(getId()); // machine UUID 3455 else 3456 medium->setRegistryIdIfFirst(mParent->getGlobalRegistryId()); // VirtualBox global registry UUID 3470 3457 } 3471 3458 … … 3475 3462 mMediaData->mAttachments.push_back(attachment); 3476 3463 3477 if (fNeeds SaveSettings)3464 if (fNeedsGlobalSaveSettings) 3478 3465 { 3479 3466 // save the global settings; for that we should hold only the VirtualBox lock … … 3953 3940 ComSafeArrayOut(IMedium*, aMedia)) 3954 3941 { 3955 AutoCaller autoCaller(this); 3956 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 3942 // use AutoLimitedCaller because this call is valid on inaccessible machines as well 3943 AutoLimitedCaller autoCaller(this); 3944 AssertComRCReturnRC(autoCaller.rc()); 3957 3945 3958 3946 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3947 3948 Guid id(getId()); 3959 3949 3960 3950 if (mData->mSession.mState != SessionState_Unlocked) … … 3962 3952 tr("Cannot unregister the machine '%s' while it is locked"), 3963 3953 mUserData->s.strName.c_str()); 3954 3955 // wait for state dependants to drop to zero 3956 ensureNoStateDependencies(); 3957 3958 if (!mData->mAccessible) 3959 { 3960 // inaccessible maschines can only be unregistered; uninitialize ourselves 3961 // here because currently there may be no unregistered that are inaccessible 3962 // (this state combination is not supported). Note releasing the caller and 3963 // leaving the lock before alling uninit() 3964 alock.leave(); 3965 autoCaller.release(); 3966 3967 uninit(); 3968 3969 mParent->unregisterMachine(this, id); 3970 // calls VirtualBox::saveSettings() 3971 3972 return S_OK; 3973 } 3964 3974 3965 3975 HRESULT rc = S_OK; … … 4055 4065 sfaMedia.detachTo(ComSafeArrayOutArg(aMedia)); 4056 4066 4057 mParent->unregisterMachine(this );4067 mParent->unregisterMachine(this, id); 4058 4068 // calls VirtualBox::saveSettings() 4059 4069 … … 6681 6691 mUserData.commitCopy(); 6682 6692 6693 // machine registry, if present (must be loaded before snapshots) 6694 if (config.canHaveOwnMediaRegistry()) 6695 { 6696 rc = mParent->initMedia(getId(), // media registry ID == machine UUID 6697 config.mediaRegistry); 6698 if (FAILED(rc)) return rc; 6699 } 6700 6683 6701 /* Snapshot node (optional) */ 6684 6702 size_t cRootSnapshots; … … 6696 6714 } 6697 6715 6698 / * Hardware node (required) */6716 // hardware data 6699 6717 rc = loadHardware(config.hardwareMachine); 6700 6718 if (FAILED(rc)) return rc; 6701 6719 6702 / * Load storage controllers */6720 // load storage controllers 6703 6721 rc = loadStorageControllers(config.storageMachine); 6704 6722 if (FAILED(rc)) return rc; … … 7779 7797 if (FAILED(rc)) throw rc; 7780 7798 7799 // save machine's media registry if this is VirtualBox 3.3 or later 7800 if (config.canHaveOwnMediaRegistry()) 7801 mParent->saveMediaRegistry(config.mediaRegistry, 7802 getId()); // only media with registry ID == machine UUID 7803 // this throws HRESULT 7804 7781 7805 // save snapshots 7782 7806 rc = saveAllSnapshots(config); … … 8357 8381 pMedium->getPreferredDiffFormat(), 8358 8382 Utf8Str(mUserData->m_strSnapshotFolderFull).append(RTPATH_SLASH_STR), 8383 pMedium->getRegistryMachineId(), // store the diff in the same registry as the parent 8359 8384 pfNeedsSaveSettings); 8360 8385 if (FAILED(rc)) throw rc; -
trunk/src/VBox/Main/MediumImpl.cpp
r31571 r31615 191 191 Task(Medium *aMedium, Progress *aProgress) 192 192 : mVDOperationIfaces(NULL), 193 m_pfNeeds SaveSettings(NULL),193 m_pfNeedsGlobalSaveSettings(NULL), 194 194 mMedium(aMedium), 195 195 mMediumCaller(aMedium), … … 234 234 // the task function returns. Only used in synchronous (wait) mode; 235 235 // otherwise the task will save the settings itself. 236 bool *m_pfNeeds SaveSettings;236 bool *m_pfNeedsGlobalSaveSettings; 237 237 238 238 const ComObjPtr<Medium> mMedium; … … 728 728 * storage unit. 729 729 * 730 * This gets called by VirtualBox::CreateHardDisk(). 730 * This gets called by VirtualBox::CreateHardDisk() in which case uuidMachineRegistry 731 * is empty since starting with VirtualBox 3.3, we no longer add opened media to a 732 * registry automatically (this is deferred until the medium is attached to a machine). 733 * 734 * This also gets called when VirtualBox creates diff images; in this case uuidMachineRegistry 735 * is set to the registry of the parent image to make sure they all end up in the same 736 * file. 731 737 * 732 738 * For hard disks that don't have the VD_CAP_CREATE_FIXED or … … 736 742 * 737 743 * @param aVirtualBox VirtualBox object. 744 * @param aFormat 738 745 * @param aLocation Storage unit location. 739 * @param pfNeedsSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 746 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUI or medium UUID or empty if none). 747 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 740 748 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 741 749 */ … … 743 751 const Utf8Str &aFormat, 744 752 const Utf8Str &aLocation, 745 bool *pfNeedsSaveSettings) 753 const Guid &uuidMachineRegistry, 754 bool *pfNeedsGlobalSaveSettings) 746 755 { 747 756 AssertReturn(aVirtualBox != NULL, E_FAIL); … … 754 763 HRESULT rc = S_OK; 755 764 756 /* share VirtualBox weakly (parent remains NULL so far) */757 765 unconst(m->pVirtualBox) = aVirtualBox; 766 m->uuidRegistryMachine = uuidMachineRegistry; 758 767 759 768 /* no storage yet */ … … 791 800 792 801 AutoWriteLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 793 rc = m->pVirtualBox->registerHardDisk(this, pfNeeds SaveSettings);802 rc = m->pVirtualBox->registerHardDisk(this, pfNeedsGlobalSaveSettings); 794 803 } 795 804 … … 809 818 * Machine::AttachDevice() and createImplicitDiffs() when new diff 810 819 * images are created. 820 * 821 * There is no registry for this case since starting with VirtualBox 3.3, we 822 * no longer add opened media to a registry automatically (this is deferred 823 * until the medium is attached to a machine). 811 824 * 812 825 * For hard disks, the UUID, format and the parent of this medium will be … … 835 848 HRESULT rc = S_OK; 836 849 837 /* share VirtualBox weakly (parent remains NULL so far) */838 850 unconst(m->pVirtualBox) = aVirtualBox; 839 851 … … 893 905 * node. In this mode, the medium will always be opened read/write. 894 906 * 907 * In this case, since we're loading from a registry, uuidMachineRegistry is 908 * always set: it's either the global registry UUID or a machine UUID when 909 * loading from a per-machine registry. 910 * 895 911 * @param aVirtualBox VirtualBox object. 896 912 * @param aParent Parent medium disk or NULL for a root (base) medium. 897 913 * @param aDeviceType Device type of the medium. 914 * @param uuidMachineRegistry The registry to which this medium should be added (global registry UUI or medium UUID). 898 915 * @param aNode Configuration settings. 899 916 * … … 903 920 Medium *aParent, 904 921 DeviceType_T aDeviceType, 922 const Guid &uuidMachineRegistry, 905 923 const settings::Medium &data) 906 924 { … … 915 933 HRESULT rc = S_OK; 916 934 917 /* share VirtualBox and parent weakly */918 935 unconst(m->pVirtualBox) = aVirtualBox; 936 m->uuidRegistryMachine = uuidMachineRegistry; 919 937 920 938 /* register with VirtualBox/parent early, since uninit() will … … 1020 1038 this, // parent 1021 1039 aDeviceType, 1040 uuidMachineRegistry, 1022 1041 med); // child data 1023 1042 if (FAILED(rc)) break; 1024 1043 1025 rc = m->pVirtualBox->registerHardDisk(pHD, NULL /*pfNeeds SaveSettings*/);1044 rc = m->pVirtualBox->registerHardDisk(pHD, NULL /*pfNeedsGlobalSaveSettings*/); 1026 1045 if (FAILED(rc)) break; 1027 1046 } … … 1037 1056 * Initializes the medium object by providing the host drive information. 1038 1057 * Not used for anything but the host floppy/host DVD case. 1058 * 1059 * There is no registry for this case. 1039 1060 * 1040 1061 * @param aVirtualBox VirtualBox object. … … 1057 1078 AssertReturn(autoInitSpan.isOk(), E_FAIL); 1058 1079 1059 /* share VirtualBox weakly (parent remains NULL so far) */1060 1080 unconst(m->pVirtualBox) = aVirtualBox; 1061 1081 … … 1962 1982 ComObjPtr<VirtualBox> pVirtualBox(m->pVirtualBox); 1963 1983 1964 bool fNeeds SaveSettings = false;1965 HRESULT rc = close(&fNeeds SaveSettings, autoCaller);1966 1967 if (fNeeds SaveSettings)1984 bool fNeedsGlobalSaveSettings = false; 1985 HRESULT rc = close(&fNeedsGlobalSaveSettings, autoCaller); 1986 1987 if (fNeedsGlobalSaveSettings) 1968 1988 { 1969 1989 AutoWriteLock vboxlock(pVirtualBox COMMA_LOCKVAL_SRC_POS); … … 2180 2200 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 2181 2201 2182 bool fNeeds SaveSettings = false;2202 bool fNeedsGlobalSaveSettings = false; 2183 2203 ComObjPtr<Progress> pProgress; 2184 2204 2185 2205 HRESULT rc = deleteStorage(&pProgress, 2186 2206 false /* aWait */, 2187 &fNeeds SaveSettings);2188 if (fNeeds SaveSettings)2207 &fNeedsGlobalSaveSettings); 2208 if (fNeedsGlobalSaveSettings) 2189 2209 { 2190 2210 AutoWriteLock vboxlock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS); … … 2236 2256 2237 2257 rc = createDiffStorage(diff, aVariant, pMediumLockList, &pProgress, 2238 false /* aWait */, NULL /* pfNeeds SaveSettings*/);2258 false /* aWait */, NULL /* pfNeedsGlobalSaveSettings*/); 2239 2259 if (FAILED(rc)) 2240 2260 delete pMediumLockList; … … 2271 2291 rc = mergeTo(pTarget, fMergeForward, pParentForTarget, childrenToReparent, 2272 2292 pMediumLockList, &pProgress, false /* aWait */, 2273 NULL /* pfNeeds SaveSettings */);2293 NULL /* pfNeedsGlobalSaveSettings */); 2274 2294 if (FAILED(rc)) 2275 2295 cancelMergeTo(childrenToReparent, pMediumLockList); … … 3265 3285 Utf8Str name = RTPathFilename(m->strLocationFull.c_str()); 3266 3286 return name; 3287 } 3288 3289 /** 3290 * This sets the UUID of the machine in whose registry this medium should 3291 * be registered, or the UUID of the global VirtualBox.xml registry, but 3292 * only if no registry ID had been previously set. 3293 * @param id 3294 */ 3295 void Medium::setRegistryIdIfFirst(const Guid& id) 3296 { 3297 if (m->uuidRegistryMachine.isEmpty()) 3298 m->uuidRegistryMachine = id; 3299 } 3300 3301 /** 3302 * Returns the UUID of the machine in whose registry this medium is registered, 3303 * or the UUID of the global VirtualBox.xml registry. 3304 * @return 3305 */ 3306 const Guid& Medium::getRegistryId() const 3307 { 3308 return m->uuidRegistryMachine; 3267 3309 } 3268 3310 … … 3851 3893 * the object is no longer usable ("not ready" state). 3852 3894 * 3853 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true3895 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3854 3896 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3855 3897 * This only works in "wait" mode; otherwise saveSettings gets called automatically by the thread that was created, … … 3859 3901 * @return 3860 3902 */ 3861 HRESULT Medium::close(bool *pfNeeds SaveSettings, AutoCaller &autoCaller)3903 HRESULT Medium::close(bool *pfNeedsGlobalSaveSettings, AutoCaller &autoCaller) 3862 3904 { 3863 3905 // we're accessing parent/child and backrefs, so lock the tree first, then ourselves … … 3896 3938 // uninitialization (to keep the media registry consistent on 3897 3939 // failure to do so) 3898 rc = unregisterWithVirtualBox(pfNeeds SaveSettings);3940 rc = unregisterWithVirtualBox(pfNeedsGlobalSaveSettings); 3899 3941 if (FAILED(rc)) return rc; 3900 3942 } … … 3930 3972 * @param aWait @c true if this method should block instead of creating 3931 3973 * an asynchronous thread. 3932 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true3974 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3933 3975 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3934 3976 * This only works in "wait" mode; otherwise saveSettings gets called automatically by the thread that was created, … … 3940 3982 HRESULT Medium::deleteStorage(ComObjPtr<Progress> *aProgress, 3941 3983 bool aWait, 3942 bool *pfNeeds SaveSettings)3984 bool *pfNeedsGlobalSaveSettings) 3943 3985 { 3944 3986 AssertReturn(aProgress != NULL || aWait == true, E_FAIL); … … 4042 4084 * which would have been broken if unregisterWithVirtualBox() failed 4043 4085 * after we successfully deleted the storage) */ 4044 rc = unregisterWithVirtualBox(pfNeeds SaveSettings);4086 rc = unregisterWithVirtualBox(pfNeedsGlobalSaveSettings); 4045 4087 if (FAILED(rc)) 4046 4088 throw rc; … … 4078 4120 { 4079 4121 if (aWait) 4080 rc = runNow(pTask, NULL /* pfNeeds SaveSettings*/);4122 rc = runNow(pTask, NULL /* pfNeedsGlobalSaveSettings*/); 4081 4123 else 4082 4124 rc = startThread(pTask); … … 4201 4243 * @param aWait @c true if this method should block instead of 4202 4244 * creating an asynchronous thread. 4203 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been4245 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been 4204 4246 * initialized to false and that will be set to true 4205 4247 * by this function if the caller should invoke … … 4217 4259 ComObjPtr<Progress> *aProgress, 4218 4260 bool aWait, 4219 bool *pfNeeds SaveSettings)4261 bool *pfNeedsGlobalSaveSettings) 4220 4262 { 4221 4263 AssertReturn(!aTarget.isNull(), E_FAIL); … … 4307 4349 { 4308 4350 if (aWait) 4309 rc = runNow(pTask, pfNeeds SaveSettings);4351 rc = runNow(pTask, pfNeedsGlobalSaveSettings); 4310 4352 else 4311 4353 rc = startThread(pTask); … … 4685 4727 * @param aWait @c true if this method should block instead of creating 4686 4728 * an asynchronous thread. 4687 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true4729 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 4688 4730 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 4689 4731 * This only works in "wait" mode; otherwise saveSettings gets called automatically by the thread that was created, … … 4700 4742 ComObjPtr <Progress> *aProgress, 4701 4743 bool aWait, 4702 bool *pfNeeds SaveSettings)4744 bool *pfNeedsGlobalSaveSettings) 4703 4745 { 4704 4746 AssertReturn(pTarget != NULL, E_FAIL); … … 4762 4804 { 4763 4805 if (aWait) 4764 rc = runNow(pTask, pfNeeds SaveSettings);4806 rc = runNow(pTask, pfNeedsGlobalSaveSettings); 4765 4807 else 4766 4808 rc = startThread(pTask); … … 4863 4905 * on the device type of this medium. 4864 4906 * 4865 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true4907 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 4866 4908 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 4867 4909 * 4868 4910 * @note Caller must have locked the media tree lock for writing! 4869 4911 */ 4870 HRESULT Medium::unregisterWithVirtualBox(bool *pfNeeds SaveSettings)4912 HRESULT Medium::unregisterWithVirtualBox(bool *pfNeedsGlobalSaveSettings) 4871 4913 { 4872 4914 /* Note that we need to de-associate ourselves from the parent to let … … 4885 4927 { 4886 4928 case DeviceType_DVD: 4887 rc = m->pVirtualBox->unregisterImage(this, DeviceType_DVD, pfNeeds SaveSettings);4929 rc = m->pVirtualBox->unregisterImage(this, DeviceType_DVD, pfNeedsGlobalSaveSettings); 4888 4930 break; 4889 4931 4890 4932 case DeviceType_Floppy: 4891 rc = m->pVirtualBox->unregisterImage(this, DeviceType_Floppy, pfNeeds SaveSettings);4933 rc = m->pVirtualBox->unregisterImage(this, DeviceType_Floppy, pfNeedsGlobalSaveSettings); 4892 4934 break; 4893 4935 4894 4936 case DeviceType_HardDisk: 4895 rc = m->pVirtualBox->unregisterHardDisk(this, pfNeeds SaveSettings);4937 rc = m->pVirtualBox->unregisterHardDisk(this, pfNeedsGlobalSaveSettings); 4896 4938 break; 4897 4939 … … 5320 5362 */ 5321 5363 HRESULT Medium::runNow(Medium::Task *pTask, 5322 bool *pfNeeds SaveSettings)5364 bool *pfNeedsGlobalSaveSettings) 5323 5365 { 5324 5366 #ifdef VBOX_WITH_MAIN_LOCK_VALIDATION … … 5330 5372 #endif 5331 5373 5332 pTask->m_pfNeeds SaveSettings = pfNeedsSaveSettings;5374 pTask->m_pfNeedsGlobalSaveSettings = pfNeedsGlobalSaveSettings; 5333 5375 5334 5376 /* NIL_RTTHREAD indicates synchronous call. */ … … 5428 5470 * Created state only on success (leaving an orphan file is 5429 5471 * better than breaking media registry consistency) */ 5430 bool fNeeds SaveSettings = false;5472 bool fNeedsGlobalSaveSettings = false; 5431 5473 AutoWriteLock treeLock(m->pVirtualBox->getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 5432 rc = m->pVirtualBox->registerHardDisk(this, &fNeeds SaveSettings);5474 rc = m->pVirtualBox->registerHardDisk(this, &fNeedsGlobalSaveSettings); 5433 5475 treeLock.release(); 5434 5476 5435 if (fNeeds SaveSettings)5477 if (fNeedsGlobalSaveSettings) 5436 5478 { 5437 5479 AutoWriteLock vboxlock(m->pVirtualBox COMMA_LOCKVAL_SRC_POS); … … 5470 5512 * synchronously or asynchronously depending on the "wait" parameter passed to 5471 5513 * that function. If we run synchronously, the caller expects the bool 5472 * *pfNeeds SaveSettings to be set before returning; otherwise (in asynchronous5514 * *pfNeedsGlobalSaveSettings to be set before returning; otherwise (in asynchronous 5473 5515 * mode), we save the settings ourselves. 5474 5516 * … … 5480 5522 HRESULT rc = S_OK; 5481 5523 5482 bool fNeeds SaveSettings = false;5524 bool fNeedsGlobalSaveSettings = false; 5483 5525 5484 5526 const ComObjPtr<Medium> &pTarget = task.mTarget; … … 5609 5651 * Created state only on success (leaving an orphan file is 5610 5652 * better than breaking media registry consistency) */ 5611 rc = m->pVirtualBox->registerHardDisk(pTarget, &fNeeds SaveSettings);5653 rc = m->pVirtualBox->registerHardDisk(pTarget, &fNeedsGlobalSaveSettings); 5612 5654 5613 5655 if (FAILED(rc)) … … 5644 5686 if (task.isAsync()) 5645 5687 { 5646 if (fNeeds SaveSettings)5688 if (fNeedsGlobalSaveSettings) 5647 5689 { 5648 5690 // save the global settings; for that we should hold only the VirtualBox lock … … 5654 5696 else 5655 5697 // synchronous mode: report save settings result to caller 5656 if (task.m_pfNeeds SaveSettings)5657 *task.m_pfNeeds SaveSettings = fNeedsSaveSettings;5698 if (task.m_pfNeedsGlobalSaveSettings) 5699 *task.m_pfNeedsGlobalSaveSettings = fNeedsGlobalSaveSettings; 5658 5700 5659 5701 /* Note that in sync mode, it's the caller's responsibility to … … 5669 5711 * synchronously or asynchrously depending on the "wait" parameter passed to 5670 5712 * that function. If we run synchronously, the caller expects the bool 5671 * *pfNeeds SaveSettings to be set before returning; otherwise (in asynchronous5713 * *pfNeedsGlobalSaveSettings to be set before returning; otherwise (in asynchronous 5672 5714 * mode), we save the settings ourselves. 5673 5715 * … … 5831 5873 /* first, unregister the target since it may become a base 5832 5874 * medium which needs re-registration */ 5833 rc2 = m->pVirtualBox->unregisterHardDisk(pTarget, NULL /*&fNeeds SaveSettings*/);5875 rc2 = m->pVirtualBox->unregisterHardDisk(pTarget, NULL /*&fNeedsGlobalSaveSettings*/); 5834 5876 AssertComRC(rc2); 5835 5877 … … 5845 5887 5846 5888 /* then, register again */ 5847 rc2 = m->pVirtualBox->registerHardDisk(pTarget, NULL /*&fNeeds SaveSettings*/);5889 rc2 = m->pVirtualBox->registerHardDisk(pTarget, NULL /*&fNeedsGlobalSaveSettings*/); 5848 5890 AssertComRC(rc2); 5849 5891 } … … 5899 5941 5900 5942 rc2 = pMedium->m->pVirtualBox->unregisterHardDisk(pMedium, 5901 NULL /*pfNeeds SaveSettings*/);5943 NULL /*pfNeedsGlobalSaveSettings*/); 5902 5944 AssertComRC(rc2); 5903 5945 … … 5941 5983 else 5942 5984 // synchronous mode: report save settings result to caller 5943 if (task.m_pfNeeds SaveSettings)5944 *task.m_pfNeeds SaveSettings = true;5985 if (task.m_pfNeedsGlobalSaveSettings) 5986 *task.m_pfNeedsGlobalSaveSettings = true; 5945 5987 5946 5988 if (FAILED(rc)) … … 6160 6202 * Created state only on success (leaving an orphan file is 6161 6203 * better than breaking media registry consistency) */ 6162 rc = pParent->m->pVirtualBox->registerHardDisk(pTarget, NULL /* pfNeeds SaveSettings */);6204 rc = pParent->m->pVirtualBox->registerHardDisk(pTarget, NULL /* pfNeedsGlobalSaveSettings */); 6163 6205 6164 6206 if (FAILED(rc)) … … 6169 6211 { 6170 6212 /* just register */ 6171 rc = m->pVirtualBox->registerHardDisk(pTarget, NULL /* pfNeeds SaveSettings */);6213 rc = m->pVirtualBox->registerHardDisk(pTarget, NULL /* pfNeedsGlobalSaveSettings */); 6172 6214 } 6173 6215 } -
trunk/src/VBox/Main/SnapshotImpl.cpp
r31539 r31615 1357 1357 1358 1358 // if this becomes true, we need to call VirtualBox::saveSettings() in the end 1359 bool fNeeds SaveSettings = false;1359 bool fNeedsGlobalSaveSettings = false; 1360 1360 1361 1361 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 1440 1440 1, // operation weight; must be the same as in Console::TakeSnapshot() 1441 1441 !!fTakingSnapshotOnline, 1442 &fNeeds SaveSettings);1442 &fNeedsGlobalSaveSettings); 1443 1443 if (FAILED(rc)) 1444 1444 throw rc; … … 1501 1501 *aStateFilePath = NULL; 1502 1502 1503 // @todo r=dj normally we would need to save the settings if fNeeds SaveSettings was set to true,1503 // @todo r=dj normally we would need to save the settings if fNeedsGlobalSaveSettings was set to true, 1504 1504 // but since we have no error handling that cleans up the diff image that might have gotten created, 1505 1505 // there's no point in saving the disk registry at this point either... this needs fixing. … … 2320 2320 2321 2321 bool fMachineSettingsChanged = false; // Machine 2322 bool fNeeds SaveSettings = false; // VirtualBox.xml2322 bool fNeedsGlobalSaveSettings = false; // VirtualBox.xml 2323 2323 2324 2324 Guid snapshotId; … … 2564 2564 true /* aWait */, 2565 2565 &fNeedsSave); 2566 fNeeds SaveSettings |= fNeedsSave;2566 fNeedsGlobalSaveSettings |= fNeedsSave; 2567 2567 if (FAILED(rc)) 2568 2568 throw rc; … … 2607 2607 &fNeedsSave); 2608 2608 } 2609 fNeeds SaveSettings |= fNeedsSave;2609 fNeedsGlobalSaveSettings |= fNeedsSave; 2610 2610 2611 2611 // If the merge failed, we need to do our best to have a usable … … 2754 2754 updateMachineStateOnClient(); 2755 2755 2756 if (fMachineSettingsChanged || fNeeds SaveSettings)2756 if (fMachineSettingsChanged || fNeedsGlobalSaveSettings) 2757 2757 { 2758 2758 if (fMachineSettingsChanged) … … 2765 2765 // then, as it avoids a rather costly config equality check 2766 2766 // when we know that it is changed. 2767 saveSettings(&fNeeds SaveSettings, SaveS_Force | SaveS_InformCallbacksAnyway);2767 saveSettings(&fNeedsGlobalSaveSettings, SaveS_Force | SaveS_InformCallbacksAnyway); 2768 2768 } 2769 2769 2770 if (fNeeds SaveSettings)2770 if (fNeedsGlobalSaveSettings) 2771 2771 { 2772 2772 AutoWriteLock vboxLock(mParent COMMA_LOCKVAL_SRC_POS); … … 3137 3137 * return NULL if no real merge is necessary). 3138 3138 * @param aProgress Progress indicator. 3139 * @param pfNeeds SaveSettings Whether the VM settings need to be saved (out).3139 * @param pfNeedsMachineSaveSettings Whether the VM settings need to be saved (out). 3140 3140 */ 3141 3141 HRESULT SessionMachine::onlineMergeMedium(const ComObjPtr<MediumAttachment> &aMediumAttachment, … … 3147 3147 MediumLockList *aMediumLockList, 3148 3148 ComObjPtr<Progress> &aProgress, 3149 bool *pfNeeds SaveSettings)3149 bool *pfNeedsMachineSaveSettings) 3150 3150 { 3151 3151 AssertReturn(aSource != NULL, E_FAIL); … … 3225 3225 // The callback mentioned above takes care of update the medium state 3226 3226 3227 if (pfNeeds SaveSettings)3228 *pfNeeds SaveSettings = true;3227 if (pfNeedsMachineSaveSettings) 3228 *pfNeedsMachineSaveSettings = true; 3229 3229 3230 3230 return rc; … … 3260 3260 if (aMergeForward) 3261 3261 { 3262 Guid uuidRegistry = pTarget->getRegistryId(); 3263 3262 3264 // first, unregister the target since it may become a base 3263 3265 // hard disk which needs re-registration 3264 rc = mParent->unregisterHardDisk(pTarget, NULL /*&fNeeds SaveSettings*/);3266 rc = mParent->unregisterHardDisk(pTarget, NULL /*&fNeedsGlobalSaveSettings*/); 3265 3267 AssertComRC(rc); 3266 3268 … … 3273 3275 3274 3276 // then, register again 3275 rc = mParent->registerHardDisk(pTarget, NULL /*&fNeeds SaveSettings*/);3277 rc = mParent->registerHardDisk(pTarget, NULL /*&fNeedsGlobalSaveSettings*/); 3276 3278 AssertComRC(rc); 3277 3279 } … … 3344 3346 { 3345 3347 rc = mParent->unregisterHardDisk(pMedium, 3346 NULL /*pfNeeds SaveSettings*/);3348 NULL /*pfNeedsGlobalSaveSettings*/); 3347 3349 AssertComRC(rc); 3348 3350 -
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r31595 r31615 240 240 threadAsyncEvent(NIL_RTTHREAD), 241 241 pAsyncEventQ(NULL) 242 {} 242 { 243 unconst(uuidMediaRegistry).create(); 244 } 243 245 244 246 ~Data() … … 257 259 const Utf8Str strSettingsFilePath; 258 260 settings::MainConfigFile *pMainConfigFile; 261 262 // pseudo machine ID for global media registry (recreated on every startup) 263 const Guid uuidMediaRegistry; 259 264 260 265 // const objects not requiring locking … … 465 470 466 471 /* all registered media, needed by machines */ 467 if (FAILED(rc = initMedia())) 472 if (FAILED(rc = initMedia(m->uuidMediaRegistry, 473 m->pMainConfigFile->mediaRegistry))) 468 474 throw rc; 469 475 … … 593 599 } 594 600 595 HRESULT VirtualBox::initMedia() 596 { 601 /** 602 * Loads a media registry from XML and adds the media contained therein to 603 * the global lists of known media. 604 * 605 * This now (3.3) gets called from two locations: 606 * 607 * -- VirtualBox::init(), to load the global media registry from VirtualBox.xml; 608 * 609 * -- Machine::loadMachineDataFromSettings(), to load the per-machine registry 610 * from machine XML, for machines created with VirtualBox 3.3 or later. 611 * 612 * In both cases, the media found are added to the global lists so the 613 * global arrays of media (including the GUI's virtual media manager) 614 * continue to work as before. 615 * 616 * @param uuidMachineRegistry The UUID of the media registry. This is either the 617 * transient UUID created at VirtualBox startup for the global registry or 618 * a machine ID. 619 * @param mediaRegistry The XML settings structure to load, either from VirtualBox.xml 620 * or a machine XML. 621 * @return 622 */ 623 HRESULT VirtualBox::initMedia(const Guid &uuidRegistry, 624 const settings::MediaRegistry mediaRegistry) 625 { 626 LogFlow(("VirtualBox::initMedia ENTERING, uuidRegistry=%s\n", uuidRegistry.toString().c_str())); 627 597 628 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 598 629 599 630 HRESULT rc = S_OK; 600 631 settings::MediaList::const_iterator it; 601 for (it = m ->pMainConfigFile->mediaRegistry.llHardDisks.begin();602 it != m ->pMainConfigFile->mediaRegistry.llHardDisks.end();632 for (it = mediaRegistry.llHardDisks.begin(); 633 it != mediaRegistry.llHardDisks.end(); 603 634 ++it) 604 635 { … … 608 639 if (SUCCEEDED(rc = pHardDisk.createObject())) 609 640 rc = pHardDisk->init(this, 610 NULL, 641 NULL, // parent 611 642 DeviceType_HardDisk, 612 xmlHD); // XML data; this recurses to processes the children 643 uuidRegistry, 644 xmlHD); // XML data; this recurses to processes the children 613 645 if (FAILED(rc)) return rc; 614 646 615 rc = registerHardDisk(pHardDisk, NULL /*pfNeedsSaveSettings*/ ); 647 rc = registerHardDisk(pHardDisk, 648 NULL /*pfNeedsGlobalSaveSettings*/ ); 616 649 if (FAILED(rc)) return rc; 617 650 } 618 651 619 for (it = m ->pMainConfigFile->mediaRegistry.llDvdImages.begin();620 it != m ->pMainConfigFile->mediaRegistry.llDvdImages.end();652 for (it = mediaRegistry.llDvdImages.begin(); 653 it != mediaRegistry.llDvdImages.end(); 621 654 ++it) 622 655 { … … 625 658 ComObjPtr<Medium> pImage; 626 659 if (SUCCEEDED(pImage.createObject())) 627 rc = pImage->init(this, NULL, DeviceType_DVD, xmlDvd); 660 rc = pImage->init(this, 661 NULL, 662 DeviceType_DVD, 663 uuidRegistry, 664 xmlDvd); 628 665 if (FAILED(rc)) return rc; 629 666 630 rc = registerImage(pImage, DeviceType_DVD, NULL /*pfNeedsSaveSettings*/ ); 667 rc = registerImage(pImage, 668 DeviceType_DVD, 669 NULL /*pfNeedsGlobalSaveSettings*/ ); 631 670 if (FAILED(rc)) return rc; 632 671 } 633 672 634 for (it = m ->pMainConfigFile->mediaRegistry.llFloppyImages.begin();635 it != m ->pMainConfigFile->mediaRegistry.llFloppyImages.end();673 for (it = mediaRegistry.llFloppyImages.begin(); 674 it != mediaRegistry.llFloppyImages.end(); 636 675 ++it) 637 676 { … … 640 679 ComObjPtr<Medium> pImage; 641 680 if (SUCCEEDED(pImage.createObject())) 642 rc = pImage->init(this, NULL, DeviceType_Floppy, xmlFloppy); 681 rc = pImage->init(this, 682 NULL, 683 DeviceType_Floppy, 684 uuidRegistry, 685 xmlFloppy); 643 686 if (FAILED(rc)) return rc; 644 687 645 rc = registerImage(pImage, DeviceType_Floppy, NULL /*pfNeedsSaveSettings*/ ); 688 rc = registerImage(pImage, 689 DeviceType_Floppy, 690 NULL /*pfNeedsGlobalSaveSettings*/ ); 646 691 if (FAILED(rc)) return rc; 647 692 } 693 694 LogFlow(("VirtualBox::initMedia LEAVING\n")); 648 695 649 696 return S_OK; … … 1328 1375 getDefaultHardDiskFormat(format); 1329 1376 1330 HRESULT rc = E_FAIL; 1331 1332 bool fNeedsSaveSettings = false; 1377 bool fNeedsGlobalSaveSettings = false; 1333 1378 1334 1379 ComObjPtr<Medium> hardDisk; 1335 1380 hardDisk.createObject(); 1336 rc = hardDisk->init(this, 1337 format, 1338 aLocation, 1339 &fNeedsSaveSettings); 1381 HRESULT rc = hardDisk->init(this, 1382 format, 1383 aLocation, 1384 Guid::Empty, // media registry 1385 &fNeedsGlobalSaveSettings); 1340 1386 1341 1387 if (SUCCEEDED(rc)) 1342 1388 hardDisk.queryInterfaceTo(aHardDisk); 1343 1389 1344 if (fNeeds SaveSettings)1390 if (fNeedsGlobalSaveSettings) 1345 1391 { 1346 1392 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS); … … 1362 1408 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1363 1409 1410 bool fNeedsGlobalSaveSettings = false; 1411 ComObjPtr<Medium> pMedium; 1412 1364 1413 /* we don't access non-const data members so no need to lock */ 1365 HRESULT rc = E_FAIL;1366 1414 1367 1415 switch (deviceType) … … 1379 1427 } 1380 1428 1381 ComObjPtr<Medium> pMedium;1382 1429 pMedium.createObject(); 1383 rc = pMedium->init(this,1384 aLocation,1385 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly,1386 deviceType);1430 HRESULT rc = pMedium->init(this, 1431 aLocation, 1432 (accessMode == AccessMode_ReadWrite) ? Medium::OpenReadWrite : Medium::OpenReadOnly, 1433 deviceType); 1387 1434 1388 1435 if (SUCCEEDED(rc)) 1389 1436 { 1390 bool fNeedsGlobalSaveSettings = false;1391 1392 1437 AutoWriteLock treeLock(getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 1393 1438 … … 1395 1440 { 1396 1441 case DeviceType_HardDisk: 1397 rc = registerHardDisk(pMedium, &fNeedsGlobalSaveSettings); 1442 rc = registerHardDisk(pMedium, 1443 &fNeedsGlobalSaveSettings); 1398 1444 break; 1399 1445 1400 1446 case DeviceType_DVD: 1401 1447 case DeviceType_Floppy: 1402 rc = registerImage(pMedium, deviceType, &fNeedsGlobalSaveSettings); 1448 rc = registerImage(pMedium, 1449 deviceType, 1450 &fNeedsGlobalSaveSettings); 1403 1451 break; 1404 1452 } … … 1410 1458 * with the parent and this association needs to be broken. */ 1411 1459 1412 if (SUCCEEDED(rc)) 1413 pMedium.queryInterfaceTo(aMedium); 1414 else 1460 if (FAILED(rc)) 1415 1461 pMedium->uninit(); 1416 1417 if (fNeedsGlobalSaveSettings) 1418 { 1419 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS); 1420 saveSettings(); 1421 } 1462 } 1463 1464 if (SUCCEEDED(rc)) 1465 pMedium.queryInterfaceTo(aMedium); 1466 1467 if (fNeedsGlobalSaveSettings) 1468 { 1469 AutoWriteLock vboxlock(this COMMA_LOCKVAL_SRC_POS); 1470 saveSettings(); 1422 1471 } 1423 1472 … … 2749 2798 } 2750 2799 2800 /** 2801 * Returns the pseudo-machine UUID that is created on each VirtualBox startup 2802 * and that is used to identify the global media registry. 2803 * 2804 * Starting with VirtualBox 3.3 each medium remembers in its instance data 2805 * in which media registry it is saved (if any): this can either be a machine 2806 * UUID, if it's in a per-machine media registry, or this global ID. 2807 * 2808 * This UUID is only used to identify the VirtualBox object while VirtualBox 2809 * is running. It is not saved anywhere and thus gets recreated with every 2810 * VirtualBox startup. 2811 * 2812 * @return 2813 */ 2814 const Guid& VirtualBox::getGlobalRegistryId() const 2815 { 2816 return m->uuidMediaRegistry; 2817 } 2818 2751 2819 const ComObjPtr<Host>& VirtualBox::host() const 2752 2820 { … … 2857 2925 // private methods 2858 2926 ///////////////////////////////////////////////////////////////////////////// 2927 2928 Utf8Str VirtualBox::getRegistryPath(Medium *pMedium) 2929 { 2930 const Guid &rid = pMedium->getRegistryId(); 2931 2932 if (!rid.isEmpty()) 2933 { 2934 if (rid == getGlobalRegistryId()) 2935 return settingsFilePath(); 2936 2937 return rid.toString(); 2938 } 2939 return "[null]"; 2940 } 2859 2941 2860 2942 /** … … 2957 3039 2958 3040 /** 3041 * Goes through all known media (hard disks, floppies and DVDs) and saves 3042 * those into the given settings::MediaRegistry structures whose registry 3043 * ID match the given UUID. 3044 * 3045 * This gets called from two contexts: 3046 * 3047 * -- VirtualBox::saveSettings() with the UUID of the global registry 3048 * (VirtualBox::Data.uuidRegistry); this will save those media 3049 * which had been loaded from the global registry or have been 3050 * attached to a "legacy" machine which can't save its own registry; 3051 * 3052 * -- Machine::saveSettings() with the UUID of a machine, if a medium 3053 * has been attached to a machine created with VirtualBox 3.3 or later. 3054 * 3055 * Media which have only been temporarily opened without having been 3056 * attached to a machine have a NULL registry UUID and therefore don't 3057 * get saved. 3058 * 3059 * This throws HRESULT on errors! 3060 * 3061 * @param mediaRegistry 3062 * @param uuidRegistry 3063 * @return 3064 */ 3065 void VirtualBox::saveMediaRegistry(settings::MediaRegistry &mediaRegistry, 3066 const Guid &uuidRegistry) 3067 { 3068 HRESULT rc; 3069 // hard disks 3070 mediaRegistry.llHardDisks.clear(); 3071 for (MediaList::const_iterator it = m->allHardDisks.begin(); 3072 it != m->allHardDisks.end(); 3073 ++it) 3074 { 3075 Medium *pMedium = *it; 3076 // is medium in global registry:? 3077 if (pMedium->getRegistryId() == uuidRegistry) 3078 { 3079 settings::Medium med; 3080 rc = pMedium->saveSettings(med); // this recurses into its children 3081 if (FAILED(rc)) throw rc; 3082 mediaRegistry.llHardDisks.push_back(med); 3083 } 3084 } 3085 3086 // CD/DVD images 3087 mediaRegistry.llDvdImages.clear(); 3088 for (MediaList::const_iterator it = m->allDVDImages.begin(); 3089 it != m->allDVDImages.end(); 3090 ++it) 3091 { 3092 Medium *pMedium = *it; 3093 // is medium in global registry:? 3094 if (pMedium->getRegistryId() == uuidRegistry) 3095 { 3096 settings::Medium med; 3097 rc = pMedium->saveSettings(med); 3098 if (FAILED(rc)) throw rc; 3099 mediaRegistry.llDvdImages.push_back(med); 3100 } 3101 } 3102 3103 // floppy images 3104 mediaRegistry.llFloppyImages.clear(); 3105 for (MediaList::const_iterator it = m->allFloppyImages.begin(); 3106 it != m->allFloppyImages.end(); 3107 ++it) 3108 { 3109 Medium *pMedium = *it; 3110 // is medium in global registry:? 3111 if (pMedium->getRegistryId() == uuidRegistry) 3112 { 3113 settings::Medium med; 3114 rc = pMedium->saveSettings(med); 3115 if (FAILED(rc)) throw rc; 3116 mediaRegistry.llFloppyImages.push_back(med); 3117 } 3118 } 3119 } 3120 3121 /** 2959 3122 * Helper function which actually writes out VirtualBox.xml, the main configuration file. 2960 3123 * Gets called from the public VirtualBox::SaveSettings() as well as from various other … … 3019 3182 ++it2) 3020 3183 { 3021 const Data::PendingMachineRename &pmr = *it2; 3022 pMedium->updatePath(pmr.strConfigDirOld, 3023 pmr.strConfigDirNew); 3184 // is medium in global registry:? 3185 if (pMedium->getRegistryId() == m->uuidMediaRegistry) 3186 { 3187 const Data::PendingMachineRename &pmr = *it2; 3188 pMedium->updatePath(pmr.strConfigDirOld, 3189 pmr.strConfigDirNew); 3190 } 3024 3191 } 3025 3192 } … … 3028 3195 } 3029 3196 3030 // hard disks 3031 m->pMainConfigFile->mediaRegistry.llHardDisks.clear(); 3032 for (MediaList::const_iterator it = m->allHardDisks.begin(); 3033 it != m->allHardDisks.end(); 3034 ++it) 3035 { 3036 settings::Medium med; 3037 rc = (*it)->saveSettings(med); // this recurses into its children 3038 if (FAILED(rc)) throw rc; 3039 m->pMainConfigFile->mediaRegistry.llHardDisks.push_back(med); 3040 } 3041 3042 /* CD/DVD images */ 3043 m->pMainConfigFile->mediaRegistry.llDvdImages.clear(); 3044 for (MediaList::const_iterator it = m->allDVDImages.begin(); 3045 it != m->allDVDImages.end(); 3046 ++it) 3047 { 3048 settings::Medium med; 3049 rc = (*it)->saveSettings(med); 3050 if (FAILED(rc)) throw rc; 3051 m->pMainConfigFile->mediaRegistry.llDvdImages.push_back(med); 3052 } 3053 3054 /* floppy images */ 3055 m->pMainConfigFile->mediaRegistry.llFloppyImages.clear(); 3056 for (MediaList::const_iterator it = m->allFloppyImages.begin(); 3057 it != m->allFloppyImages.end(); 3058 ++it) 3059 { 3060 settings::Medium med; 3061 rc = (*it)->saveSettings(med); 3062 if (FAILED(rc)) throw rc; 3063 m->pMainConfigFile->mediaRegistry.llFloppyImages.push_back(med); 3064 } 3197 saveMediaRegistry(m->pMainConfigFile->mediaRegistry, 3198 m->uuidMediaRegistry); 3065 3199 3066 3200 mediaLock.release(); … … 3169 3303 3170 3304 /** 3171 * Remembers the given hard disk by storing it in the hard disk registry. 3172 * 3173 * @param aHardDisk Hard disk object to remember. 3174 * @param pfNeedsSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3305 * Remembers the given hard disk by storing it in either the global hard disk registry 3306 * or a machine one. 3307 * 3308 * @note Caller must hold the media tree lock for writing; in addition, this locks @a aHardDisk for reading 3309 * 3310 * @param aHardDisk Hard disk object to remember. 3311 * @param uuidMachineRegistry UUID of machine whose registry should be used, or a NULL UUID for the global registry. 3312 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3175 3313 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3176 * 3177 * @note Caller must hold the media tree lock for writing; in addition, this locks @a aHardDisk for reading 3178 */ 3179 HRESULT VirtualBox::registerHardDisk(Medium *aHardDisk, 3180 bool *pfNeedsSaveSettings) 3181 { 3182 AssertReturn(aHardDisk != NULL, E_INVALIDARG); 3314 * @return 3315 */ 3316 HRESULT VirtualBox::registerHardDisk(Medium *pMedium, 3317 bool *pfNeedsGlobalSaveSettings) 3318 { 3319 AssertReturn(pMedium != NULL, E_INVALIDARG); 3183 3320 3184 3321 AutoCaller autoCaller(this); 3185 3322 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3186 3323 3187 AutoCaller hardDiskCaller( aHardDisk);3324 AutoCaller hardDiskCaller(pMedium); 3188 3325 AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc()); 3189 3326 … … 3195 3332 ComObjPtr<Medium> pParent; 3196 3333 { 3197 AutoReadLock hardDiskLock( aHardDiskCOMMA_LOCKVAL_SRC_POS);3198 id = aHardDisk->getId();3199 strLocationFull = aHardDisk->getLocationFull();3200 pParent = aHardDisk->getParent();3334 AutoReadLock hardDiskLock(pMedium COMMA_LOCKVAL_SRC_POS); 3335 id = pMedium->getId(); 3336 strLocationFull = pMedium->getLocationFull(); 3337 pParent = pMedium->getParent(); 3201 3338 } 3202 3339 … … 3210 3347 3211 3348 if (strConflict.length()) 3349 { 3212 3350 return setError(E_INVALIDARG, 3213 tr("Cannot register the hard disk '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"),3351 tr("Cannot register the hard disk '%s' {%RTuuid} because a %s already exists"), 3214 3352 strLocationFull.c_str(), 3215 3353 id.raw(), 3216 3354 strConflict.c_str(), 3217 3355 m->strSettingsFilePath.c_str()); 3356 } 3218 3357 3219 3358 // store base (root) hard disks in the list 3220 3359 if (pParent.isNull()) 3221 m->allHardDisks.getList().push_back( aHardDisk);3360 m->allHardDisks.getList().push_back(pMedium); 3222 3361 // access the list directly because we already locked the list above 3223 3362 3224 3363 // store all hard disks (even differencing images) in the map 3225 m->mapHardDisks[id] = aHardDisk; 3226 3227 if (pfNeedsSaveSettings) 3228 *pfNeedsSaveSettings = true; 3364 m->mapHardDisks[id] = pMedium; 3365 3366 if (pfNeedsGlobalSaveSettings) 3367 // global settings need saving only if the medium is to be saved in the global registry 3368 if (pMedium->getRegistryId() == m->uuidMediaRegistry) 3369 *pfNeedsGlobalSaveSettings = true; 3229 3370 3230 3371 return rc; … … 3235 3376 * 3236 3377 * @param aHardDisk Hard disk object to remove. 3237 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true3378 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3238 3379 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3239 3380 * … … 3241 3382 */ 3242 3383 HRESULT VirtualBox::unregisterHardDisk(Medium *aHardDisk, 3243 bool *pfNeeds SaveSettings)3384 bool *pfNeedsGlobalSaveSettings) 3244 3385 { 3245 3386 AssertReturn(aHardDisk != NULL, E_INVALIDARG); … … 3272 3413 NOREF(cnt); 3273 3414 3274 if (pfNeedsSaveSettings) 3275 *pfNeedsSaveSettings = true; 3415 if (pfNeedsGlobalSaveSettings) 3416 // global settings need saving only if the medium is to be saved in the global registry 3417 if (aHardDisk->getRegistryId() == m->uuidMediaRegistry) 3418 *pfNeedsGlobalSaveSettings = true; 3276 3419 3277 3420 return S_OK; … … 3283 3426 * @param argImage Image object to remember. 3284 3427 * @param argType Either DeviceType_DVD or DeviceType_Floppy. 3285 * @param pfNeedsSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3428 * @param uuidMachineRegistry UUID of machine whose registry should be used, or a NULL UUID for the global registry. 3429 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3286 3430 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3287 3431 * 3288 3432 * @note Caller must hold the media tree lock for writing; in addition, this locks @a argImage for reading 3289 3433 */ 3290 HRESULT VirtualBox::registerImage(Medium * argImage,3434 HRESULT VirtualBox::registerImage(Medium *pMedium, 3291 3435 DeviceType_T argType, 3292 bool *pfNeeds SaveSettings)3293 { 3294 AssertReturn( argImage!= NULL, E_INVALIDARG);3436 bool *pfNeedsGlobalSaveSettings) 3437 { 3438 AssertReturn(pMedium != NULL, E_INVALIDARG); 3295 3439 3296 3440 AutoCaller autoCaller(this); 3297 3441 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 3298 3442 3299 AutoCaller imageCaller( argImage);3443 AutoCaller imageCaller(pMedium); 3300 3444 AssertComRCReturn(imageCaller.rc(), imageCaller.rc()); 3301 3445 … … 3307 3451 ComObjPtr<Medium> pParent; 3308 3452 { 3309 AutoReadLock al( argImageCOMMA_LOCKVAL_SRC_POS);3310 id = argImage->getId();3311 strLocationFull = argImage->getLocationFull();3312 pParent = argImage->getParent();3453 AutoReadLock al(pMedium COMMA_LOCKVAL_SRC_POS); 3454 id = pMedium->getId(); 3455 strLocationFull = pMedium->getLocationFull(); 3456 pParent = pMedium->getParent(); 3313 3457 } 3314 3458 … … 3322 3466 Utf8Str strConflict; 3323 3467 rc = checkMediaForConflicts2(id, 3324 3325 3468 strLocationFull, 3469 strConflict); 3326 3470 if (FAILED(rc)) return rc; 3327 3471 3328 3472 if (strConflict.length()) 3329 3473 return setError(VBOX_E_INVALID_OBJECT_STATE, 3330 tr("Cannot register the image '%s' with UUID {%RTuuid} because a %s already exists in the media registry ('%s')"),3474 tr("Cannot register the image '%s' with UUID {%RTuuid} from '%s' because a %s already exists"), 3331 3475 strLocationFull.c_str(), 3332 3476 id.raw(), 3333 strConflict.c_str(),3334 m->strSettingsFilePath.c_str());3477 getRegistryPath(pMedium).c_str(), 3478 strConflict.c_str()); 3335 3479 3336 3480 // add to the collection 3337 all.getList().push_back( argImage);3481 all.getList().push_back(pMedium); 3338 3482 // access the list directly because we already locked the list above 3339 3483 3340 if (pfNeedsSaveSettings) 3341 *pfNeedsSaveSettings = true; 3484 if (pfNeedsGlobalSaveSettings) 3485 // global settings need saving only if the medium is to be saved in the global registry 3486 if (pMedium->getRegistryId() == m->uuidMediaRegistry) 3487 *pfNeedsGlobalSaveSettings = true; 3342 3488 3343 3489 return rc; … … 3349 3495 * @param argImage Image object to remove. 3350 3496 * @param argType Either DeviceType_DVD or DeviceType_Floppy. 3351 * @param pfNeeds SaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true3497 * @param pfNeedsGlobalSaveSettings Optional pointer to a bool that must have been initialized to false and that will be set to true 3352 3498 * by this function if the caller should invoke VirtualBox::saveSettings() because the global settings have changed. 3353 3499 * … … 3356 3502 HRESULT VirtualBox::unregisterImage(Medium *argImage, 3357 3503 DeviceType_T argType, 3358 bool *pfNeeds SaveSettings)3504 bool *pfNeedsGlobalSaveSettings) 3359 3505 { 3360 3506 AssertReturn(argImage != NULL, E_INVALIDARG); … … 3385 3531 HRESULT rc = S_OK; 3386 3532 3387 if (pfNeedsSaveSettings) 3388 *pfNeedsSaveSettings = true; 3533 if (pfNeedsGlobalSaveSettings) 3534 // global settings need saving only if the medium is to be saved in the global registry 3535 if (argImage->getRegistryId() == m->uuidMediaRegistry) 3536 *pfNeedsGlobalSaveSettings = true; 3389 3537 3390 3538 return rc; … … 3395 3543 * Called from Machine::Unregister(). 3396 3544 * @param pMachine 3545 * @param id UUID of the machine. Must be passed by caller because machine may be dead by this time. 3397 3546 * @return 3398 3547 */ 3399 HRESULT VirtualBox::unregisterMachine(Machine *pMachine) 3400 { 3401 const Guid &id = pMachine->getId(); 3402 3548 HRESULT VirtualBox::unregisterMachine(Machine *pMachine, 3549 const Guid &id) 3550 { 3403 3551 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3404 3552 -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r31596 r31615 1437 1437 <attribute name="DVDImages" type="IMedium" readonly="yes" safearray="yes"> 1438 1438 <desc> 1439 Array of CD/DVD image objects registered withthis VirtualBox instance.1439 Array of CD/DVD image objects currently in use by this VirtualBox instance. 1440 1440 </desc> 1441 1441 </attribute> … … 1443 1443 <attribute name="floppyImages" type="IMedium" readonly="yes" safearray="yes"> 1444 1444 <desc> 1445 Array of floppy image objects registered withthis VirtualBox instance.1445 Array of floppy image objects currently in use by this VirtualBox instance. 1446 1446 </desc> 1447 1447 </attribute> … … 1705 1705 created by one of the above methods. 1706 1706 1707 After the storage unit is successfully created, the medium gets 1708 remembered by this VirtualBox installation and will be accessible 1709 through the <link to="#findMedium"/> method. Remembered base medium 1710 are also returned as part of the <link to="#hardDisks"/> array. 1711 See <link to="IMedium" /> for more details. 1707 After the storage unit is successfully created, it will be 1708 accessible through the <link to="#findMedium"/> method and can 1709 be found in the <link to="#hardDisks"/> array. 1712 1710 1713 1711 The list of all storage formats supported by this VirtualBox … … 1749 1747 Opens a medium from an existing storage location. 1750 1748 1751 Once a medium has been opened, VirtualBox saves the medium in a media 1752 registry. Prior to VirtualBox 3.3, this registry had to be the global 1753 media registry in the VirtualBox.xml file, which was shared between 1754 all machines and made transporting machines from one host to another 1755 difficult. Now you can optionally specify an <link to="IMachine" /> 1756 instance, in which case the medium will be remembered in that machine's 1757 registry. This is the recommended procedure for machines created with 1758 VirtualBox 3.3 or later. <i>(not yet implemented)</i> 1749 Once a medium has been opened, it can be passed to other VirtualBox 1750 methods, in particular to <link to="IMachine::AttachDevice" />. 1759 1751 1760 1752 Depending on the given device type, the file at the storage location … … 1806 1798 <link to="IMedium::location"/>, IMedium and 1807 1799 <link to="ISystemProperties::defaultHardDiskFolder"/> for more details. 1800 1801 Prior to VirtualBox 3.3, opening a medium added it to a global media 1802 registry in the VirtualBox.xml file, which was shared between 1803 all machines and made transporting machines and their media from one 1804 host to another difficult. 1805 1806 Starting with VirtualBox 3.3, media are only added to a registry when 1807 they are attached to a machine. Machines created with VirtualBox 3.3 1808 or later can have their own media registry. As a result, a medium attached 1809 to such a machine will be remembered in that machine's XML settings file. 1810 Media attached to older machines will continue to be added to the global 1811 registry. 1808 1812 1809 1813 <result name="VBOX_E_FILE_ERROR"> … … 2751 2755 hard disk image. This means that on import the image will be copied and converted from the 2752 2756 "ovf" location to the "vbox" location; on export, this will be handled the other way round. 2753 On import, the target image will also be registered with VirtualBox.2754 2757 2755 2758 The matching item in the @a aExtraConfigValues[] array must contain a string of the following … … 4225 4228 This method is intended for managing storage devices in general while a 4226 4229 machine is powered off. It can be used to attach and detach fixed 4227 and removeable media. 4228 4229 Starting with VirtualBox 3.3, media no longer have to be globally 4230 registered before they can be attached to a virtual machine. For 4231 compatibility with machines created by older versions of VirtualBox 4232 and for greater flexibility with managing removable media, media 4233 can still be registered globally. As a result, there are now 4234 several variants of attaching media: 4230 and removeable media. The following kind of media can be attached 4231 to a machine: 4235 4232 4236 4233 <ul> 4237 <li>To directly attach a medium without first registering it 4238 globally, simply pass the file name of its storage unit in the 4239 @a medium string parameter. This works for all media formats 4240 supported by the <li to="VirtualBox::openMedium" /> method. 4241 The difference is that the medium will not be saved in the 4242 global media registry, but only with the machine settings 4243 XML file. For better portability of the machine as a whole, 4244 it is recommended to place the storage unit in the machine's 4245 folder as well. 4234 <li>For fixed and removable media, you can pass in a medium that was 4235 previously opened using <link to="VirtualBox::openMedium" />. 4246 4236 </li> 4247 4237 4248 <li>To attach a medium that has been globally registered using4249 <li to="VirtualBox::openMedium" />, call that method with the4250 full path of a storage unit. Then, retrieve the UUID of that4251 medium from its <link to="IMedium::id" /> attribute and pass4252 that UUID into this method. This way, the medium will be4253 saved in the global media registry in the VirtualBox.xml4254 settings file. This is still the recommended way to manage4255 removable media such as ISO and RAW files if they are to be4256 used by several virtual machines and the storage unit is not4257 located in the machine's directory.4258 </li>4259 4260 4238 <li>Only for storage devices supporting removable media (such as 4261 DVDs and floppies), you can also specify a n empty stringto4262 indicate an empty drive or the UUID of a host DVD or floppy4263 drive; those UUIDs can be obtained from <link to="IHost::DVDDrives"/>4264 a nd <link to="IHost::floppyDrives"/>.4239 DVDs and floppies), you can also specify a null pointer to 4240 indicate an empty drive or one of the medium objects listed 4241 in the <link to="IHost::DVDDrives" /> and <link to="IHost::floppyDrives"/> 4242 arrays to indicate a host drive. 4265 4243 For removeable devices, you can also use <link to="IMachine::mountMedium"/> 4266 4244 to change the media while the machine is running. … … 4326 4304 </param> 4327 4305 <param name="type" type="DeviceType" dir="in"> 4328 <desc>Device type of the attached device.</desc> 4329 </param> 4330 <param name="medium" type="wstring" dir="in"> 4331 <desc>Path of the storage unit or UUID of the medium or the UUID of a 4332 host drive to mount, or an empty string for an empty drive.</desc> 4306 <desc>Device type of the attached device. For media opened by 4307 <link to="IVirtualBox::openMedium" />, this must match the device type 4308 specified there.</desc> 4309 </param> 4310 <param name="medium" type="IMedium" dir="in"> 4311 <desc>Medium to mount or NULL for an empty drive.</desc> 4333 4312 </param> 4334 4313 </method> -
trunk/src/VBox/Main/include/MachineImpl.h
r31574 r31615 452 452 STDMETHOD(GetBootOrder)(ULONG aPosition, DeviceType_T *aDevice); 453 453 STDMETHOD(AttachDevice)(IN_BSTR aControllerName, LONG aControllerPort, 454 LONG aDevice, DeviceType_T aType, I N_BSTR aId);454 LONG aDevice, DeviceType_T aType, IMedium *aMedium); 455 455 STDMETHOD(DetachDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice); 456 456 STDMETHOD(PassthroughDevice)(IN_BSTR aControllerName, LONG aControllerPort, LONG aDevice, BOOL aPassthrough); … … 1018 1018 MediumLockList *aMediumLockList, 1019 1019 ComObjPtr<Progress> &aProgress, 1020 bool *pfNeeds SaveSettings);1020 bool *pfNeedsMachineSaveSettings); 1021 1021 1022 1022 HRESULT lockMedia(); -
trunk/src/VBox/Main/include/MediumImpl.h
r31568 r31615 72 72 const Utf8Str &aFormat, 73 73 const Utf8Str &aLocation, 74 bool *pfNeedsSaveSettings); 74 const Guid &uuidMachineRegistry, 75 bool *pfNeedsGlobalSaveSettings); 75 76 76 77 // initializer for opening existing media 77 // (VirtualBox::Open HardDisk/DVD(); Machine::AttachDevice())78 // (VirtualBox::OpenMedium(); Machine::AttachDevice()) 78 79 HRESULT init(VirtualBox *aVirtualBox, 79 80 const Utf8Str &aLocation, … … 85 86 Medium *aParent, 86 87 DeviceType_T aDeviceType, 88 const Guid &uuidMachineRegistry, 87 89 const settings::Medium &data); 88 90 … … 176 178 Utf8Str getName(); 177 179 180 void setRegistryIdIfFirst(const Guid& id); 181 const Guid& getRegistryId() const; 182 178 183 HRESULT addBackReference(const Guid &aMachineId, 179 184 const Guid &aSnapshotId = Guid::Empty); … … 208 213 ComObjPtr<Progress> *aProgress, 209 214 bool aWait, 210 bool *pfNeeds SaveSettings);211 212 HRESULT close(bool *pfNeeds SaveSettings, AutoCaller &autoCaller);213 HRESULT deleteStorage(ComObjPtr<Progress> *aProgress, bool aWait, bool *pfNeeds SaveSettings);215 bool *pfNeedsGlobalSaveSettings); 216 217 HRESULT close(bool *pfNeedsGlobalSaveSettings, AutoCaller &autoCaller); 218 HRESULT deleteStorage(ComObjPtr<Progress> *aProgress, bool aWait, bool *pfNeedsGlobalSaveSettings); 214 219 HRESULT markForDeletion(); 215 220 HRESULT unmarkForDeletion(); … … 232 237 ComObjPtr<Progress> *aProgress, 233 238 bool aWait, 234 bool *pfNeeds SaveSettings);239 bool *pfNeedsGlobalSaveSettings); 235 240 void cancelMergeTo(const MediaList &aChildrenToReparent, 236 241 MediumLockList *aMediumLockList); … … 246 251 247 252 HRESULT canClose(); 248 HRESULT unregisterWithVirtualBox(bool *pfNeeds SaveSettings);253 HRESULT unregisterWithVirtualBox(bool *pfNeedsGlobalSaveSettings); 249 254 250 255 HRESULT setStateError(); … … 297 302 298 303 HRESULT startThread(Medium::Task *pTask); 299 HRESULT runNow(Medium::Task *pTask, bool *pfNeeds SaveSettings);304 HRESULT runNow(Medium::Task *pTask, bool *pfNeedsGlobalSaveSettings); 300 305 301 306 HRESULT taskCreateBaseHandler(Medium::CreateBaseTask &task); -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r31595 r31615 54 54 { 55 55 class MainConfigFile; 56 class MediaRegistry; 56 57 } 57 58 … … 96 97 HRESULT init(); 97 98 HRESULT initMachines(); 98 HRESULT initMedia(); 99 HRESULT initMedia(const Guid &uuidMachineRegistry, 100 const settings::MediaRegistry mediaRegistry); 99 101 void uninit(); 100 102 … … 127 129 STDMETHOD(CreateAppliance) (IAppliance **anAppliance); 128 130 129 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, IN_BSTR aLocation, 130 IMedium **aHardDisk); 131 STDMETHOD(CreateHardDisk)(IN_BSTR aFormat, 132 IN_BSTR aLocation, 133 IMedium **aHardDisk); 131 134 STDMETHOD(OpenMedium)(IN_BSTR aLocation, 132 135 DeviceType_T deviceType, … … 204 207 InternalControlList *aControls = NULL); 205 208 206 HRESULT findMachine 207 208 209 209 HRESULT findMachine(const Guid &aId, 210 bool fPermitInaccessible, 211 bool aSetError, 212 ComObjPtr<Machine> *machine = NULL); 210 213 211 214 HRESULT findHardDisk(const Guid *aId, … … 226 229 GuestOSType*& pGuestOSType); 227 230 231 const Guid& getGlobalRegistryId() const; 232 228 233 const ComObjPtr<Host>& host() const; 229 234 SystemProperties* getSystemProperties() const; … … 242 247 void copyPathRelativeToConfig(const Utf8Str &strSource, Utf8Str &strTarget); 243 248 244 HRESULT registerHardDisk(Medium *aHardDisk, bool *pfNeeds SaveSettings);245 HRESULT unregisterHardDisk(Medium *aHardDisk, bool *pfNeeds SaveSettings);246 247 HRESULT registerImage(Medium *aImage, DeviceType_T argType, bool *pfNeeds SaveSettings);248 HRESULT unregisterImage(Medium *aImage, DeviceType_T argType, bool *pfNeeds SaveSettings);249 250 HRESULT unregisterMachine(Machine *pMachine );249 HRESULT registerHardDisk(Medium *aHardDisk, bool *pfNeedsGlobalSaveSettings); 250 HRESULT unregisterHardDisk(Medium *aHardDisk, bool *pfNeedsGlobalSaveSettings); 251 252 HRESULT registerImage(Medium *aImage, DeviceType_T argType, bool *pfNeedsGlobalSaveSettings); 253 HRESULT unregisterImage(Medium *aImage, DeviceType_T argType, bool *pfNeedsGlobalSaveSettings); 254 255 HRESULT unregisterMachine(Machine *pMachine, const Guid &id); 251 256 252 257 void rememberMachineNameChangeForMedia(const Utf8Str &strOldConfigDir, 253 258 const Utf8Str &strNewConfigDir); 254 259 260 void saveMediaRegistry(settings::MediaRegistry &mediaRegistry, 261 const Guid &uuidRegistry); 255 262 HRESULT saveSettings(); 256 263 … … 271 278 } 272 279 280 Utf8Str getRegistryPath(Medium *pMedium); 281 273 282 HRESULT checkMediaForConflicts2(const Guid &aId, const Utf8Str &aLocation, 274 283 Utf8Str &aConflictType); -
trunk/src/VBox/Main/testcase/tstVBoxAPILinux.cpp
r31568 r31615 330 330 { 331 331 /* 332 * Now that it's created, we can assign it to the VM. This is done 333 * by UUID, so query that one fist. The UUID has been assigned automatically 334 * when we've created the image. 332 * Now that it's created, we can assign it to the VM. 335 333 */ 336 nsXPIDLString vdiUUID;337 hardDisk->GetId(getter_Copies(vdiUUID));338 334 rc = machine->AttachDevice(NS_LITERAL_STRING("IDE Controller").get(), // controller identifier 339 335 0, // channel number on the controller 340 336 0, // device number on the controller 341 337 DeviceType_HardDisk, 342 vdiUUID);338 hardDisk); 343 339 if (NS_FAILED(rc)) 344 340 { -
trunk/src/VBox/Main/xml/Settings.cpp
r31539 r31615 1742 1742 1743 1743 /** 1744 * Public routine which returns true if this machine config file can have its 1745 * own media registry (which is true for settings version v1.11 and higher, 1746 * i.e. files created by VirtualBox 3.3 and higher). 1747 * @return 1748 */ 1749 bool MachineConfigFile::canHaveOwnMediaRegistry() const 1750 { 1751 return (m->sv >= SettingsVersion_v1_11); 1752 } 1753 1754 /** 1744 1755 * Public routine which allows for importing machine XML from an external DOM tree. 1745 1756 * Use this after having called the constructor with a NULL argument. … … 3097 3108 pelmMachineChild->getAttributeValue("password", machineUserData.strTeleporterPassword); 3098 3109 } 3110 else if (pelmMachineChild->nameEquals("MediaRegistry")) 3111 readMediaRegistry(*pelmMachineChild, mediaRegistry); 3099 3112 } 3100 3113 … … 3998 4011 } 3999 4012 4013 if ( (fl & BuildMachineXML_MediaRegistry) 4014 && (m->sv >= SettingsVersion_v1_11) 4015 ) 4016 buildMediaRegistry(elmMachine, mediaRegistry); 4017 4000 4018 buildExtraData(elmMachine, mapExtraDataItems); 4001 4019 … … 4009 4027 !!(fl & BuildMachineXML_SkipRemovableMedia), 4010 4028 pllElementsWithUuidAttributes); 4011 4012 if ( (fl & BuildMachineXML_MediaRegistry)4013 && (m->sv >= SettingsVersion_v1_11)4014 )4015 buildMediaRegistry(elmMachine, mediaRegistry);4016 4029 } 4017 4030
Note:
See TracChangeset
for help on using the changeset viewer.