VirtualBox

Ignore:
Timestamp:
Sep 6, 2021 7:02:28 PM (3 years ago)
Author:
vboxsync
Message:

VBoxManage: For movevm, treat the "no target specified" case so that the API knows to move to the same location.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r90828 r91131  
    317317    HRESULT                        rc;
    318318    const char                    *pszSrcName      = NULL;
    319     const char                    *pszTargetFolder = NULL;
    320319    const char                    *pszType         = NULL;
     320    char                          szTargetFolder[RTPATH_MAX];
    321321
    322322    int c;
     
    337337
    338338            case 'f':   // --target folder
    339 
    340                 char szPath[RTPATH_MAX];
    341                 pszTargetFolder = ValueUnion.psz;
    342 
    343                 vrc = RTPathAbs(pszTargetFolder, szPath, sizeof(szPath));
    344                 if (RT_FAILURE(vrc))
    345                     return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs(%s,,) failed with rc=%Rrc", pszTargetFolder, vrc);
     339                if (ValueUnion.psz && ValueUnion.psz[0] != '\0')
     340                {
     341                    vrc = RTPathAbs(ValueUnion.psz, szTargetFolder, sizeof(szTargetFolder));
     342                    if (RT_FAILURE(vrc))
     343                        return RTMsgErrorExit(RTEXITCODE_FAILURE, "RTPathAbs(%s,,) failed with rc=%Rrc", ValueUnion.psz, vrc);
     344                } else {
     345                    szTargetFolder[0] = '\0';
     346                }
    346347                break;
    347348
     
    384385
    385386        CHECK_ERROR_RET(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()), RTEXITCODE_FAILURE);
    386         CHECK_ERROR_RET(sessionMachine, MoveTo(Bstr(pszTargetFolder).raw(),
     387        CHECK_ERROR_RET(sessionMachine,
     388                        MoveTo(Bstr(szTargetFolder).raw(),
    387389                               Bstr(pszType).raw(),
    388                                progress.asOutParam()), RTEXITCODE_FAILURE);
     390                               progress.asOutParam()),
     391                        RTEXITCODE_FAILURE);
    389392        rc = showProgress(progress);
    390393        CHECK_PROGRESS_ERROR_RET(progress, ("Move VM failed"), RTEXITCODE_FAILURE);
     
    393396        CHECK_ERROR_RET(a->session, UnlockMachine(), RTEXITCODE_FAILURE);
    394397
    395 //        do
    396 //        {
    397 //            /* we have to open a session for this task */
    398 //            CHECK_ERROR_BREAK(srcMachine, LockMachine(a->session, LockType_Write));
    399 //            ComPtr<IMachine> sessionMachine;
    400 //            do
    401 //            {
    402 //                CHECK_ERROR_BREAK(a->session, COMGETTER(Machine)(sessionMachine.asOutParam()));
    403 //                CHECK_ERROR_BREAK(sessionMachine, MoveTo(Bstr(pszTargetFolder).raw(),
    404 //                                       Bstr(pszType).raw(),
    405 //                                       progress.asOutParam()));
    406 //                rc = showProgress(progress);
    407 //                CHECK_PROGRESS_ERROR_RET(progress, ("Move VM failed"), RTEXITCODE_FAILURE);
    408 ////              CHECK_ERROR_BREAK(sessionMachine, SaveSettings());
    409 //            } while (0);
    410 //
    411 //            sessionMachine.setNull();
    412 //            CHECK_ERROR_BREAK(a->session, UnlockMachine());
    413 //        } while (0);
    414         RTPrintf("Machine has been successfully moved into %s\n", pszTargetFolder);
     398        RTPrintf("Machine has been successfully moved into %s\n", szTargetFolder[0] != '\0' ? szTargetFolder : "the same location");
    415399    }
    416400
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette