VirtualBox

Changeset 81394 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Oct 21, 2019 9:16:17 AM (5 years ago)
Author:
vboxsync
Message:

Main/MachineImplMoveVM: Putting all Machine object references in a global variable is impossible, since multiple VM move operations can operate concurrently.

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineImplMoveVM.h

    r81393 r81394  
    6666class MachineMoveVM : public ThreadTask
    6767{
     68    std::vector<ComObjPtr<Machine> >        machineList;
    6869    RTCList<MEDIUMTASKCHAINMOVE>            m_llMedias;
    6970    RTCList<SAVESTATETASKMOVE>              m_llSaveStateFiles;
     
    110111
    111112private:
    112     HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot, std::vector<ComObjPtr<Machine> > &aMachineList) const;
     113    HRESULT createMachineList(const ComPtr<ISnapshot> &pSnapshot);
    113114    inline HRESULT queryBaseName(const ComPtr<IMedium> &pMedium, Utf8Str &strBaseName) const;
    114     HRESULT queryMediasForAllStates(const std::vector<ComObjPtr<Machine> > &aMachineList);
     115    HRESULT queryMediasForAllStates();
    115116    void updateProgressStats(MEDIUMTASKCHAINMOVE &mtc, ULONG &uCount, ULONG &uTotalWeight) const;
    116117    HRESULT addSaveState(const ComObjPtr<Machine> &machine);
  • trunk/src/VBox/Main/src-server/MachineImplMoveVM.cpp

    r81393 r81394  
    3030#include "LoggingNew.h"
    3131
    32 /* This variable is global and used in the different places so it must be cleared each time before usage to avoid failure */
    33 std::vector<ComObjPtr<Machine> > machineList;
    34 
    3532typedef std::multimap<Utf8Str, Utf8Str> list_t;
    3633typedef std::multimap<Utf8Str, Utf8Str>::const_iterator cit_t;
     
    292289    Utf8Str strTargetImageName;
    293290
    294     /* Global variable (defined at the beginning of file), so clear it before usage */
    295     machineList.clear();
    296291    machineList.push_back(m_pMachine);
    297292
     
    311306            if (FAILED(hrc))
    312307                return hrc;
    313             hrc = createMachineList(pSnapshot, machineList);
     308            hrc = createMachineList(pSnapshot);
    314309            if (FAILED(hrc))
    315310                return hrc;
     
    321316
    322317    /* The lists m_llMedias and m_llSaveStateFiles are filled in the queryMediasForAllStates() */
    323     hrc = queryMediasForAllStates(machineList);
     318    hrc = queryMediasForAllStates();
    324319    if (FAILED(hrc))
    325320        return hrc;
     
    13221317}
    13231318
    1324 HRESULT MachineMoveVM::createMachineList(const ComPtr<ISnapshot> &pSnapshot,
    1325                                          std::vector<ComObjPtr<Machine> > &aMachineList) const
     1319HRESULT MachineMoveVM::createMachineList(const ComPtr<ISnapshot> &pSnapshot)
    13261320{
    13271321    Bstr name;
     
    13321326    rc = pSnapshot->COMGETTER(Machine)(l_pMachine.asOutParam());
    13331327    if (FAILED(rc)) return rc;
    1334     aMachineList.push_back((Machine*)(IMachine*)l_pMachine);
     1328    machineList.push_back((Machine*)(IMachine*)l_pMachine);
    13351329
    13361330    SafeIfaceArray<ISnapshot> sfaChilds;
     
    13391333    for (size_t i = 0; i < sfaChilds.size(); ++i)
    13401334    {
    1341         rc = createMachineList(sfaChilds[i], aMachineList);
     1335        rc = createMachineList(sfaChilds[i]);
    13421336        if (FAILED(rc)) return rc;
    13431337    }
     
    13461340}
    13471341
    1348 HRESULT MachineMoveVM::queryMediasForAllStates(const std::vector<ComObjPtr<Machine> > &aMachineList)
     1342HRESULT MachineMoveVM::queryMediasForAllStates()
    13491343{
    13501344    /* In this case we create a exact copy of the original VM. This means just
     
    13521346     * list. */
    13531347    HRESULT rc = S_OK;
    1354     for (size_t i = 0; i < aMachineList.size(); ++i)
    1355     {
    1356         const ComObjPtr<Machine> &machine = aMachineList.at(i);
     1348    for (size_t i = 0; i < machineList.size(); ++i)
     1349    {
     1350        const ComObjPtr<Machine> &machine = machineList.at(i);
    13571351
    13581352        /* Add all attachments (and their parents) of the different
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