Changeset 70582 in vbox
- Timestamp:
- Jan 15, 2018 10:13:41 AM (7 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r69500 r70582 105 105 { "unregistervm", USAGE_UNREGISTERVM, VBMG_CMD_TODO, handleUnregisterVM, 0 }, 106 106 { "clonevm", USAGE_CLONEVM, VBMG_CMD_TODO, handleCloneVM, 0 }, 107 { "movevm", USAGE_MOVEVM, VBMG_CMD_TODO, handleMoveVM, 0 }, 107 108 { "mediumproperty", USAGE_MEDIUMPROPERTY, VBMG_CMD_TODO, handleMediumProperty, 0 }, 108 109 { "hdproperty", USAGE_MEDIUMPROPERTY, VBMG_CMD_TODO, handleMediumProperty, 0 }, /* backward compatibility */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.h
r69500 r70582 62 62 #define USAGE_MODIFYMEDIUM RT_BIT_64(14) 63 63 #define USAGE_CLONEMEDIUM RT_BIT_64(15) 64 #define USAGE_MOVEVM RT_BIT_64(16) 64 65 #define USAGE_CREATEHOSTIF RT_BIT_64(17) 65 66 #define USAGE_REMOVEHOSTIF RT_BIT_64(18) … … 277 278 RTEXITCODE handleExtPack(HandlerArg *a); 278 279 RTEXITCODE handleUnattended(HandlerArg *a); 280 RTEXITCODE handleMoveVM(HandlerArg *a); 279 281 280 282 /* VBoxManageDisk.cpp */ -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
r69681 r70582 732 732 " [--uuid <uuid>]\n" 733 733 " [--register]\n" 734 "\n", SEP); 735 736 if (fCategory & USAGE_MOVEVM) 737 RTStrmPrintf(pStrm, 738 "%s movevm %s <uuid|vmname>\n" 739 " --type basic\n" 740 " [--folder <path>]\n" 734 741 "\n", SEP); 735 742 -
trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp
r68318 r70582 292 292 293 293 return SUCCEEDED(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 294 } 295 296 static const RTGETOPTDEF g_aMoveVMOptions[] = 297 { 298 { "--type", 't', RTGETOPT_REQ_STRING }, 299 { "--folder", 'f', RTGETOPT_REQ_STRING }, 300 }; 301 302 RTEXITCODE handleMoveVM(HandlerArg *a) 303 { 304 HRESULT rc; 305 const char *pszSrcName = NULL; 306 const char *pszTargetFolder = NULL; 307 const char *pszType = NULL; 308 309 int c; 310 int vrc = VINF_SUCCESS; 311 RTGETOPTUNION ValueUnion; 312 RTGETOPTSTATE GetState; 313 314 // start at 0 because main() has hacked both the argc and argv given to us 315 RTGetOptInit(&GetState, a->argc, a->argv, g_aMoveVMOptions, RT_ELEMENTS(g_aMoveVMOptions), 316 0, RTGETOPTINIT_FLAGS_NO_STD_OPTS); 317 while ((c = RTGetOpt(&GetState, &ValueUnion))) 318 { 319 switch (c) 320 { 321 case 't': // --type 322 pszType = ValueUnion.psz; 323 break; 324 325 case 'f': // --target folder 326 327 char szPath[RTPATH_MAX]; 328 pszTargetFolder = ValueUnion.psz; 329 330 vrc = RTPathAbs(pszTargetFolder, szPath, sizeof(szPath)); 331 if (RT_FAILURE(vrc)) 332 return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs(%s,,) failed with rc=%Rrc", pszTargetFolder, vrc); 333 break; 334 335 case VINF_GETOPT_NOT_OPTION: 336 if (!pszSrcName) 337 pszSrcName = ValueUnion.psz; 338 else 339 return errorSyntax(USAGE_MOVEVM, "Invalid parameter '%s'", ValueUnion.psz); 340 break; 341 342 default: 343 return errorGetOpt(USAGE_MOVEVM, c, &ValueUnion); 344 } 345 } 346 347 348 /* Check for required options */ 349 if (!pszSrcName) 350 return errorSyntax(USAGE_MOVEVM, "VM name required"); 351 352 /* Get the machine object */ 353 ComPtr<IMachine> srcMachine; 354 CHECK_ERROR_RET(a->virtualBox, FindMachine(Bstr(pszSrcName).raw(), 355 srcMachine.asOutParam()), 356 RTEXITCODE_FAILURE); 357 358 if (srcMachine) 359 { 360 /* Start the moving */ 361 ComPtr<IProgress> progress; 362 do 363 { 364 /* we have to open a session for this task */ 365 CHECK_ERROR_BREAK(srcMachine, LockMachine(a->session, LockType_Write)); 366 ComPtr<IMachine> sessionMachine; 367 do 368 { 369 CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam())); 370 CHECK_ERROR_BREAK(sessionMachine, MoveTo(Bstr(pszTargetFolder).raw(), 371 Bstr(pszType).raw(), 372 progress.asOutParam())); 373 rc = showProgress(progress); 374 CHECK_PROGRESS_ERROR_RET(progress, ("Move VM failed"), RTEXITCODE_FAILURE); 375 // CHECK_ERROR_BREAK(sessionMachine, SaveSettings()); 376 } while (0); 377 378 sessionMachine.setNull(); 379 CHECK_ERROR_BREAK(a->session, UnlockMachine()); 380 } while (0); 381 } 382 383 RTPrintf("Machine has been successfully moved into %s\n", pszTargetFolder); 384 385 return RTEXITCODE_SUCCESS; 294 386 } 295 387 -
trunk/src/VBox/Main/Makefile.kmk
r70533 r70582 461 461 src-server/MachineImpl.cpp \ 462 462 src-server/MachineImplCloneVM.cpp \ 463 src-server/MachineImplMoveVM.cpp \ 463 464 src-server/Matching.cpp \ 464 465 src-server/MediumAttachmentImpl.cpp \ -
trunk/src/VBox/Main/idl/VirtualBox.xidl
r70228 r70582 4776 4776 <interface 4777 4777 name="IMachine" extends="$unknown" 4778 uuid=" 85cd948e-a71f-4289-281e-0ca7ad48cd89"4778 uuid="fecae8e8-46da-44cf-8fc0-2ba9aeb796a7" 4779 4779 wsmap="managed" 4780 4780 wrap-hint-server-addinterfaces="IInternalMachineControl" … … 7977 7977 <desc>Options for the cloning operation.</desc> 7978 7978 </param> 7979 <param name="progress" type="IProgress" dir="return"> 7980 <desc>Progress object to track the operation completion.</desc> 7981 </param> 7982 </method> 7983 7984 <method name="moveTo"> 7985 <desc> 7986 Move machine on to new place/folder 7987 <result name="E_INVALIDARG"> 7988 @a target is @c null. 7989 </result> 7990 </desc> 7991 7992 <param name="folder" type="wstring" dir="in"> 7993 <desc>Target folder where machine is moved.</desc> 7994 </param> 7995 7996 <param name="type" type="wstring" dir="in"> 7997 <desc>Type of moving. 7998 Possible values: 7999 basic - Only the files which belong solely to this machine 8000 are moved from the original machine's folder to 8001 a new folder. 8002 </desc> 8003 </param> 8004 7979 8005 <param name="progress" type="IProgress" dir="return"> 7980 8006 <desc>Progress object to track the operation completion.</desc> -
trunk/src/VBox/Main/include/MachineImpl.h
r68938 r70582 827 827 828 828 friend class MachineCloneVM; 829 829 friend class MachineMoveVM; 830 830 private: 831 831 // wrapped IMachine properties … … 1188 1188 const std::vector<CloneOptions_T> &aOptions, 1189 1189 ComPtr<IProgress> &aProgress); 1190 HRESULT moveTo(const com::Utf8Str &aTargetPath, 1191 const com::Utf8Str &aType, 1192 ComPtr<IProgress> &aProgress); 1190 1193 HRESULT saveState(ComPtr<IProgress> &aProgress); 1191 1194 HRESULT adoptSavedState(const com::Utf8Str &aSavedStateFile); -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r70386 r70582 45 45 #include "AutostartDb.h" 46 46 #include "SystemPropertiesImpl.h" 47 #include "MachineImplMoveVM.h" 47 48 48 49 // generated header … … 7223 7224 pP.queryInterfaceTo(aProgress.asOutParam()); 7224 7225 7226 return rc; 7227 7228 } 7229 7230 HRESULT Machine::moveTo(const com::Utf8Str &aTargetPath, 7231 const com::Utf8Str &aType, 7232 ComPtr<IProgress> &aProgress) 7233 { 7234 LogFlowThisFuncEnter(); 7235 7236 ComObjPtr<Progress> progress; 7237 7238 progress.createObject(); 7239 7240 HRESULT rc = S_OK; 7241 Utf8Str targetPath = aTargetPath; 7242 Utf8Str type = aType; 7243 7244 /* Initialize our worker task */ 7245 MachineMoveVM* task = NULL; 7246 try 7247 { 7248 task = new MachineMoveVM(this, targetPath, type, progress); 7249 } 7250 catch(...) 7251 { 7252 delete task; 7253 return rc; 7254 } 7255 7256 /* 7257 * task pointer will be owned by the ThreadTask class. 7258 * There is no need to call operator "delete" in the end. 7259 */ 7260 rc = task->init(); 7261 if (SUCCEEDED(rc)) 7262 { 7263 rc = task->createThread(); 7264 if (FAILED(rc)) 7265 { 7266 setError(rc, tr("Could not run the thread for the task MachineMoveVM")); 7267 } 7268 7269 /* Return progress to the caller */ 7270 progress.queryInterfaceTo(aProgress.asOutParam()); 7271 } 7272 7273 LogFlowThisFuncLeave(); 7225 7274 return rc; 7226 7275
Note:
See TracChangeset
for help on using the changeset viewer.