Changeset 74003 in vbox
- Timestamp:
- Aug 31, 2018 2:47:37 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/manual/en_US/user_VBoxManage.xml
r73740 r74003 5152 5152 [--compact] 5153 5153 [--resize <megabytes>|--resizebyte <bytes>] 5154 [--move <path></screen> 5154 [--move <path>] 5155 [--setlocation <path>]</screen> 5155 5156 5156 5157 <note> … … 5277 5278 </para> 5278 5279 </listitem> 5280 5281 <listitem> 5282 <para> 5283 The <computeroutput>--setlocation <path></computeroutput> 5284 option can be used to set new location <path> of the 5285 medium on the host file system if the medium had been moved 5286 for any reasons. The path can be either relative to the 5287 current directory or absolute. 5288 </para> 5289 5290 <para> 5291 Note, the new location is used as is, without any sanity checks, 5292 so user is responsible to set correct path. 5293 </para> 5294 </listitem> 5279 5295 5280 5296 </itemizedlist> -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageDisk.cpp
r73716 r74003 493 493 { "--resizebyte", 'R', RTGETOPT_REQ_UINT64 }, 494 494 { "--move", 'm', RTGETOPT_REQ_STRING }, 495 { "--setlocation", 'l', RTGETOPT_REQ_STRING }, 495 496 { "--description", 'd', RTGETOPT_REQ_STRING } 496 497 }; … … 517 518 bool fModifyResize = false; 518 519 bool fModifyResizeMB = false; 519 bool fMo difyLocation= false;520 bool fMoveMedium = false; 520 521 bool fModifyDescription = false; 522 bool fSetNewLocation = false; 521 523 uint64_t cbResize = 0; 522 524 const char *pszFilenameOrUuid = NULL; … … 615 617 /* Get a new location */ 616 618 pszNewLocation = RTPathAbsDup(ValueUnion.psz); 617 fModifyLocation = true; 619 fMoveMedium = true; 620 break; 621 622 case 'l': // --setlocation 623 /* Get a new location */ 624 pszNewLocation = RTPathAbsDup(ValueUnion.psz); 625 fSetNewLocation = true; 618 626 break; 619 627 … … 659 667 && !fModifyCompact 660 668 && !fModifyResize 661 && !fModifyLocation 662 && !fModifyDescription) 669 && !fMoveMedium 670 && !fSetNewLocation 671 && !fModifyDescription 672 ) 663 673 return errorSyntax(USAGE_MODIFYMEDIUM, "No operation specified"); 664 674 … … 766 776 } 767 777 768 if (fMo difyLocation)778 if (fMoveMedium) 769 779 { 770 780 do … … 773 783 Utf8Str strLocation(pszNewLocation); 774 784 RTStrFree(pszNewLocation); 775 CHECK_ERROR(pMedium, SetLocation(Bstr(strLocation).raw(), pProgress.asOutParam()));785 CHECK_ERROR(pMedium, MoveTo(Bstr(strLocation).raw(), pProgress.asOutParam())); 776 786 777 787 if (SUCCEEDED(rc) && !pProgress.isNull()) … … 784 794 CHECK_ERROR_BREAK(pMedium, COMGETTER(Id)(uuid.asOutParam())); 785 795 786 RTPrintf("Move medium with UUID %s finished 796 RTPrintf("Move medium with UUID %s finished\n", Utf8Str(uuid).c_str()); 787 797 } 788 798 while (0); 789 799 } 790 800 801 if (fSetNewLocation) 802 { 803 Utf8Str strLocation(pszNewLocation); 804 RTStrFree(pszNewLocation); 805 CHECK_ERROR(pMedium, COMSETTER(Location)(Bstr(strLocation).raw())); 806 807 Bstr uuid; 808 CHECK_ERROR(pMedium, COMGETTER(Id)(uuid.asOutParam())); 809 RTPrintf("Set new location of medium with UUID %s finished\n", Utf8Str(uuid).c_str()); 810 } 811 791 812 if (fModifyDescription) 792 813 { 793 814 CHECK_ERROR(pMedium, COMSETTER(Description)(Bstr(pszNewLocation).raw())); 794 815 795 RTPrintf("Medium description has been changed. 816 RTPrintf("Medium description has been changed.\n"); 796 817 } 797 818 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r73768 r74003 982 982 " [--compact]\n" 983 983 " [--resize <megabytes>|--resizebyte <bytes>]\n" 984 " [--move <path]\n" 984 " [--move <path>]\n" 985 " [--setlocation <path>]\n" 985 986 " [--description <description string>]" 986 987 "\n", SEP); -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumItem.cpp
r73953 r74003 88 88 { 89 89 /* Prepare move storage progress: */ 90 CProgress comProgress = comMedium. SetLocation(strFileName);90 CProgress comProgress = comMedium.MoveTo(strFileName); 91 91 92 92 /* Show error message if necessary: */ -
trunk/src/VBox/Frontends/VirtualBox/src/medium/UIMediumManager.cpp
r73953 r74003 310 310 { 311 311 /* Prepare move storage progress: */ 312 CProgress comProgress = comMedium. SetLocation(newData.m_options.m_strLocation);312 CProgress comProgress = comMedium.MoveTo(newData.m_options.m_strLocation); 313 313 314 314 /* Show error message if necessary: */ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r73971 r74003 15030 15030 <interface 15031 15031 name="IMedium" extends="$unknown" 15032 uuid=" c3a390cd-4efa-458d-2afb-d07eb4e105bb"15032 uuid="a570ac5b-d90d-42bb-b577-a3e2697044e4" 15033 15033 wsmap="managed" 15034 15034 reservedMethods="4" reservedAttributes="8" … … 15245 15245 </attribute> 15246 15246 15247 <attribute name="location" type="wstring" readonly="yes">15247 <attribute name="location" type="wstring"> 15248 15248 <desc> 15249 15249 Location of the storage unit holding medium data. … … 16160 16160 <!-- other methods --> 16161 16161 16162 <method name=" setLocation" wrap-hint-server="passcaller">16162 <method name="moveTo" wrap-hint-server="passcaller"> 16163 16163 <desc> 16164 16164 Changes the location of this medium. Some medium types may support -
trunk/src/VBox/Main/include/MediumImpl.h
r72999 r74003 239 239 HRESULT getVariant(std::vector<MediumVariant_T> &aVariant); 240 240 HRESULT getLocation(com::Utf8Str &aLocation); 241 HRESULT setLocation(const com::Utf8Str &aLocation); 241 242 HRESULT getName(com::Utf8Str &aName); 242 243 HRESULT getDeviceType(DeviceType_T *aDeviceType); … … 297 298 const std::vector<MediumVariant_T> &aVariant, 298 299 ComPtr<IProgress> &aProgress); 299 HRESULT setLocation(AutoCaller &autoCaller,300 301 300 HRESULT moveTo(AutoCaller &autoCaller, 301 const com::Utf8Str &aLocation, 302 ComPtr<IProgress> &aProgress); 302 303 HRESULT compact(ComPtr<IProgress> &aProgress); 303 304 HRESULT resize(LONG64 aLogicalSize, -
trunk/src/VBox/Main/src-server/MachineImplMoveVM.cpp
r73757 r74003 1103 1103 if (FAILED(rc)) throw rc; 1104 1104 1105 /* Drop lock early because IMedium:: SetLocationneeds to get the VirtualBox one. */1105 /* Drop lock early because IMedium::MoveTo needs to get the VirtualBox one. */ 1106 1106 machineLock.release(); 1107 1107 1108 1108 ComPtr<IProgress> moveDiskProgress; 1109 rc = pMedium-> SetLocation(bstrLocation.raw(), moveDiskProgress.asOutParam());1109 rc = pMedium->MoveTo(bstrLocation.raw(), moveDiskProgress.asOutParam()); 1110 1110 if (SUCCEEDED(rc)) 1111 1111 { -
trunk/src/VBox/Main/src-server/MediumImpl.cpp
r73858 r74003 2919 2919 } 2920 2920 2921 HRESULT Medium:: setLocation(AutoCaller &autoCaller, const com::Utf8Str &aLocation, ComPtr<IProgress> &aProgress)2921 HRESULT Medium::moveTo(AutoCaller &autoCaller, const com::Utf8Str &aLocation, ComPtr<IProgress> &aProgress) 2922 2922 { 2923 2923 ComObjPtr<Medium> pParent; … … 2930 2930 /// @todo NEWMEDIA for file names, add the default extension if no extension 2931 2931 /// is present (using the information from the VD backend which also implies 2932 /// that one more parameter should be passed to setLocation() requesting2932 /// that one more parameter should be passed to moveTo() requesting 2933 2933 /// that functionality since it is only allowed when called from this method 2934 2934 … … 3200 3200 } 3201 3201 3202 HRESULT Medium::setLocation(const com::Utf8Str &aLocation) 3203 { 3204 HRESULT rc = S_OK; 3205 3206 try 3207 { 3208 // locking: we need the tree lock first because we access parent pointers 3209 // and we need to write-lock the media involved 3210 AutoWriteLock treeLock(m->pVirtualBox->i_getMediaTreeLockHandle() COMMA_LOCKVAL_SRC_POS); 3211 3212 AutoCaller autoCaller(this); 3213 AssertComRCThrowRC(autoCaller.rc()); 3214 3215 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3216 3217 Utf8Str destPath(aLocation); 3218 3219 // some check for file based medium 3220 if (i_isMediumFormatFile()) 3221 { 3222 /* Path must be absolute */ 3223 if (!RTPathStartsWithRoot(destPath.c_str())) 3224 { 3225 rc = setError(VBOX_E_FILE_ERROR, 3226 tr("The given path '%s' is not fully qualified"), 3227 destPath.c_str()); 3228 throw rc; 3229 } 3230 3231 /* Simple check for existence */ 3232 if (!RTFileExists(destPath.c_str())) 3233 { 3234 rc = setError(VBOX_E_FILE_ERROR, 3235 tr("The given path '%s' is not an existing file. New location is invalid."), 3236 destPath.c_str()); 3237 throw rc; 3238 } 3239 } 3240 3241 /* Check VMs which have this medium attached to*/ 3242 std::vector<com::Guid> aMachineIds; 3243 rc = getMachineIds(aMachineIds); 3244 3245 // switch locks only if there are machines with this medium attached 3246 if (!aMachineIds.empty()) 3247 { 3248 std::vector<com::Guid>::const_iterator currMachineID = aMachineIds.begin(); 3249 std::vector<com::Guid>::const_iterator lastMachineID = aMachineIds.end(); 3250 3251 alock.release(); 3252 autoCaller.release(); 3253 treeLock.release(); 3254 3255 while (currMachineID != lastMachineID) 3256 { 3257 Guid id(*currMachineID); 3258 ComObjPtr<Machine> aMachine; 3259 rc = m->pVirtualBox->i_findMachine(id, false, true, &aMachine); 3260 if (SUCCEEDED(rc)) 3261 { 3262 ComObjPtr<SessionMachine> sm; 3263 ComPtr<IInternalSessionControl> ctl; 3264 3265 bool ses = aMachine->i_isSessionOpenVM(sm, &ctl); 3266 if (ses) 3267 { 3268 treeLock.acquire(); 3269 autoCaller.add(); 3270 AssertComRCThrowRC(autoCaller.rc()); 3271 alock.acquire(); 3272 3273 rc = setError(VERR_VM_UNEXPECTED_VM_STATE, 3274 tr("At least the VM '%s' to whom this medium '%s' attached has currently an opened session. Stop all VMs before set location for this medium"), 3275 id.toString().c_str(), 3276 i_getLocationFull().c_str()); 3277 throw rc; 3278 } 3279 } 3280 ++currMachineID; 3281 } 3282 3283 treeLock.acquire(); 3284 autoCaller.add(); 3285 AssertComRCThrowRC(autoCaller.rc()); 3286 alock.acquire(); 3287 } 3288 3289 m->strLocationFull = destPath; 3290 3291 // save the settings 3292 alock.release(); 3293 autoCaller.release(); 3294 treeLock.release(); 3295 3296 i_markRegistriesModified(); 3297 m->pVirtualBox->i_saveModifiedRegistries(); 3298 3299 MediumState_T mediumState; 3300 refreshState(autoCaller, &mediumState); 3301 } 3302 catch (HRESULT aRC) { rc = aRC; } 3303 3304 return rc; 3305 } 3306 3202 3307 HRESULT Medium::compact(ComPtr<IProgress> &aProgress) 3203 3308 { … … 8154 8259 8155 8260 /* The object may request a specific UUID (through a special form of 8156 * the setLocation() argument). Otherwise we have to generate it */8261 * the moveTo() argument). Otherwise we have to generate it */ 8157 8262 Guid id = m->id; 8158 8263 … … 8332 8437 8333 8438 /* The object may request a specific UUID (through a special form of 8334 * the setLocation() argument). Otherwise we have to generate it */8439 * the moveTo() argument). Otherwise we have to generate it */ 8335 8440 Guid targetId = pTarget->m->id; 8336 8441 … … 8880 8985 8881 8986 /* The object may request a specific UUID (through a special form of 8882 * the setLocation() argument). Otherwise we have to generate it */8987 * the moveTo() argument). Otherwise we have to generate it */ 8883 8988 Guid targetId = pTarget->m->id; 8884 8989 … … 9166 9271 * Implementation code for the "move" task. 9167 9272 * 9168 * This only gets started from Medium:: SetLocation() and always9273 * This only gets started from Medium::MoveTo() and always 9169 9274 * runs asynchronously. 9170 9275 * … … 9789 9894 9790 9895 /* The object may request a specific UUID (through a special form of 9791 * the setLocation() argument). Otherwise we have to generate it */9896 * the moveTo() argument). Otherwise we have to generate it */ 9792 9897 Guid targetId = m->id; 9793 9898 -
trunk/src/VBox/ValidationKit/testdriver/vbox.py
r73171 r74003 783 783 self.fImportedVBoxApi = False; 784 784 self.fpApiVer = 3.2; 785 self.uRevision = 0; 785 786 self.oBuild = None; 786 787 self.oVBoxMgr = None; … … 1318 1319 else: 1319 1320 self.fpApiVer += 1.1; 1321 1322 try: 1323 self.uRevision = oVBox.revision; 1324 except: 1325 reporter.logXcpt('Failed to get VirtualBox revision, assuming 0'); 1326 self.uRevision = 0; 1327 reporter.log("IVirtualBox.revision=%u" % (self.uRevision,)); 1320 1328 1321 1329 # Patch VBox manage to gloss over portability issues (error constants, etc). -
trunk/src/VBox/ValidationKit/tests/api/tdMoveMedium1.py
r72732 r74003 66 66 # 67 67 68 def setLocation(self, sLocation, aoMediumAttachments):68 def moveTo(self, sLocation, aoMediumAttachments): 69 69 for oAttachment in aoMediumAttachments: 70 70 try: … … 74 74 reporter.errorXcpt('failed to get the medium from the IMediumAttachment "%s"' % (oAttachment)) 75 75 76 try: 77 oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv, 78 'move "%s"' % (oMedium.name,)) 79 except: 80 return reporter.errorXcpt('Medium::setLocation("%s") for medium "%s" failed' % (sLocation, oMedium.name,)) 76 if self.oTstDrv.fpApiVer >= 5.3 and self.oTstDrv.uRevision > 124748: 77 try: 78 oProgress = vboxwrappers.ProgressWrapper(oMedium.moveTo(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv, 79 'move "%s"' % (oMedium.name,)); 80 except: 81 return reporter.errorXcpt('Medium::moveTo("%s") for medium "%s" failed' % (sLocation, oMedium.name,)); 82 else: 83 try: 84 oProgress = vboxwrappers.ProgressWrapper(oMedium.setLocation(sLocation), self.oTstDrv.oVBoxMgr, self.oTstDrv, 85 'move "%s"' % (oMedium.name,)); 86 except: 87 return reporter.errorXcpt('Medium::setLocation("%s") for medium "%s" failed' % (sLocation, oMedium.name,)); 88 81 89 82 90 oProgress.wait() … … 149 157 aoMediumAttachments = oVM.getMediumAttachmentsOfController(sController) 150 158 #case 1. Only path without file name, with trailing separator 151 fRc = self. setLocation(sNewLoc + os.sep, aoMediumAttachments) and fRc159 fRc = self.moveTo(sNewLoc + os.sep, aoMediumAttachments) and fRc 152 160 fRc = self.checkLocation(sNewLoc, aoMediumAttachments, asFiles) and fRc 153 161 154 162 #case 2. Only path without file name, without trailing separator 155 fRc = self. setLocation(sOrigLoc, aoMediumAttachments) and fRc163 fRc = self.moveTo(sOrigLoc, aoMediumAttachments) and fRc 156 164 fRc = self.checkLocation(sOrigLoc, aoMediumAttachments, asFiles) and fRc 157 165 … … 162 170 #and the file name is processed as folder name (aka mv(1) logic). 163 171 #Be discussed. 164 fRc = self. setLocation(os.path.join(sNewLoc, 'newName'), aoMediumAttachments) and fRc172 fRc = self.moveTo(os.path.join(sNewLoc, 'newName'), aoMediumAttachments) and fRc 165 173 asNewFiles = ['newName' + os.path.splitext(s)[1] for s in asFiles] 166 174 fRc = self.checkLocation(os.path.join(sNewLoc, 'newName'), aoMediumAttachments, asFiles) and fRc … … 170 178 171 179 #case 4. Only file name 172 fRc = self. setLocation('onlyMediumName', aoMediumAttachments) and fRc180 fRc = self.moveTo('onlyMediumName', aoMediumAttachments) and fRc 173 181 asNewFiles = ['onlyMediumName' + os.path.splitext(s)[1] for s in asFiles] 174 182 if self.oTstDrv.fpApiVer >= 5.3: … … 183 191 aoMediumAttachments = oVM.getMediumAttachmentsOfController(sController) 184 192 asSnapFiles = [os.path.basename(o.medium.name) for o in aoMediumAttachments] 185 fRc = self. setLocation(sOrigLoc, aoMediumAttachments) and fRc193 fRc = self.moveTo(sOrigLoc, aoMediumAttachments) and fRc 186 194 fRc = self.checkLocation(sOrigLoc, aoMediumAttachments, asSnapFiles) and fRc 187 195 -
trunk/src/VBox/ValidationKit/tests/api/tdMoveVM1.py
r72742 r74003 287 287 aoMediumAttachments = oMachine.getMediumAttachmentsOfController(sController) 288 288 oSubTstDrvMoveMedium1Instance = SubTstDrvMoveMedium1(self.oTstDrv) 289 oSubTstDrvMoveMedium1Instance. setLocation(sOldLoc, aoMediumAttachments)289 oSubTstDrvMoveMedium1Instance.moveTo(sOldLoc, aoMediumAttachments) 290 290 291 291 del oSubTstDrvMoveMedium1Instance
Note:
See TracChangeset
for help on using the changeset viewer.