Changeset 108046 in vbox for trunk/src/VBox/Main
- Timestamp:
- Feb 4, 2025 5:24:54 AM (2 weeks ago)
- svn:sync-xref-src-repo-rev:
- 167323
- Location:
- trunk/src/VBox/Main
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/idl/VirtualBox.xidl
r107930 r108046 2764 2764 <interface 2765 2765 name="IVirtualBox" extends="$unknown" 2766 uuid=" d644ad1e-c501-4fc7-9ab6-aa6d763bc540"2766 uuid="2ce10519-3c09-45d8-a12d-e887786146b7" 2767 2767 wsmap="managed" 2768 2768 rest="managed" … … 2952 2952 <link to="#createSharedFolder"/>. Existing shared folders can be 2953 2953 removed using <link to="#removeSharedFolder"/>. 2954 2955 <note>2956 In the current version of the product, global shared folders are not2957 implemented and therefore this collection is always empty.2958 </note>2959 2954 </desc> 2960 2955 </attribute> … … 3630 3625 folders and starts sharing it. Refer to the description of 3631 3626 <link to="ISharedFolder"/> to read more about logical names. 3632 <note> 3633 In the current implementation, this operation is not 3634 implemented. 3635 </note> 3627 3628 <result name="VBOX_E_OBJECT_IN_USE"> 3629 Shared folder already exists. 3630 </result> 3631 <result name="VBOX_E_FILE_ERROR"> 3632 Shared folder @a hostPath not accessible. 3633 </result> 3634 3636 3635 </desc> 3637 3636 <param name="name" type="wstring" dir="in"> … … 3662 3661 created by <link to="#createSharedFolder"/> from the collection of 3663 3662 shared folders and stops sharing it. 3664 <note> 3665 In the current implementation, this operation is not 3666 implemented. 3667 </note> 3663 3664 <result name="VBOX_E_OBJECT_NOT_FOUND"> 3665 Shared folder @a name does not exist. 3666 </result> 3667 3668 3668 </desc> 3669 3669 <param name="name" type="wstring" dir="in"> … … 24717 24717 are in different name spaces, so they don't overlap and don't need to 24718 24718 have unique logical names. 24719 24720 <note>24721 Global shared folders are not implemented in the current version of the24722 product.24723 </note>24724 24719 </desc> 24725 24720 -
trunk/src/VBox/Main/include/ConsoleSharedFolderImpl.h
r106061 r108046 53 53 HRESULT init(Console *aConsole, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, 54 54 bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError); 55 // 56 // bool aWritable, const com::Utf8Str &aAutoMountPoint, bool aAutoMount, bool fFailOnError);55 // HRESULT init(VirtualBox *aVirtualBox, const Utf8Str &aName, const Utf8Str &aHostPath, 56 // bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError); 57 57 void uninit(); 58 58 -
trunk/src/VBox/Main/include/MachineImpl.h
r107526 r108046 566 566 virtual HRESULT i_onCPUExecutionCapChange(ULONG /* aExecutionCap */) { return S_OK; } 567 567 virtual HRESULT i_onMediumChange(IMediumAttachment * /* mediumAttachment */, BOOL /* force */) { return S_OK; } 568 virtual HRESULT i_onSharedFolderChange( ) { return S_OK; }568 virtual HRESULT i_onSharedFolderChange(BOOL /* aGlobal */) { return S_OK; } 569 569 virtual HRESULT i_onVMProcessPriorityChange(VMProcPriority_T /* aPriority */) { return S_OK; } 570 570 virtual HRESULT i_onClipboardModeChange(ClipboardMode_T /* aClipboardMode */) { return S_OK; } … … 1408 1408 HRESULT i_onUSBDeviceDetach(IN_BSTR aId, 1409 1409 IVirtualBoxErrorInfo *aError); 1410 HRESULT i_onSharedFolderChange( ) RT_OVERRIDE;1410 HRESULT i_onSharedFolderChange(BOOL aGlobal) RT_OVERRIDE; 1411 1411 HRESULT i_onClipboardModeChange(ClipboardMode_T aClipboardMode) RT_OVERRIDE; 1412 1412 HRESULT i_onClipboardFileTransferModeChange(BOOL aEnable) RT_OVERRIDE; -
trunk/src/VBox/Main/include/SharedFolderImpl.h
r106061 r108046 37 37 class Console; 38 38 39 namespace settings 40 { 41 struct SharedFolder; 42 } 43 39 44 class ATL_NO_VTABLE SharedFolder : 40 45 public SharedFolderWrap … … 54 59 // HRESULT init(Console *aConsole, const com::Utf8Str &aName, const com::Utf8Str &aHostPath, 55 60 // bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError); 56 // HRESULT init(VirtualBox *aVirtualBox, const Utf8Str &aName, const Utf8Str &aHostPath, 57 // bool aWritable, const com::Utf8Str &aAutoMountPoint, bool aAutoMount, bool fFailOnError); 61 HRESULT init(VirtualBox *aVirtualBox, const Utf8Str &aName, const Utf8Str &aHostPath, 62 bool aWritable, bool aAutoMount, const com::Utf8Str &aAutoMountPoint, bool fFailOnError, 63 SymlinkPolicy_T enmSymlinkPolicy); 64 HRESULT init(VirtualBox *aVirtualBox, const settings::SharedFolder &rData); 58 65 void uninit(); 66 HRESULT i_saveSettings(settings::SharedFolder &data); 59 67 60 68 // public methods for internal purposes only -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r107239 r108046 171 171 void i_onMediumConfigChanged(IMedium *aMedium); 172 172 void i_onMediumChanged(IMediumAttachment* aMediumAttachment); 173 void i_onSharedFolderChanged(); 173 174 void i_onStorageControllerChanged(const Guid &aMachineId, const com::Utf8Str &aControllerName); 174 175 void i_onStorageDeviceChanged(IMediumAttachment* aStorageDevice, BOOL fRemoved, BOOL fSilent); … … 270 271 bool aSetError, 271 272 ComObjPtr<Medium> &pMedium); 273 HRESULT i_findSharedFolder(const Utf8Str &aName, 274 ComPtr<ISharedFolder> &aSharedFolder); 272 275 273 276 HRESULT i_findGuestOSType(const Utf8Str &strOSType, -
trunk/src/VBox/Main/src-all/SharedFolderImpl.cpp
r106061 r108046 167 167 } 168 168 169 # if 0170 169 171 170 /** 172 171 * Initializes the shared folder object. 173 172 * 174 * This variant initializes a global instance that lives in the server address space. It is not presently used.173 * This variant initializes a global instance that lives in the server address space. 175 174 * 176 175 * @param aVirtualBox VirtualBox parent object … … 178 177 * @param aHostPath full path to the shared folder on the host 179 178 * @param aWritable writable if true, readonly otherwise 179 * @param aAutoMount if auto mounted by guest true, false otherwise 180 180 * @param aAutoMountPoint Where the guest should try auto mount it. 181 181 * @param fFailOnError Whether to fail with an error if the shared folder path is bad. 182 * @param enmSymlinkPolicy The symbolic link creation policy to apply. 182 183 * 183 184 * @return COM result indicator … … 189 190 bool aAutoMount, 190 191 const Utf8Str &aAutoMountPoint, 191 bool fFailOnError) 192 bool fFailOnError, 193 SymlinkPolicy_T enmSymlinkPolicy) 192 194 { 193 195 /* Enclose the state transition NotReady->InInit->Ready */ … … 197 199 unconst(mVirtualBox) = aVirtualBox; 198 200 199 HRESULT hrc = protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError); 201 HRESULT hrc = i_protectedInit(aVirtualBox, aName, aHostPath, aWritable, aAutoMount, aAutoMountPoint, fFailOnError, 202 enmSymlinkPolicy); 200 203 201 204 /* Confirm a successful initialization when it's the case */ … … 206 209 } 207 210 208 # endif 211 /** 212 * Initializes the shared folder object. 213 * 214 * This variant initializes a global instance that lives in the server address space. 215 * 216 * @param aVirtualBox VirtualBox parent object 217 * @param rData Settings shared folder 218 * 219 * @return COM result indicator 220 */ 221 HRESULT SharedFolder::init(VirtualBox *aVirtualBox, const settings::SharedFolder &rData) 222 { 223 /* Enclose the state transition NotReady->InInit->Ready */ 224 AutoInitSpan autoInitSpan(this); 225 AssertReturn(autoInitSpan.isOk(), E_FAIL); 226 227 unconst(mVirtualBox) = aVirtualBox; 228 HRESULT hrc = i_protectedInit(aVirtualBox, rData.strName, rData.strHostPath, 229 rData.fWritable, rData.fAutoMount, rData.strAutoMountPoint, 230 false, rData.enmSymlinkPolicy); 231 232 /* Confirm a successful initialization or not: */ 233 if (SUCCEEDED(hrc)) 234 autoInitSpan.setSucceeded(); 235 else 236 autoInitSpan.setFailed(hrc); 237 return hrc; 238 } 239 209 240 210 241 /** … … 301 332 } 302 333 334 HRESULT SharedFolder::i_saveSettings(settings::SharedFolder &data) 335 { 336 AutoCaller autoCaller(this); 337 if (FAILED(autoCaller.hrc())) return autoCaller.hrc(); 338 339 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 340 AssertReturn(!m->strName.isEmpty(), E_FAIL); 341 data.strName = m->strName; 342 data.strHostPath = m->strHostPath; 343 data.fWritable = m->fWritable != FALSE; 344 data.fAutoMount = m->fAutoMount != FALSE; 345 data.strAutoMountPoint = m->strAutoMountPoint; 346 data.enmSymlinkPolicy = m->enmSymlinkPolicy; 347 348 return S_OK; 349 } 350 303 351 // wrapped ISharedFolder properties 304 352 ///////////////////////////////////////////////////////////////////////////// -
trunk/src/VBox/Main/src-client/ConsoleImpl.cpp
r107843 r108046 3354 3354 return hrc; 3355 3355 3356 /* first, removethe machine or the global folder if there is any */3356 /* second, add the machine or the global folder if there is any */ 3357 3357 SharedFolderDataMap::const_iterator it; 3358 3358 if (i_findOtherSharedFolder(aName, it)) … … 9479 9479 if (aGlobal) 9480 9480 { 9481 /// @todo grab & process global folders when they are done 9481 SharedFolderDataMap oldFolders; 9482 oldFolders = m_mapGlobalSharedFolders; 9483 9484 m_mapGlobalSharedFolders.clear(); 9485 9486 ComPtr<IVirtualBox> ptrVirtualBox; 9487 hrc = mMachine->COMGETTER(Parent)(ptrVirtualBox.asOutParam()); 9488 if (FAILED(hrc)) throw hrc; 9489 SafeIfaceArray<ISharedFolder> folders; 9490 hrc = ptrVirtualBox->COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders)); 9491 if (FAILED(hrc)) throw hrc; 9492 9493 for (size_t i = 0; i < folders.size(); ++i) 9494 { 9495 ComPtr<ISharedFolder> pSharedFolder = folders[i]; 9496 9497 Bstr bstr; 9498 hrc = pSharedFolder->COMGETTER(Name)(bstr.asOutParam()); 9499 if (FAILED(hrc)) throw hrc; 9500 Utf8Str strName(bstr); 9501 9502 hrc = pSharedFolder->COMGETTER(HostPath)(bstr.asOutParam()); 9503 if (FAILED(hrc)) throw hrc; 9504 Utf8Str strHostPath(bstr); 9505 9506 BOOL writable; 9507 hrc = pSharedFolder->COMGETTER(Writable)(&writable); 9508 if (FAILED(hrc)) throw hrc; 9509 9510 BOOL autoMount; 9511 hrc = pSharedFolder->COMGETTER(AutoMount)(&autoMount); 9512 if (FAILED(hrc)) throw hrc; 9513 9514 hrc = pSharedFolder->COMGETTER(AutoMountPoint)(bstr.asOutParam()); 9515 if (FAILED(hrc)) throw hrc; 9516 Utf8Str strAutoMountPoint(bstr); 9517 9518 m_mapGlobalSharedFolders.insert(std::make_pair(strName, 9519 SharedFolderData(strHostPath, !!writable, 9520 !!autoMount, strAutoMountPoint))); 9521 9522 /* send changes to HGCM if the VM is running */ 9523 if (online) 9524 { 9525 SharedFolderDataMap::iterator it = oldFolders.find(strName); 9526 if ( it == oldFolders.end() 9527 || it->second.m_strHostPath != strHostPath) 9528 { 9529 /* a new global folder is added or 9530 * the existing global folder is changed */ 9531 if (m_mapSharedFolders.find(strName) != m_mapSharedFolders.end()) 9532 ; /* the console folder exists, nothing to do */ 9533 else if (m_mapMachineSharedFolders.find(strName) != m_mapMachineSharedFolders.end()) 9534 ; /* the machine folder exists, nothing to do */ 9535 else 9536 { 9537 /* remove the old global folder (when changed) */ 9538 if (it != oldFolders.end()) 9539 { 9540 hrc = i_removeSharedFolder(strName); 9541 if (FAILED(hrc)) throw hrc; 9542 } 9543 9544 /* create the new global folder */ 9545 hrc = i_createSharedFolder(strName, 9546 SharedFolderData(strHostPath, !!writable, !!autoMount, strAutoMountPoint)); 9547 if (FAILED(hrc)) throw hrc; 9548 } 9549 } 9550 /* forget the processed (or identical) folder */ 9551 if (it != oldFolders.end()) 9552 oldFolders.erase(it); 9553 } 9554 } 9555 9556 /* process outdated (removed) folders */ 9557 if (online) 9558 { 9559 for (SharedFolderDataMap::const_iterator it = oldFolders.begin(); 9560 it != oldFolders.end(); ++it) 9561 { 9562 if (m_mapSharedFolders.find(it->first) != m_mapSharedFolders.end()) 9563 ; /* the console folder exists, nothing to do */ 9564 else if (m_mapMachineSharedFolders.find(it->first) != m_mapMachineSharedFolders.end()) 9565 ; /* the machine folder exists, nothing to do */ 9566 else 9567 { 9568 /* remove the outdated global folder */ 9569 hrc = i_removeSharedFolder(it->first); 9570 if (FAILED(hrc)) throw hrc; 9571 } 9572 } 9573 } 9482 9574 } 9483 9575 else … … 9617 9709 return true; 9618 9710 9619 /* second, search machinefolders */9711 /* second, search global folders */ 9620 9712 aIt = m_mapGlobalSharedFolders.find(strName); 9621 9713 if (aIt != m_mapGlobalSharedFolders.end()) -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r107598 r108046 5053 5053 /* inform the direct session if any */ 5054 5054 alock.release(); 5055 i_onSharedFolderChange( );5055 i_onSharedFolderChange(FALSE); 5056 5056 5057 5057 return S_OK; … … 5075 5075 /* inform the direct session if any */ 5076 5076 alock.release(); 5077 i_onSharedFolderChange( );5077 i_onSharedFolderChange(FALSE); 5078 5078 5079 5079 return S_OK; … … 11786 11786 11787 11787 if (flModifications & IsModified_SharedFolders) 11788 that->i_onSharedFolderChange( );11788 that->i_onSharedFolderChange(FALSE); 11789 11789 11790 11790 if (flModifications & IsModified_VRDEServer) … … 14331 14331 * @note Locks this object for reading. 14332 14332 */ 14333 HRESULT SessionMachine::i_onSharedFolderChange( )14333 HRESULT SessionMachine::i_onSharedFolderChange(BOOL aGlobal) 14334 14334 { 14335 14335 LogFlowThisFunc(("\n")); … … 14349 14349 return S_OK; 14350 14350 14351 return directControl->OnSharedFolderChange( FALSE /* aGlobal */);14351 return directControl->OnSharedFolderChange(aGlobal); 14352 14352 } 14353 14353 -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r107754 r108046 819 819 } 820 820 821 for (settings::SharedFoldersList::const_iterator it = m->pMainConfigFile->llGlobalSharedFolders.begin(); 822 it != m->pMainConfigFile->llGlobalSharedFolders.end(); 823 ++it) 824 { 825 const settings::SharedFolder &sf = *it; 826 ComObjPtr<SharedFolder> pSharedFolder; 827 hrc = pSharedFolder.createObject(); 828 AssertComRCThrowRC(hrc); 829 hrc = pSharedFolder->init(this, sf); 830 if (FAILED(hrc)) throw hrc; 831 832 AutoWriteLock alock(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 833 m->allSharedFolders.addChild(pSharedFolder); 834 alock.release(); 835 } 836 821 837 /* net services - nat networks */ 822 838 for (settings::NATNetworksList::const_iterator it = m->pMainConfigFile->llNATNetworks.begin(); … … 1502 1518 HRESULT VirtualBox::getSharedFolders(std::vector<ComPtr<ISharedFolder> > &aSharedFolders) 1503 1519 { 1504 NOREF(aSharedFolders); 1505 1506 return setError(E_NOTIMPL, tr("Not yet implemented")); 1520 AutoReadLock al(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 1521 aSharedFolders.resize(m->allSharedFolders.size()); 1522 size_t i = 0; 1523 for (SharedFoldersOList::const_iterator it= m->allSharedFolders.begin(); 1524 it!= m->allSharedFolders.end(); ++it, ++i) 1525 (*it).queryInterfaceTo(aSharedFolders[i].asOutParam()); 1526 return S_OK; 1507 1527 } 1508 1528 … … 2780 2800 const com::Utf8Str &aAutoMountPoint) 2781 2801 { 2782 NOREF(aName); 2783 NOREF(aHostPath); 2784 NOREF(aWritable); 2785 NOREF(aAutomount); 2786 NOREF(aAutoMountPoint); 2787 2788 return setError(E_NOTIMPL, tr("Not yet implemented")); 2802 LogFlowThisFunc(("Entering for '%s' -> '%s'\n", aName.c_str(), aHostPath.c_str())); 2803 2804 ComPtr<ISharedFolder> found; 2805 HRESULT hrc = i_findSharedFolder(aName, found); 2806 if (SUCCEEDED(hrc)) 2807 return setError(VBOX_E_OBJECT_IN_USE, 2808 tr("Shared folder named '%s' already exists"), 2809 aName.c_str()); 2810 2811 ComObjPtr<SharedFolder> sharedFolder; 2812 SymlinkPolicy_T enmSymlinkPolicy = SymlinkPolicy_None; 2813 sharedFolder.createObject(); 2814 hrc = sharedFolder->init(this, 2815 aName, 2816 aHostPath, 2817 !!aWritable, 2818 !!aAutomount, 2819 aAutoMountPoint, 2820 true /* fFailOnError */, 2821 enmSymlinkPolicy); 2822 if (FAILED(hrc)) return hrc; 2823 2824 AutoWriteLock alock(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2825 m->allSharedFolders.addChild(sharedFolder); 2826 alock.release(); 2827 { 2828 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS); 2829 hrc = i_saveSettings(); 2830 vboxLock.release(); 2831 2832 if (FAILED(hrc)) 2833 { 2834 alock.acquire(); 2835 m->allSharedFolders.removeChild(sharedFolder); 2836 alock.release(); 2837 } 2838 } 2839 2840 i_onSharedFolderChanged(); 2841 LogFlowThisFunc(("Leaving for '%s' -> '%s'\n", aName.c_str(), aHostPath.c_str())); 2842 return hrc; 2789 2843 } 2790 2844 2791 2845 HRESULT VirtualBox::removeSharedFolder(const com::Utf8Str &aName) 2792 2846 { 2793 NOREF(aName); 2794 return setError(E_NOTIMPL, tr("Not yet implemented")); 2847 LogFlowThisFunc(("Entering for '%s'\n", aName.c_str())); 2848 2849 ComPtr<ISharedFolder> sharedFolder; 2850 HRESULT hrc = i_findSharedFolder(aName, sharedFolder); 2851 if (FAILED(hrc)) 2852 return hrc; 2853 2854 ISharedFolder *aP = sharedFolder; 2855 SharedFolder *aP2 = static_cast<SharedFolder *>(aP); 2856 AutoWriteLock alock(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2857 m->allSharedFolders.removeChild(aP2); 2858 alock.release(); 2859 2860 { 2861 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS); 2862 hrc = i_saveSettings(); 2863 vboxLock.release(); 2864 2865 if (FAILED(hrc)) 2866 { 2867 alock.acquire(); 2868 m->allSharedFolders.addChild(aP2); 2869 alock.release(); 2870 } 2871 } 2872 2873 i_onSharedFolderChanged(); 2874 LogFlowThisFunc(("Leaving for '%s'\n", aName.c_str())); 2875 2876 return hrc; 2795 2877 } 2796 2878 … … 3622 3704 AssertComRCReturnVoid(hrc); 3623 3705 i_postEvent(new AsyncEvent(this, ptrEvent)); 3706 } 3707 3708 /** 3709 * @note Locks this object for reading. 3710 */ 3711 void VirtualBox::i_onSharedFolderChanged() 3712 { 3713 LogFlowThisFunc(("\n")); 3714 3715 AutoCaller autoCaller(this); 3716 AssertComRCReturnVoid(autoCaller.hrc()); 3717 3718 SessionMachinesList aMachines; 3719 i_getOpenedMachines(aMachines, NULL); 3720 for (SessionMachinesList::iterator it = aMachines.begin(); 3721 it != aMachines.end(); 3722 ++it) 3723 { 3724 ComObjPtr<SessionMachine> &pMachine = *it; 3725 AutoReadLock mlock(pMachine COMMA_LOCKVAL_SRC_POS); 3726 pMachine->i_onSharedFolderChange(TRUE); 3727 } 3728 aMachines.clear(); 3624 3729 } 3625 3730 … … 4555 4660 } 4556 4661 4662 /** 4663 * Searches for a shared folder with the given logical name 4664 * in the collection of shared folders. 4665 * 4666 * @param aName logical name of the shared folder 4667 * @param aSharedFolder where to return the found object 4668 * 4669 * @return S_OK, E_INVALIDARG or VBOX_E_OBJECT_NOT_FOUND when not found. 4670 * 4671 * @note must be called from under the object's lock 4672 */ 4673 HRESULT VirtualBox::i_findSharedFolder(const Utf8Str &aName, 4674 ComPtr<ISharedFolder> &aSharedFolder) 4675 { 4676 ComObjPtr<SharedFolder> found; 4677 4678 AutoReadLock alock(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 4679 4680 for (SharedFoldersOList::const_iterator it = m->allSharedFolders.begin(); 4681 it != m->allSharedFolders.end(); 4682 ++it) 4683 { 4684 Bstr bstrSharedFolderName; 4685 HRESULT hrc = (*it)->COMGETTER(Name)(bstrSharedFolderName.asOutParam()); 4686 if (FAILED(hrc)) return hrc; 4687 4688 if (Utf8Str(bstrSharedFolderName) == aName) 4689 { 4690 found = *it; 4691 break; 4692 } 4693 } 4694 if (!found) 4695 return VBOX_E_OBJECT_NOT_FOUND; 4696 return found.queryInterfaceTo(aSharedFolder.asOutParam()); 4697 } 4698 4557 4699 /* Look for a GuestOSType object */ 4558 4700 HRESULT VirtualBox::i_findGuestOSType(const Utf8Str &strOSType, … … 5244 5386 if (FAILED(hrc)) throw hrc; 5245 5387 m->pMainConfigFile->llDhcpServers.push_back(d); 5388 } 5389 } 5390 m->pMainConfigFile->llGlobalSharedFolders.clear(); 5391 { 5392 AutoReadLock sharedFolderLock(m->allSharedFolders.getLockHandle() COMMA_LOCKVAL_SRC_POS); 5393 for (SharedFoldersOList::const_iterator it = m->allSharedFolders.begin(); 5394 it != m->allSharedFolders.end(); 5395 ++it) 5396 { 5397 settings::SharedFolder sf; 5398 hrc = (*it)->i_saveSettings(sf); 5399 if (FAILED(hrc)) throw hrc; 5400 m->pMainConfigFile->llGlobalSharedFolders.push_back(sf); 5246 5401 } 5247 5402 } -
trunk/src/VBox/Main/xml/Settings.cpp
r107930 r108046 1648 1648 } 1649 1649 1650 /** 1651 * Constructor. Needs to set sane defaults which stand the test of time. 1652 */ 1653 SharedFolder::SharedFolder() : 1654 fWritable(false), 1655 fAutoMount(false), 1656 enmSymlinkPolicy(SymlinkPolicy_None) 1657 { 1658 } 1659 1660 /** 1661 * Comparison operator. This gets called from MachineConfigFile::operator==, 1662 * which in turn gets called from Machine::saveSettings to figure out whether 1663 * machine settings have really changed and thus need to be written out to disk. 1664 */ 1665 bool SharedFolder::operator==(const SharedFolder &g) const 1666 { 1667 return (this == &g) 1668 || ( strName == g.strName 1669 && strHostPath == g.strHostPath 1670 && fWritable == g.fWritable 1671 && fAutoMount == g.fAutoMount 1672 && strAutoMountPoint == g.strAutoMountPoint 1673 && enmSymlinkPolicy == g.enmSymlinkPolicy); 1674 } 1675 1650 1676 1651 1677 //////////////////////////////////////////////////////////////////////////////// … … 2098 2124 throw ConfigFileError(this, pelmNet, N_("Required NATNetwork/@networkName, @gateway, @network,@advertiseDefaultIpv6Route , @needDhcp or @enabled attribute is missing")); 2099 2125 } 2126 } 2127 } 2128 2129 /** 2130 * Reads in the \<SharedFolders\> chunk. 2131 * @param elmSharedFolders 2132 */ 2133 void MainConfigFile::readSharedFolders(const xml::ElementNode &elmSharedFolders) 2134 { 2135 xml::NodesLoop nl1(elmSharedFolders, "SharedFolder"); 2136 const xml::ElementNode *pelmFolder; 2137 while ((pelmFolder = nl1.forAllNodes())) 2138 { 2139 SharedFolder sf; 2140 pelmFolder->getAttributeValue("name", sf.strName); 2141 pelmFolder->getAttributeValue("hostPath", sf.strHostPath); 2142 pelmFolder->getAttributeValue("writable", sf.fWritable); 2143 pelmFolder->getAttributeValue("autoMount", sf.fAutoMount); 2144 pelmFolder->getAttributeValue("autoMountPoint", sf.strAutoMountPoint); 2145 2146 Utf8Str strTemp; 2147 if (pelmFolder->getAttributeValue("symlinkPolicy", strTemp)) 2148 { 2149 if (strTemp == "forbidden") 2150 sf.enmSymlinkPolicy = SymlinkPolicy_Forbidden; 2151 else if (strTemp == "subtree") 2152 sf.enmSymlinkPolicy = SymlinkPolicy_AllowedInShareSubtree; 2153 else if (strTemp == "relative") 2154 sf.enmSymlinkPolicy = SymlinkPolicy_AllowedToRelativeTargets; 2155 else if (strTemp == "any") 2156 sf.enmSymlinkPolicy = SymlinkPolicy_AllowedToAnyTarget; 2157 else 2158 throw ConfigFileError(this, 2159 pelmFolder, 2160 N_("Invalid value '%s' in SharedFolder/@symlinkPolicy attribute"), 2161 strTemp.c_str()); 2162 } 2163 llGlobalSharedFolders.push_back(sf); 2100 2164 } 2101 2165 } … … 2433 2497 } 2434 2498 } 2499 else if (pelmGlobalChild->nameEquals("SharedFolders")) 2500 readSharedFolders(*pelmGlobalChild); 2435 2501 else if (pelmGlobalChild->nameEquals("USBDeviceFilters")) 2436 2502 readUSBDeviceFilters(*pelmGlobalChild, host.llUSBDeviceFilters); … … 2508 2574 m->sv = SettingsVersion_v1_14; 2509 2575 } 2576 if (m->sv < SettingsVersion_v1_20) 2577 { 2578 // VirtualBox 7.1 adds global shared folders. 2579 if (!llGlobalSharedFolders.empty()) 2580 m->sv = SettingsVersion_v1_20; 2581 } 2582 2510 2583 } 2511 2584 … … 2623 2696 } 2624 2697 #endif /* VBOX_WITH_CLOUD_NET */ 2698 2699 xml::ElementNode *pelmSharedFolders = pelmGlobal->createChild("SharedFolders"); 2700 if (!llGlobalSharedFolders.empty()) 2701 { 2702 for (SharedFoldersList::const_iterator it = llGlobalSharedFolders.begin(); 2703 it != llGlobalSharedFolders.end(); 2704 ++it) 2705 { 2706 const SharedFolder &sf = *it; 2707 xml::ElementNode *pelmThis = pelmSharedFolders->createChild("SharedFolder"); 2708 pelmThis->setAttribute("name", sf.strName); 2709 pelmThis->setAttribute("hostPath", sf.strHostPath); 2710 pelmThis->setAttribute("writable", sf.fWritable); 2711 pelmThis->setAttribute("autoMount", sf.fAutoMount); 2712 if (sf.strAutoMountPoint.isNotEmpty()) 2713 pelmThis->setAttribute("autoMountPoint", sf.strAutoMountPoint); 2714 const char *pcszSymlinkPolicy; 2715 if (sf.enmSymlinkPolicy != SymlinkPolicy_None) 2716 { 2717 switch (sf.enmSymlinkPolicy) 2718 { 2719 default: /*case SymlinkPolicy_Forbidden:*/ pcszSymlinkPolicy = "forbidden"; break; 2720 case SymlinkPolicy_AllowedInShareSubtree: pcszSymlinkPolicy = "subtree"; break; 2721 case SymlinkPolicy_AllowedToRelativeTargets: pcszSymlinkPolicy = "relative"; break; 2722 case SymlinkPolicy_AllowedToAnyTarget: pcszSymlinkPolicy = "any"; break; 2723 } 2724 pelmThis->setAttribute("symlinkPolicy", pcszSymlinkPolicy); 2725 } 2726 2727 } 2728 } 2625 2729 2626 2730 #ifdef VBOX_WITH_UPDATE_AGENT … … 3789 3893 } 3790 3894 3791 /**3792 * Constructor. Needs to set sane defaults which stand the test of time.3793 */3794 SharedFolder::SharedFolder() :3795 fWritable(false),3796 fAutoMount(false),3797 enmSymlinkPolicy(SymlinkPolicy_None)3798 {3799 }3800 3801 /**3802 * Comparison operator. This gets called from MachineConfigFile::operator==,3803 * which in turn gets called from Machine::saveSettings to figure out whether3804 * machine settings have really changed and thus need to be written out to disk.3805 */3806 bool SharedFolder::operator==(const SharedFolder &g) const3807 {3808 return (this == &g)3809 || ( strName == g.strName3810 && strHostPath == g.strHostPath3811 && fWritable == g.fWritable3812 && fAutoMount == g.fAutoMount3813 && strAutoMountPoint == g.strAutoMountPoint3814 && enmSymlinkPolicy == g.enmSymlinkPolicy);3815 }3816 3895 3817 3896 /** -
trunk/src/VBox/Main/xml/VirtualBox-settings.xsd
r107930 r108046 571 571 </xsd:complexType> 572 572 </xsd:element> 573 <xsd:element name="SharedFolders" type="TSharedFolders" minOccurs="0"/> 573 574 <xsd:element name="USBDeviceFilters"> 574 575 <xsd:complexType>
Note:
See TracChangeset
for help on using the changeset viewer.