VirtualBox

Changeset 70674 in vbox


Ignore:
Timestamp:
Jan 22, 2018 12:00:30 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120410
Message:

bugref:8345. Added a Progress object for rollback action. is it correct or not? I am not sure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/MachineImplMoveVM.cpp

    r70648 r70674  
    375375        }
    376376
    377         /** weak VirtualBox parent */
    378         VirtualBox* const pVirtualBox = NULL;
    379         unconst(pVirtualBox) = m_pMachine->i_getVirtualBox();
    380         rc = m_pProgress->init(pVirtualBox,
    381                              static_cast<IMachine*>(m_pMachine) /* aInitiator */,
    382                              Bstr(m_pMachine->tr("Moving Machine")).raw(),
    383                              true /* fCancellable */,
    384                              uCount,
    385                              uTotalWeight,
    386                              Bstr(m_pMachine->tr("Initialize Moving")).raw(),
    387                              1);
    388         if (FAILED(rc))
    389         {
    390             throw m_pMachine->setError(VBOX_E_IPRT_ERROR,
    391                                  m_pMachine->tr("Couldn't correctly setup the progress object for moving VM operation (%Rrc)"),
    392                                  rc);
     377        /* Init both Progress instances */
     378        {
     379            /** weak VirtualBox parent */
     380            VirtualBox* const pVirtualBox = NULL;
     381            unconst(pVirtualBox) = m_pMachine->i_getVirtualBox();
     382            rc = m_pProgress->init(pVirtualBox,
     383                                 static_cast<IMachine*>(m_pMachine) /* aInitiator */,
     384                                 Bstr(m_pMachine->tr("Moving Machine")).raw(),
     385                                 true /* fCancellable */,
     386                                 uCount,
     387                                 uTotalWeight,
     388                                 Bstr(m_pMachine->tr("Initialize Moving")).raw(),
     389                                 1);
     390            if (FAILED(rc))
     391            {
     392                throw m_pMachine->setError(VBOX_E_IPRT_ERROR,
     393                                     m_pMachine->tr("Couldn't correctly setup the progress object "
     394                                                    "for moving VM operation (%Rrc)"),
     395                                     rc);
     396            }
     397
     398            m_pRollBackProgress.createObject();
     399            rc = m_pRollBackProgress->init(pVirtualBox,
     400                                 static_cast<IMachine*>(m_pMachine) /* aInitiator */,
     401                                 Bstr(m_pMachine->tr("Moving back Machine")).raw(),
     402                                 true /* fCancellable */,
     403                                 uCount,
     404                                 uTotalWeight,
     405                                 Bstr(m_pMachine->tr("Initialize Moving back")).raw(),
     406                                 1);
     407            if (FAILED(rc))
     408            {
     409                throw m_pMachine->setError(VBOX_E_IPRT_ERROR,
     410                                     m_pMachine->tr("Couldn't correctly setup the progress object "
     411                                                    "for possible rollback operation during moving VM (%Rrc)"),
     412                                     rc);
     413            }
    393414        }
    394415
     
    511532
    512533    AutoCaller autoCaller(machine);
    513     if (FAILED(autoCaller.rc())) return;//Should we return something here?
     534//  if (FAILED(autoCaller.rc())) return;//Should we return something here?
    514535
    515536    Utf8Str strTargetFolder = taskMoveVM->m_targetPath;
     
    852873            Bstr bstrSrcName;
    853874
     875            rc = pMedium->COMGETTER(Name)(bstrSrcName.asOutParam());
     876            if (FAILED(rc)) throw rc;
     877
    854878            if (strTargetFolder != NULL && !strTargetFolder->isEmpty())
    855879            {
     
    869893
    870894                strTargetImageName.append(RTPATH_DELIMITER).append(strLocation);
    871             }
    872             else
    873             {
    874                 strTargetImageName = mt.strBaseName;//Should contain full path to the image
    875             }
    876 
    877             rc = pMedium->COMGETTER(Name)(bstrSrcName.asOutParam());
    878             if (FAILED(rc)) throw rc;
    879 
    880             rc = m_pProgress->SetNextOperation(BstrFmt(machine->tr("Moving Disk '%ls' ..."),
     895                rc = m_pProgress->SetNextOperation(BstrFmt(machine->tr("Moving Disk '%ls' ..."),
    881896                                                       bstrSrcName.raw()).raw(),
    882897                                                       mt.uWeight);
    883             if (FAILED(rc)) throw rc;
     898                if (FAILED(rc)) throw rc;
     899            }
     900            else
     901            {
     902                strTargetImageName = mt.strBaseName;//Should contain full path to the image
     903                rc = m_pRollBackProgress->SetNextOperation(BstrFmt(machine->tr("Moving back Disk '%ls' ..."),
     904                                                       bstrSrcName.raw()).raw(),
     905                                                       mt.uWeight);
     906                if (FAILED(rc)) throw rc;
     907            }
     908
     909
    884910
    885911            /* consistency: use \ if appropriate on the platform */
     
    893919            /* Wait until the async process has finished. */
    894920            machineLock.release();
    895             rc = m_pProgress->WaitForAsyncProgressCompletion(moveDiskProgress);
     921            if (strTargetFolder != NULL && !strTargetFolder->isEmpty())
     922            {
     923                rc = m_pProgress->WaitForAsyncProgressCompletion(moveDiskProgress);
     924            }
     925            else
     926            {
     927                rc = m_pRollBackProgress->WaitForAsyncProgressCompletion(moveDiskProgress);
     928            }
     929
    896930            machineLock.acquire();
    897931            if (FAILED(rc)) throw rc;
Note: See TracChangeset for help on using the changeset viewer.

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