VirtualBox

Changeset 23327 in vbox for trunk


Ignore:
Timestamp:
Sep 25, 2009 11:36:00 AM (15 years ago)
Author:
vboxsync
Message:

Main: more header cleanup; move VirtualBox instance data to cpp implementation file

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/HostPower.cpp

    r23223 r23327  
    4444}
    4545
    46 void HostPowerService::notify (HostPowerEvent aEvent)
     46void HostPowerService::notify(HostPowerEvent aEvent)
    4747{
    48     VirtualBox::SessionMachineVector machines;
    49     VirtualBox::InternalControlVector controls;
     48    VirtualBox::SessionMachineList machines;
     49    VirtualBox::InternalControlList controls;
    5050
    5151    HRESULT rc = S_OK;
     
    6464                perfcollector->suspendSampling();
    6565#endif
    66             mVirtualBox->getOpenedMachinesAndControls (machines, controls);
     66            mVirtualBox->getOpenedMachines(machines, &controls);
    6767
    6868            /* pause running VMs */
    69             for (size_t i = 0; i < controls.size(); ++ i)
     69            for (VirtualBox::InternalControlList::const_iterator it = controls.begin();
     70                 it != controls.end();
     71                 ++it)
    7072            {
     73                ComPtr<IInternalSessionControl> pControl = *it;
     74
    7175                /* get the remote console */
    7276                ComPtr<IConsole> console;
    73                 rc = controls [i]->GetRemoteConsole (console.asOutParam());
     77                rc = pControl->GetRemoteConsole (console.asOutParam());
    7478                /* the VM could have been powered down and closed or whatever */
    7579                if (FAILED (rc))
     
    8387
    8488                /* save the control to un-pause the VM later */
    85                 mConsoles.push_back (console);
     89                mConsoles.push_back(console);
    8690            }
    8791
     
    130134            LogFunc (("BATTERY LOW\n"));
    131135
    132             mVirtualBox->getOpenedMachinesAndControls (machines, controls);
     136            mVirtualBox->getOpenedMachines(machines, &controls);
    133137
    134138            size_t saved = 0;
    135139
    136140            /* save running VMs */
    137             for (size_t i = 0; i < controls.size(); ++ i)
     141            for (VirtualBox::InternalControlList::const_iterator it = controls.begin();
     142                 it != controls.end();
     143                 ++it)
    138144            {
     145                ComPtr<IInternalSessionControl> pControl = *it;
    139146                /* get the remote console */
    140147                ComPtr<IConsole> console;
    141                 rc = controls [i]->GetRemoteConsole (console.asOutParam());
     148                rc = pControl->GetRemoteConsole (console.asOutParam());
    142149                /* the VM could have been powered down and closed or whatever */
    143150                if (FAILED (rc))
  • trunk/src/VBox/Main/MediumImpl.cpp

    r23257 r23327  
    33073307RWLockHandle* Medium::treeLock()
    33083308{
    3309     return mVirtualBox->hardDiskTreeLockHandle();
     3309    return &mVirtualBox->hardDiskTreeLockHandle();
    33103310}
    33113311
  • trunk/src/VBox/Main/VFSExplorerImpl.cpp

    r23223 r23327  
    2626#include <iprt/s3.h>
    2727
     28#include <VBox/com/array.h>
     29
    2830#include <VBox/param.h>
    2931#include <VBox/version.h>
  • trunk/src/VBox/Main/VirtualBoxImpl.cpp

    r23319 r23327  
    6565#include "DHCPServerRunner.h"
    6666#include "DHCPServerImpl.h"
     67#ifdef VBOX_WITH_RESOURCE_USAGE_API
     68#include "PerformanceImpl.h"
     69#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    6770
    6871#include "Logging.h"
     
    7275#endif
    7376
    74 // defines
    75 /////////////////////////////////////////////////////////////////////////////
     77////////////////////////////////////////////////////////////////////////////////
     78//
     79// Definitions
     80//
     81////////////////////////////////////////////////////////////////////////////////
    7682
    7783#define VBOX_GLOBAL_SETTINGS_FILE "VirtualBox.xml"
     
    7985typedef std::vector< ComObjPtr<Machine> > MachineVector;
    8086
    81 // globals
    82 /////////////////////////////////////////////////////////////////////////////
     87typedef std::list< ComObjPtr<Machine> > MachineList;
     88typedef std::vector< ComObjPtr<SessionMachine> > SessionMachineVector;
     89typedef std::list< ComObjPtr<GuestOSType> > GuestOSTypeList;
     90
     91typedef std::map<Guid, ComPtr<IProgress> > ProgressMap;
     92
     93typedef std::list <ComObjPtr<Medium> > HardDiskList;
     94typedef std::list <ComObjPtr<Medium> > DVDImageList;
     95typedef std::list <ComObjPtr<Medium> > FloppyImageList;
     96typedef std::list <ComObjPtr<SharedFolder> > SharedFolderList;
     97typedef std::list <ComObjPtr<DHCPServer> > DHCPServerList;
     98
     99typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap;
     100
     101
     102////////////////////////////////////////////////////////////////////////////////
     103//
     104// Global variables
     105//
     106////////////////////////////////////////////////////////////////////////////////
    83107
    84108// static
     
    93117////////////////////////////////////////////////////////////////////////////////
    94118//
    95 // Callback event
     119// CallbackEvent class
    96120//
    97121////////////////////////////////////////////////////////////////////////////////
     
    129153};
    130154
     155////////////////////////////////////////////////////////////////////////////////
     156//
     157// VirtualBox data definition
     158//
     159////////////////////////////////////////////////////////////////////////////////
     160
     161#if defined(RT_OS_WINDOWS)
     162    #define UPDATEREQARG NULL
     163    #define UPDATEREQTYPE HANDLE
     164#elif defined(RT_OS_OS2)
     165    #define UPDATEREQARG NIL_RTSEMEVENT
     166    #define UPDATEREQTYPE RTSEMEVENT
     167#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
     168    #define UPDATEREQARG
     169    #define UPDATEREQTYPE RTSEMEVENT
     170#else
     171# error "Port me!"
     172#endif
     173
     174/**
     175 *  Main VirtualBox data structure.
     176 *  @note |const| members are persistent during lifetime so can be accessed
     177 *  without locking.
     178 */
     179struct VirtualBox::Data
     180{
     181    Data()
     182        : pMainConfigFile(NULL),
     183          updateReq(UPDATEREQARG),
     184          threadClientWatcher(NIL_RTTHREAD),
     185          threadAsyncEvent(NIL_RTTHREAD),
     186          pAsyncEventQ(NULL)
     187    {}
     188
     189    // const data members not requiring locking
     190    const Utf8Str                       strHomeDir;
     191
     192    // VirtualBox main settings file
     193    const Utf8Str                       strSettingsFilePath;
     194    settings::MainConfigFile            *pMainConfigFile;
     195
     196    // const objects not requiring locking
     197    const ComObjPtr<Host>               pHost;
     198    const ComObjPtr<SystemProperties>   pSystemProperties;
     199#ifdef VBOX_WITH_RESOURCE_USAGE_API
     200    const ComObjPtr<PerformanceCollector> pPerformanceCollector;
     201#endif /* VBOX_WITH_RESOURCE_USAGE_API */
     202
     203    MachineList                         llMachines;
     204    GuestOSTypeList                     llGuestOSTypes;
     205
     206    ProgressMap                         mapProgressOperations;
     207
     208    HardDiskList                        llHardDisks;
     209    DVDImageList                        llDVDImages;
     210    FloppyImageList                     llFloppyImages;
     211    SharedFolderList                    llSharedFolders;
     212    DHCPServerList                      llDHCPServers;
     213
     214    /// @todo NEWMEDIA do we really need this map? Used only in
     215    /// find() it seems
     216    HardDiskMap                         mapHardDisks;
     217
     218    CallbackList                        llCallbacks;
     219
     220    RWLockHandle                        mtxProgressOperations;
     221            // protects mutex operations; "leaf" lock, no other lock may be requested after this
     222    RWLockHandle                        mtxHardDiskTree;
     223            // protects the hard disk tree; this is implemented here, but only requested through
     224            // Medium::treeLock, which returns exactly this
     225    RWLockHandle                        mtxChildrenMap;
     226            // used for VirtualBoxWithChildrenNEXT management
     227
     228    // the following are data for the client watcher thread
     229    const UPDATEREQTYPE                 updateReq;
     230    const RTTHREAD                      threadClientWatcher;
     231    typedef std::list<RTPROCESS> ProcessList;
     232    ProcessList                         llProcesses;
     233
     234    // the following are data for the async event thread
     235    const RTTHREAD                      threadAsyncEvent;
     236    EventQueue * const                  pAsyncEventQ;
     237
     238};
     239
    131240// constructor / destructor
    132241/////////////////////////////////////////////////////////////////////////////
    133242
    134243VirtualBox::VirtualBox()
    135     : mAsyncEventThread (NIL_RTTHREAD)
    136     , mAsyncEventQ (NULL)
    137244{}
    138245
    139 VirtualBox::~VirtualBox() {}
     246VirtualBox::~VirtualBox()
     247{}
    140248
    141249HRESULT VirtualBox::FinalConstruct()
     
    151259
    152260    uninit();
    153 }
    154 
    155 VirtualBox::Data::Data()
    156 {
    157261}
    158262
     
    175279     * read lock and later calls code which wants the same write lock. */
    176280    AutoWriteLock lock(this);
     281
     282    // allocate our instance data
     283    m = new Data;
    177284
    178285    LogFlow (("===========================================================\n"));
     
    196303                homeDir, vrc);
    197304
    198         unconst(mData.mHomeDir) = homeDir;
     305        unconst(m->strHomeDir) = homeDir;
    199306    }
    200307
    201308    /* compose the VirtualBox.xml file name */
    202     unconst(m_strSettingsFilePath) = Utf8StrFmt("%s%c%s",
    203                                                 mData.mHomeDir.raw(),
     309    unconst(m->strSettingsFilePath) = Utf8StrFmt("%s%c%s",
     310                                                m->strHomeDir.raw(),
    204311                                                RTPATH_DELIMITER,
    205312                                                VBOX_GLOBAL_SETTINGS_FILE);
     
    211318        try
    212319        {
    213             m_pMainConfigFile = new settings::MainConfigFile(&m_strSettingsFilePath);
     320            m->pMainConfigFile = new settings::MainConfigFile(&m->strSettingsFilePath);
    214321        }
    215322        catch (xml::EIPRTFailure &e)
     
    225332
    226333        if (fCreate)
    227             m_pMainConfigFile = new settings::MainConfigFile(NULL);
     334            m->pMainConfigFile = new settings::MainConfigFile(NULL);
    228335
    229336#ifdef VBOX_WITH_RESOURCE_USAGE_API
    230337        /* create the performance collector object BEFORE host */
    231         unconst (mData.mPerformanceCollector).createObject();
    232         rc = mData.mPerformanceCollector->init();
     338        unconst(m->pPerformanceCollector).createObject();
     339        rc = m->pPerformanceCollector->init();
    233340        ComAssertComRCThrowRC(rc);
    234341#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    235342
    236343        /* create the host object early, machines will need it */
    237         unconst (mData.mHost).createObject();
    238         rc = mData.mHost->init(this);
     344        unconst(m->pHost).createObject();
     345        rc = m->pHost->init(this);
    239346        ComAssertComRCThrowRC(rc);
    240347
    241         rc = mData.mHost->loadSettings(m_pMainConfigFile->host);
     348        rc = m->pHost->loadSettings(m->pMainConfigFile->host);
    242349        CheckComRCThrowRC(rc);
    243350
    244351        /* create the system properties object, someone may need it too */
    245         unconst (mData.mSystemProperties).createObject();
    246         rc = mData.mSystemProperties->init(this);
     352        unconst(m->pSystemProperties).createObject();
     353        rc = m->pSystemProperties->init(this);
    247354        ComAssertComRCThrowRC (rc);
    248355
    249         rc = mData.mSystemProperties->loadSettings(m_pMainConfigFile->systemProperties);
     356        rc = m->pSystemProperties->loadSettings(m->pMainConfigFile->systemProperties);
    250357        CheckComRCThrowRC(rc);
    251358
     
    269376                                          Global::sOSTypes [i].numSerialEnabled);
    270377                if (SUCCEEDED(rc))
    271                     mData.mGuestOSTypes.push_back (guestOSTypeObj);
     378                    m->llGuestOSTypes.push_back (guestOSTypeObj);
    272379            }
    273380            ComAssertComRCThrowRC (rc);
     
    283390
    284391        /* net services */
    285         for (settings::DHCPServersList::const_iterator it = m_pMainConfigFile->llDhcpServers.begin();
    286              it != m_pMainConfigFile->llDhcpServers.end();
     392        for (settings::DHCPServersList::const_iterator it = m->pMainConfigFile->llDhcpServers.begin();
     393             it != m->pMainConfigFile->llDhcpServers.end();
    287394             ++it)
    288395        {
     
    312419        /* start the client watcher thread */
    313420#if defined(RT_OS_WINDOWS)
    314         unconst(mWatcherData.mUpdateReq) = ::CreateEvent (NULL, FALSE, FALSE, NULL);
     421        unconst(m->updateReq) = ::CreateEvent (NULL, FALSE, FALSE, NULL);
    315422#elif defined(RT_OS_OS2)
    316         RTSemEventCreate (&unconst(mWatcherData.mUpdateReq));
     423        RTSemEventCreate(&unconst(m->updateReq));
    317424#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    318         RTSemEventCreate (&unconst(mWatcherData.mUpdateReq));
     425        RTSemEventCreate(&unconst(m->updateReq));
    319426#else
    320427# error "Port me!"
    321428#endif
    322         int vrc = RTThreadCreate (&unconst(mWatcherData.mThread),
    323                                   ClientWatcher, (void *) this,
    324                                   0, RTTHREADTYPE_MAIN_WORKER,
    325                                   RTTHREADFLAGS_WAITABLE, "Watcher");
     429        int vrc = RTThreadCreate(&unconst(m->threadClientWatcher),
     430                                 ClientWatcher,
     431                                 (void *) this,
     432                                 0,
     433                                 RTTHREADTYPE_MAIN_WORKER,
     434                                 RTTHREADFLAGS_WAITABLE,
     435                                 "Watcher");
    326436        ComAssertRC (vrc);
    327437        if (RT_FAILURE(vrc))
     
    332442    {
    333443        /* start the async event handler thread */
    334         int vrc = RTThreadCreate (&unconst(mAsyncEventThread), AsyncEventHandler,
    335                                   &unconst(mAsyncEventQ),
    336                                   0, RTTHREADTYPE_MAIN_WORKER,
    337                                   RTTHREADFLAGS_WAITABLE, "EventHandler");
     444        int vrc = RTThreadCreate(&unconst(m->threadAsyncEvent),
     445                                 AsyncEventHandler,
     446                                 &unconst(m->pAsyncEventQ),
     447                                 0,
     448                                 RTTHREADTYPE_MAIN_WORKER,
     449                                 RTTHREADFLAGS_WAITABLE,
     450                                 "EventHandler");
    338451        ComAssertRCBreak (vrc, rc = E_FAIL);
    339452
    340         /* wait until the thread sets mAsyncEventQ */
    341         RTThreadUserWait (mAsyncEventThread, RT_INDEFINITE_WAIT);
    342         ComAssertBreak (mAsyncEventQ, rc = E_FAIL);
     453        /* wait until the thread sets m->pAsyncEventQ */
     454        RTThreadUserWait(m->threadAsyncEvent, RT_INDEFINITE_WAIT);
     455        ComAssertBreak(m->pAsyncEventQ, rc = E_FAIL);
    343456    }
    344457    while (0);
     
    356469HRESULT VirtualBox::initMachines()
    357470{
    358     for (settings::MachinesRegistry::const_iterator it = m_pMainConfigFile->llMachines.begin();
    359          it != m_pMainConfigFile->llMachines.end();
     471    for (settings::MachinesRegistry::const_iterator it = m->pMainConfigFile->llMachines.begin();
     472         it != m->pMainConfigFile->llMachines.end();
    360473         ++it)
    361474    {
     
    388501    HRESULT rc = S_OK;
    389502    settings::MediaList::const_iterator it;
    390     for (it = m_pMainConfigFile->llHardDisks.begin();
    391          it != m_pMainConfigFile->llHardDisks.end();
     503    for (it = m->pMainConfigFile->llHardDisks.begin();
     504         it != m->pMainConfigFile->llHardDisks.end();
    392505         ++it)
    393506    {
     
    406519    }
    407520
    408     for (it = m_pMainConfigFile->llDvdImages.begin();
    409          it != m_pMainConfigFile->llDvdImages.end();
     521    for (it = m->pMainConfigFile->llDvdImages.begin();
     522         it != m->pMainConfigFile->llDvdImages.end();
    410523         ++it)
    411524    {
     
    421534    }
    422535
    423     for (it = m_pMainConfigFile->llFloppyImages.begin();
    424          it != m_pMainConfigFile->llFloppyImages.end();
     536    for (it = m->pMainConfigFile->llFloppyImages.begin();
     537         it != m->pMainConfigFile->llFloppyImages.end();
    425538         ++it)
    426539    {
     
    452565    /* tell all our child objects we've been uninitialized */
    453566
    454     LogFlowThisFunc(("Uninitializing machines (%d)...\n", mData.mMachines.size()));
    455     if (mData.mMachines.size())
    456     {
    457         MachineList::iterator it = mData.mMachines.begin();
    458         while (it != mData.mMachines.end())
     567    LogFlowThisFunc(("Uninitializing machines (%d)...\n", m->llMachines.size()));
     568    if (m->llMachines.size())
     569    {
     570        MachineList::iterator it = m->llMachines.begin();
     571        while (it != m->llMachines.end())
    459572            (*it++)->uninit();
    460         mData.mMachines.clear();
     573        m->llMachines.clear();
    461574    }
    462575
     
    466579    uninitDependentChildren();
    467580
    468     mData.mHardDiskMap.clear();
    469 
    470     mData.mFloppyImages.clear();
    471     mData.mDVDImages.clear();
    472     mData.mHardDisks.clear();
    473     mData.mDHCPServers.clear();
    474 
    475     mData.mProgressOperations.clear();
    476 
    477     mData.mGuestOSTypes.clear();
     581    m->mapHardDisks.clear();
     582
     583    m->llFloppyImages.clear();
     584    m->llDVDImages.clear();
     585    m->llHardDisks.clear();
     586    m->llDHCPServers.clear();
     587
     588    m->mapProgressOperations.clear();
     589
     590    m->llGuestOSTypes.clear();
    478591
    479592    /* Note that we release singleton children after we've all other children.
     
    482595     * uninitializing (as for example, mSystemProperties which owns
    483596     * MediumFormat objects which Medium objects refer to) */
    484     if (mData.mSystemProperties)
    485     {
    486         mData.mSystemProperties->uninit();
    487         unconst(mData.mSystemProperties).setNull();
    488     }
    489 
    490     if (mData.mHost)
    491     {
    492         mData.mHost->uninit();
    493         unconst(mData.mHost).setNull();
     597    if (m->pSystemProperties)
     598    {
     599        m->pSystemProperties->uninit();
     600        unconst(m->pSystemProperties).setNull();
     601    }
     602
     603    if (m->pHost)
     604    {
     605        m->pHost->uninit();
     606        unconst(m->pHost).setNull();
    494607    }
    495608
    496609#ifdef VBOX_WITH_RESOURCE_USAGE_API
    497     if (mData.mPerformanceCollector)
    498     {
    499         mData.mPerformanceCollector->uninit();
    500         unconst(mData.mPerformanceCollector).setNull();
     610    if (m->pPerformanceCollector)
     611    {
     612        m->pPerformanceCollector->uninit();
     613        unconst(m->pPerformanceCollector).setNull();
    501614    }
    502615#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    503616
    504617    LogFlowThisFunc(("Releasing callbacks...\n"));
    505     if (mData.mCallbacks.size())
     618    if (m->llCallbacks.size())
    506619    {
    507620        /* release all callbacks */
    508621        LogWarningFunc (("%d unregistered callbacks!\n",
    509                          mData.mCallbacks.size()));
    510         mData.mCallbacks.clear();
     622                         m->llCallbacks.size()));
     623        m->llCallbacks.clear();
    511624    }
    512625
    513626    LogFlowThisFunc(("Terminating the async event handler...\n"));
    514     if (mAsyncEventThread != NIL_RTTHREAD)
     627    if (m->threadAsyncEvent != NIL_RTTHREAD)
    515628    {
    516629        /* signal to exit the event loop */
    517         if (mAsyncEventQ->postEvent (NULL))
     630        if (m->pAsyncEventQ->postEvent (NULL))
    518631        {
    519632            /*
     
    521634             *  a NULL event!)
    522635             */
    523             int vrc = RTThreadWait (mAsyncEventThread, 60000, NULL);
     636            int vrc = RTThreadWait(m->threadAsyncEvent, 60000, NULL);
    524637            if (RT_FAILURE(vrc))
    525                 LogWarningFunc (("RTThreadWait(%RTthrd) -> %Rrc\n",
    526                                  mAsyncEventThread, vrc));
     638                LogWarningFunc(("RTThreadWait(%RTthrd) -> %Rrc\n",
     639                                m->threadAsyncEvent, vrc));
    527640        }
    528641        else
    529642        {
    530             AssertMsgFailed (("postEvent(NULL) failed\n"));
    531             RTThreadWait (mAsyncEventThread, 0, NULL);
     643            AssertMsgFailed(("postEvent(NULL) failed\n"));
     644            RTThreadWait(m->threadAsyncEvent, 0, NULL);
    532645        }
    533646
    534         unconst(mAsyncEventThread) = NIL_RTTHREAD;
    535         unconst(mAsyncEventQ) = NULL;
     647        unconst(m->threadAsyncEvent) = NIL_RTTHREAD;
     648        unconst(m->pAsyncEventQ) = NULL;
    536649    }
    537650
    538651    LogFlowThisFunc(("Terminating the client watcher...\n"));
    539     if (mWatcherData.mThread != NIL_RTTHREAD)
     652    if (m->threadClientWatcher != NIL_RTTHREAD)
    540653    {
    541654        /* signal the client watcher thread */
    542655        updateClientWatcher();
    543656        /* wait for the termination */
    544         RTThreadWait (mWatcherData.mThread, RT_INDEFINITE_WAIT, NULL);
    545         unconst(mWatcherData.mThread) = NIL_RTTHREAD;
    546     }
    547     mWatcherData.mProcesses.clear();
     657        RTThreadWait(m->threadClientWatcher, RT_INDEFINITE_WAIT, NULL);
     658        unconst(m->threadClientWatcher) = NIL_RTTHREAD;
     659    }
     660    m->llProcesses.clear();
    548661#if defined(RT_OS_WINDOWS)
    549     if (mWatcherData.mUpdateReq != NULL)
    550     {
    551         ::CloseHandle (mWatcherData.mUpdateReq);
    552         unconst(mWatcherData.mUpdateReq) = NULL;
     662    if (m->updateReq != NULL)
     663    {
     664        ::CloseHandle (m->updateReq);
     665        unconst(m->updateReq) = NULL;
    553666    }
    554667#elif defined(RT_OS_OS2)
    555     if (mWatcherData.mUpdateReq != NIL_RTSEMEVENT)
    556     {
    557         RTSemEventDestroy (mWatcherData.mUpdateReq);
    558         unconst(mWatcherData.mUpdateReq) = NIL_RTSEMEVENT;
     668    if (m->updateReq != NIL_RTSEMEVENT)
     669    {
     670        RTSemEventDestroy (m->updateReq);
     671        unconst(m->updateReq) = NIL_RTSEMEVENT;
    559672    }
    560673#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    561     if (mWatcherData.mUpdateReq != NIL_RTSEMEVENT)
    562     {
    563         RTSemEventDestroy (mWatcherData.mUpdateReq);
    564         unconst(mWatcherData.mUpdateReq) = NIL_RTSEMEVENT;
     674    if (m->updateReq != NIL_RTSEMEVENT)
     675    {
     676        RTSemEventDestroy (m->updateReq);
     677        unconst(m->updateReq) = NIL_RTSEMEVENT;
    565678    }
    566679#else
     
    568681#endif
    569682
     683    // clean up our instance data
     684    delete m;
     685
    570686    /* Unload hard disk plugin backends. */
    571687    VDShutdown();
     
    619735
    620736    /* mHomeDir is const and doesn't need a lock */
    621     mData.mHomeDir.cloneTo(aHomeFolder);
     737    m->strHomeDir.cloneTo(aHomeFolder);
    622738    return S_OK;
    623739}
     
    631747
    632748    /* mCfgFile.mName is const and doesn't need a lock */
    633     m_strSettingsFilePath.cloneTo(aSettingsFilePath);
     749    m->strSettingsFilePath.cloneTo(aSettingsFilePath);
    634750    return S_OK;
    635751}
     
    643759
    644760    /* mHost is const, no need to lock */
    645     mData.mHost.queryInterfaceTo(aHost);
     761    m->pHost.queryInterfaceTo(aHost);
    646762    return S_OK;
    647763}
     
    656772
    657773    /* mSystemProperties is const, no need to lock */
    658     mData.mSystemProperties.queryInterfaceTo(aSystemProperties);
     774    m->pSystemProperties.queryInterfaceTo(aSystemProperties);
    659775    return S_OK;
    660776}
     
    671787    AutoReadLock alock(this);
    672788
    673     SafeIfaceArray<IMachine> machines (mData.mMachines);
     789    SafeIfaceArray<IMachine> machines(m->llMachines);
    674790    machines.detachTo(ComSafeArrayOutArg(aMachines));
    675791
     
    687803    AutoReadLock alock(this);
    688804
    689     SafeIfaceArray<IMedium> hardDisks (mData.mHardDisks);
     805    SafeIfaceArray<IMedium> hardDisks(m->llHardDisks);
    690806    hardDisks.detachTo(ComSafeArrayOutArg(aHardDisks));
    691807
     
    704820    AutoReadLock alock(this);
    705821
    706     SafeIfaceArray<IMedium> images (mData.mDVDImages);
     822    SafeIfaceArray<IMedium> images(m->llDVDImages);
    707823    images.detachTo(ComSafeArrayOutArg(aDVDImages));
    708824
     
    721837    AutoReadLock alock(this);
    722838
    723     SafeIfaceArray<IMedium> images (mData.mFloppyImages);
     839    SafeIfaceArray<IMedium> images(m->llFloppyImages);
    724840    images.detachTo(ComSafeArrayOutArg(aFloppyImages));
    725841
     
    735851
    736852    /* protect mProgressOperations */
    737     AutoReadLock safeLock (mSafeLock);
    738 
    739     SafeIfaceArray<IProgress> progress (mData.mProgressOperations);
     853    AutoReadLock safeLock(m->mtxProgressOperations);
     854
     855    SafeIfaceArray<IProgress> progress(m->mapProgressOperations);
    740856    progress.detachTo(ComSafeArrayOutArg(aOperations));
    741857
     
    752868    AutoReadLock alock(this);
    753869
    754     SafeIfaceArray<IGuestOSType> ostypes (mData.mGuestOSTypes);
     870    SafeIfaceArray<IGuestOSType> ostypes(m->llGuestOSTypes);
    755871    ostypes.detachTo(ComSafeArrayOutArg(aGuestOSTypes));
    756872
     
    783899
    784900    /* mPerformanceCollector is const, no need to lock */
    785     mData.mPerformanceCollector.queryInterfaceTo(aPerformanceCollector);
     901    m->pPerformanceCollector.queryInterfaceTo(aPerformanceCollector);
    786902
    787903    return S_OK;
     
    802918    AutoReadLock alock(this);
    803919
    804     SafeIfaceArray<IDHCPServer> svrs (mData.mDHCPServers);
     920    SafeIfaceArray<IDHCPServer> svrs (m->llDHCPServers);
    805921    svrs.detachTo(ComSafeArrayOutArg(aDHCPServers));
    806922
     
    859975        id.create();
    860976
    861     /* Look for a GuestOSType object */
    862     AssertMsg (mData.mGuestOSTypes.size() != 0,
    863                ("Guest OS types array must be filled"));
    864 
    865     GuestOSType *osType = NULL;
    866     if (aOsTypeId != NULL)
    867     {
    868         for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin();
    869              it != mData.mGuestOSTypes.end();
    870              ++ it)
    871         {
    872             if ((*it)->id() == aOsTypeId)
    873             {
    874                 osType = *it;
    875                 break;
    876             }
    877         }
    878 
    879         if (osType == NULL)
    880             return setError(VBOX_E_OBJECT_NOT_FOUND,
    881                             tr("Guest OS type '%ls' is invalid"),
    882                             aOsTypeId);
    883     }
     977    GuestOSType *osType;
     978    rc = findGuestOSType(aOsTypeId, osType);
     979    CheckComRCReturnRC(rc);
    884980
    885981    /* initialize the machine object */
     
    9341030        id.create();
    9351031
    936     /* Look for a GuestOSType object */
    937     AssertMsg (mData.mGuestOSTypes.size() != 0,
    938                ("Guest OS types array must be filled"));
    939 
    940     GuestOSType *osType = NULL;
    941     if (aOsTypeId != NULL)
    942     {
    943         for (GuestOSTypeList::const_iterator it = mData.mGuestOSTypes.begin();
    944              it != mData.mGuestOSTypes.end(); ++ it)
    945         {
    946             if ((*it)->id() == aOsTypeId)
    947             {
    948                 osType = *it;
    949                 break;
    950             }
    951         }
    952 
    953         if (osType == NULL)
    954             return setError (VBOX_E_OBJECT_NOT_FOUND,
    955                 tr ("Guest OS type '%ls' is invalid"), aOsTypeId);
    956     }
     1032    GuestOSType *osType;
     1033    rc = findGuestOSType(aOsTypeId, osType);
     1034    CheckComRCReturnRC(rc);
    9571035
    9581036    /* initialize the machine object */
     
    10821160        /* take a copy for safe iteration outside the lock */
    10831161        AutoReadLock alock(this);
    1084         machines = mData.mMachines;
     1162        machines = m->llMachines;
    10851163    }
    10861164
     
    11371215
    11381216    /* remove from the collection of registered machines */
    1139     mData.mMachines.remove (machine);
     1217    m->llMachines.remove (machine);
    11401218
    11411219    /* save the global registry */
     
    14461524    AutoReadLock alock(this);
    14471525
    1448     for (GuestOSTypeList::iterator it = mData.mGuestOSTypes.begin();
    1449          it != mData.mGuestOSTypes.end();
     1526    for (GuestOSTypeList::iterator it = m->llGuestOSTypes.begin();
     1527         it != m->llGuestOSTypes.end();
    14501528         ++ it)
    14511529    {
     
    15021580    AutoReadLock alock (this);
    15031581
    1504     com::SafeArray<BSTR> saKeys(m_pMainConfigFile->mapExtraDataItems.size());
     1582    com::SafeArray<BSTR> saKeys(m->pMainConfigFile->mapExtraDataItems.size());
    15051583    int i = 0;
    1506     for (ExtraDataItemsMap::const_iterator it = m_pMainConfigFile->mapExtraDataItems.begin();
    1507          it != m_pMainConfigFile->mapExtraDataItems.end();
     1584    for (ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.begin();
     1585         it != m->pMainConfigFile->mapExtraDataItems.end();
    15081586         ++it, ++i)
    15091587    {
     
    15311609    Bstr("").cloneTo(aValue);
    15321610
    1533     settings::ExtraDataItemsMap::const_iterator it = m_pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey));
    1534     if (it != m_pMainConfigFile->mapExtraDataItems.end())
     1611    settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(Utf8Str(aKey));
     1612    if (it != m->pMainConfigFile->mapExtraDataItems.end())
    15351613    {
    15361614        // found:
     
    15671645    {
    15681646        AutoReadLock alock(this); // hold read lock only while looking up
    1569         settings::ExtraDataItemsMap::const_iterator it = m_pMainConfigFile->mapExtraDataItems.find(strKey);
    1570         if (it != m_pMainConfigFile->mapExtraDataItems.end())
     1647        settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(strKey);
     1648        if (it != m->pMainConfigFile->mapExtraDataItems.end())
    15711649            strOldValue = it->second;
    15721650    }
     
    16041682
    16051683        if (strValue.isEmpty())
    1606             m_pMainConfigFile->mapExtraDataItems.erase(strKey);
     1684            m->pMainConfigFile->mapExtraDataItems.erase(strKey);
    16071685        else
    1608             m_pMainConfigFile->mapExtraDataItems[strKey] = strValue;
     1686            m->pMainConfigFile->mapExtraDataItems[strKey] = strValue;
    16091687                // creates a new key if needed
    16101688
     
    17871865
    17881866    AutoWriteLock alock(this);
    1789     mData.mCallbacks.push_back (CallbackList::value_type (aCallback));
     1867    m->llCallbacks.push_back (CallbackList::value_type (aCallback));
    17901868
    17911869    return S_OK;
     
    18071885
    18081886    CallbackList::iterator it;
    1809     it = std::find (mData.mCallbacks.begin(),
    1810                     mData.mCallbacks.end(),
     1887    it = std::find (m->llCallbacks.begin(),
     1888                    m->llCallbacks.end(),
    18111889                    CallbackList::value_type (aCallback));
    1812     if (it == mData.mCallbacks.end())
     1890    if (it == m->llCallbacks.end())
    18131891        rc = E_INVALIDARG;
    18141892    else
    1815         mData.mCallbacks.erase (it);
     1893        m->llCallbacks.erase (it);
    18161894
    18171895    LogFlowThisFunc(("aCallback=%p, rc=%08X\n", aCallback, rc));
     
    18201898
    18211899
    1822 STDMETHODIMP VirtualBox::WaitForPropertyChange (IN_BSTR /* aWhat */, ULONG /* aTimeout */,
    1823                                                 BSTR * /* aChanged */, BSTR * /* aValues */)
     1900STDMETHODIMP VirtualBox::WaitForPropertyChange(IN_BSTR /* aWhat */,
     1901                                               ULONG /* aTimeout */,
     1902                                               BSTR * /* aChanged */,
     1903                                               BSTR * /* aValues */)
    18241904{
    18251905    ReturnComNotImplemented();
     
    18441924 *  @note Doesn't lock any object.
    18451925 */
    1846 HRESULT VirtualBox::postEvent (Event *event)
    1847 {
    1848     AutoCaller autoCaller(this);
    1849     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     1926HRESULT VirtualBox::postEvent(Event *event)
     1927{
     1928    AutoCaller autoCaller(this);
     1929    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    18501930
    18511931    if (autoCaller.state() != Ready)
     
    18581938
    18591939    AssertReturn(event, E_FAIL);
    1860     AssertReturn(mAsyncEventQ, E_FAIL);
    1861 
    1862     if (mAsyncEventQ->postEvent (event))
     1940    AssertReturn(m->pAsyncEventQ, E_FAIL);
     1941
     1942    if (m->pAsyncEventQ->postEvent(event))
    18631943        return S_OK;
    18641944
     
    18741954 * @note Doesn't lock objects.
    18751955 */
    1876 HRESULT VirtualBox::addProgress (IProgress *aProgress)
     1956HRESULT VirtualBox::addProgress(IProgress *aProgress)
    18771957{
    18781958    CheckComArgNotNull(aProgress);
     
    18861966
    18871967    /* protect mProgressOperations */
    1888     AutoWriteLock safeLock (mSafeLock);
    1889 
    1890     mData.mProgressOperations.insert (ProgressMap::value_type (Guid(id), aProgress));
     1968    AutoWriteLock safeLock(m->mtxProgressOperations);
     1969
     1970    m->mapProgressOperations.insert (ProgressMap::value_type (Guid(id), aProgress));
    18911971    return S_OK;
    18921972}
     
    19001980 * @note Doesn't lock objects.
    19011981 */
    1902 HRESULT VirtualBox::removeProgress (IN_GUID aId)
     1982HRESULT VirtualBox::removeProgress(IN_GUID aId)
    19031983{
    19041984    AutoCaller autoCaller(this);
     
    19081988
    19091989    /* protect mProgressOperations */
    1910     AutoWriteLock safeLock (mSafeLock);
    1911 
    1912     size_t cnt = mData.mProgressOperations.erase (aId);
     1990    AutoWriteLock safeLock(m->mtxProgressOperations);
     1991
     1992    size_t cnt = m->mapProgressOperations.erase (aId);
    19131993    Assert (cnt == 1);
    19141994    NOREF(cnt);
     
    21622242{
    21632243    AutoCaller autoCaller(this);
    2164     AssertComRCReturn (autoCaller.rc(), (void) 0);
    2165 
    2166     AssertReturn(mWatcherData.mThread != NIL_RTTHREAD, (void) 0);
     2244    AssertComRCReturn(autoCaller.rc(), (void) 0);
     2245
     2246    AssertReturn(m->threadClientWatcher != NIL_RTTHREAD, (void) 0);
    21672247
    21682248    /* sent an update request */
    21692249#if defined(RT_OS_WINDOWS)
    2170     ::SetEvent (mWatcherData.mUpdateReq);
     2250    ::SetEvent (m->updateReq);
    21712251#elif defined(RT_OS_OS2)
    2172     RTSemEventSignal (mWatcherData.mUpdateReq);
     2252    RTSemEventSignal (m->updateReq);
    21732253#elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    2174     RTSemEventSignal (mWatcherData.mUpdateReq);
     2254    RTSemEventSignal (m->updateReq);
    21752255#else
    21762256# error "Port me!"
     
    21852265{
    21862266    AutoCaller autoCaller(this);
    2187     AssertComRCReturn (autoCaller.rc(), (void) 0);
     2267    AssertComRCReturn(autoCaller.rc(), (void) 0);
    21882268
    21892269    /// @todo (dmik) Win32?
    21902270#ifndef RT_OS_WINDOWS
    21912271    AutoWriteLock alock(this);
    2192     mWatcherData.mProcesses.push_back (pid);
     2272    m->llProcesses.push_back (pid);
    21932273#endif
    21942274}
     
    22692349
    22702350    AutoCaller autoCaller(this);
    2271     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     2351    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    22722352
    22732353    CallbackList list;
    22742354    {
    22752355        AutoReadLock alock(this);
    2276         list = mData.mCallbacks;
     2356        list = m->llCallbacks;
    22772357    }
    22782358
     
    24672547
    24682548    AutoCaller autoCaller(this);
    2469     AssertComRCReturn (autoCaller.rc(), type);
     2549    AssertComRCReturn(autoCaller.rc(), type);
    24702550
    24712551    AutoReadLock alock(this);
    24722552
    24732553    /* unknown type must always be the first */
    2474     ComAssertRet (mData.mGuestOSTypes.size() > 0, type);
    2475 
    2476     type = mData.mGuestOSTypes.front();
     2554    ComAssertRet (m->llGuestOSTypes.size() > 0, type);
     2555
     2556    type = m->llGuestOSTypes.front();
    24772557    return type;
    24782558}
     
    24942574 * @note Locks objects for reading.
    24952575 */
    2496 void VirtualBox::getOpenedMachines (SessionMachineVector &aMachines,
    2497                                     InternalControlVector *aControls /*= NULL*/)
     2576void VirtualBox::getOpenedMachines(SessionMachineList &aMachines,
     2577                                   InternalControlList *aControls /*= NULL*/)
    24982578{
    24992579    AutoCaller autoCaller(this);
     
    25062586    AutoReadLock alock(this);
    25072587
    2508     for (MachineList::iterator it = mData.mMachines.begin();
    2509          it != mData.mMachines.end();
    2510          ++ it)
     2588    for (MachineList::iterator it = m->llMachines.begin();
     2589         it != m->llMachines.end();
     2590         ++it)
    25112591    {
    25122592        ComObjPtr<SessionMachine> sm;
    25132593        ComPtr<IInternalSessionControl> ctl;
    2514         if ((*it)->isSessionOpen (sm, &ctl))
     2594        if ((*it)->isSessionOpen(sm, &ctl))
    25152595        {
    2516             aMachines.push_back (sm);
     2596            aMachines.push_back(sm);
    25172597            if (aControls)
    2518                 aControls->push_back (ctl);
     2598                aControls->push_back(ctl);
    25192599        }
    25202600    }
     
    25422622{
    25432623    AutoCaller autoCaller(this);
    2544     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     2624    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    25452625
    25462626    bool found = false;
     
    25492629        AutoReadLock alock(this);
    25502630
    2551         for (MachineList::iterator it = mData.mMachines.begin();
    2552              !found && it != mData.mMachines.end();
     2631        for (MachineList::iterator it = m->llMachines.begin();
     2632             !found && it != m->llMachines.end();
    25532633             ++ it)
    25542634        {
     
    26022682    if (aId)
    26032683    {
    2604         HardDiskMap::const_iterator it = mData.mHardDiskMap.find (*aId);
    2605         if (it != mData.mHardDiskMap.end())
     2684        HardDiskMap::const_iterator it = m->mapHardDisks.find (*aId);
     2685        if (it != m->mapHardDisks.end())
    26062686        {
    26072687            if (aHardDisk)
     
    26172697        Utf8Str location = aLocation;
    26182698
    2619         for (HardDiskMap::const_iterator it = mData.mHardDiskMap.begin();
    2620              it != mData.mHardDiskMap.end();
     2699        for (HardDiskMap::const_iterator it = m->mapHardDisks.begin();
     2700             it != m->mapHardDisks.end();
    26212701             ++ it)
    26222702        {
     
    26432723                     tr("Could not find a hard disk with UUID {%RTuuid} in the media registry ('%s')"),
    26442724                     aId->raw(),
    2645                      m_strSettingsFilePath.raw());
     2725                     m->strSettingsFilePath.raw());
    26462726        else
    26472727            setError(rc,
    26482728                     tr("Could not find a hard disk with location '%ls' in the media registry ('%s')"),
    26492729                     aLocation,
    2650                      m_strSettingsFilePath.raw());
     2730                     m->strSettingsFilePath.raw());
    26512731    }
    26522732
     
    26922772    bool found = false;
    26932773
    2694     for (DVDImageList::const_iterator it = mData.mDVDImages.begin();
    2695          it != mData.mDVDImages.end();
     2774    for (DVDImageList::const_iterator it = m->llDVDImages.begin();
     2775         it != m->llDVDImages.end();
    26962776         ++ it)
    26972777    {
     
    27202800                     tr("Could not find a CD/DVD image with UUID {%RTuuid} in the media registry ('%s')"),
    27212801                     aId->raw(),
    2722                      m_strSettingsFilePath.raw());
     2802                     m->strSettingsFilePath.raw());
    27232803        else
    27242804            setError(rc,
    27252805                     tr("Could not find a CD/DVD image with location '%ls' in the media registry ('%s')"),
    27262806                     aLocation,
    2727                      m_strSettingsFilePath.raw());
     2807                     m->strSettingsFilePath.raw());
    27282808    }
    27292809
     
    27682848    bool found = false;
    27692849
    2770     for (FloppyImageList::const_iterator it = mData.mFloppyImages.begin();
    2771          it != mData.mFloppyImages.end();
     2850    for (FloppyImageList::const_iterator it = m->llFloppyImages.begin();
     2851         it != m->llFloppyImages.end();
    27722852         ++ it)
    27732853    {
     
    27962876                     tr("Could not find a floppy image with UUID {%RTuuid} in the media registry ('%s')"),
    27972877                     aId->raw(),
    2798                      m_strSettingsFilePath.raw());
     2878                     m->strSettingsFilePath.raw());
    27992879        else
    28002880            setError(rc,
    28012881                     tr("Could not find a floppy image with location '%ls' in the media registry ('%s')"),
    28022882                     aLocation,
    2803                      m_strSettingsFilePath.raw());
     2883                     m->strSettingsFilePath.raw());
    28042884    }
    28052885
    28062886    return rc;
    28072887}
     2888
     2889HRESULT VirtualBox::findGuestOSType(CBSTR bstrOSType,
     2890                                    GuestOSType*& pGuestOSType)
     2891{
     2892    AutoReadLock alock(this);
     2893
     2894    /* Look for a GuestOSType object */
     2895    AssertMsg(m->llGuestOSTypes.size() != 0,
     2896              ("Guest OS types array must be filled"));
     2897
     2898    if (bstrOSType == NULL)
     2899    {
     2900        pGuestOSType = NULL;
     2901        return S_OK;
     2902    }
     2903
     2904    for (GuestOSTypeList::const_iterator it = m->llGuestOSTypes.begin();
     2905         it != m->llGuestOSTypes.end();
     2906         ++it)
     2907    {
     2908        if ((*it)->id() == bstrOSType)
     2909        {
     2910            pGuestOSType = *it;
     2911            return S_OK;
     2912        }
     2913    }
     2914
     2915    return setError(VBOX_E_OBJECT_NOT_FOUND,
     2916                    tr("Guest OS type '%ls' is invalid"),
     2917                    bstrOSType);
     2918}
     2919
     2920const ComObjPtr<Host>& VirtualBox::host() const
     2921{
     2922    return m->pHost;
     2923}
     2924
     2925const ComObjPtr<SystemProperties>& VirtualBox::systemProperties() const
     2926{
     2927    return m->pSystemProperties;
     2928}
     2929
     2930#ifdef VBOX_WITH_RESOURCE_USAGE_API
     2931const ComObjPtr<PerformanceCollector>& VirtualBox::performanceCollector() const
     2932{
     2933    return m->pPerformanceCollector;
     2934}
     2935#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    28082936
    28092937/**
     
    28142942const Utf8Str& VirtualBox::getDefaultMachineFolder() const
    28152943{
    2816     AutoReadLock propsLock(mData.mSystemProperties);
    2817     return mData.mSystemProperties->m_strDefaultMachineFolder;
     2944    AutoReadLock propsLock(m->pSystemProperties);
     2945    return m->pSystemProperties->m_strDefaultMachineFolder;
    28182946}
    28192947
     
    28252953const Utf8Str& VirtualBox::getDefaultHardDiskFolder() const
    28262954{
    2827     AutoReadLock propsLock(mData.mSystemProperties);
    2828     return mData.mSystemProperties->m_strDefaultHardDiskFolder;
     2955    AutoReadLock propsLock(m->pSystemProperties);
     2956    return m->pSystemProperties->m_strDefaultHardDiskFolder;
    28292957}
    28302958
     
    28362964const Utf8Str& VirtualBox::getDefaultHardDiskFormat() const
    28372965{
    2838     AutoReadLock propsLock(mData.mSystemProperties);
    2839     return mData.mSystemProperties->m_strDefaultHardDiskFormat;
     2966    AutoReadLock propsLock(m->pSystemProperties);
     2967    return m->pSystemProperties->m_strDefaultHardDiskFormat;
     2968}
     2969
     2970const Utf8Str& VirtualBox::homeDir() const
     2971{
     2972    return m->strHomeDir;
    28402973}
    28412974
     
    28542987{
    28552988    AutoCaller autoCaller(this);
    2856     AssertComRCReturn (autoCaller.rc(), VERR_GENERAL_FAILURE);
     2989    AssertComRCReturn(autoCaller.rc(), VERR_GENERAL_FAILURE);
    28572990
    28582991    /* no need to lock since mHomeDir is const */
    28592992
    28602993    char folder[RTPATH_MAX];
    2861     int vrc = RTPathAbsEx(mData.mHomeDir.c_str(), strPath.c_str(), folder, sizeof(folder));
     2994    int vrc = RTPathAbsEx(m->strHomeDir.c_str(), strPath.c_str(), folder, sizeof(folder));
    28622995    if (RT_SUCCESS(vrc))
    28632996        aResult = folder;
     
    28843017    /* no need to lock since mHomeDir is const */
    28853018
    2886     Utf8Str settingsDir = mData.mHomeDir;
     3019    Utf8Str settingsDir = m->strHomeDir;
    28873020
    28883021    if (RTPathStartsWith(strPath.c_str(), settingsDir.c_str()))
     
    29813114    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    29823115
    2983     AssertReturn(!m_strSettingsFilePath.isEmpty(), E_FAIL);
     3116    AssertReturn(!m->strSettingsFilePath.isEmpty(), E_FAIL);
    29843117
    29853118    HRESULT rc = S_OK;
     
    29913124    {
    29923125        // machines
    2993         m_pMainConfigFile->llMachines.clear();
    2994         for (MachineList::iterator it = mData.mMachines.begin();
    2995              it != mData.mMachines.end();
     3126        m->pMainConfigFile->llMachines.clear();
     3127        for (MachineList::iterator it = m->llMachines.begin();
     3128             it != m->llMachines.end();
    29963129             ++it)
    29973130        {
    29983131            settings::MachineRegistryEntry mre;
    29993132            rc = (*it)->saveRegistryEntry(mre);
    3000             m_pMainConfigFile->llMachines.push_back(mre);
     3133            m->pMainConfigFile->llMachines.push_back(mre);
    30013134        }
    30023135
    30033136        // hard disks
    3004         m_pMainConfigFile->llHardDisks.clear();
    3005         for (HardDiskList::const_iterator it = mData.mHardDisks.begin();
    3006              it != mData.mHardDisks.end();
     3137        m->pMainConfigFile->llHardDisks.clear();
     3138        for (HardDiskList::const_iterator it = m->llHardDisks.begin();
     3139             it != m->llHardDisks.end();
    30073140             ++it)
    30083141        {
    3009             settings::Medium m;
    3010             rc = (*it)->saveSettings(m);
    3011             m_pMainConfigFile->llHardDisks.push_back(m);
     3142            settings::Medium med;
     3143            rc = (*it)->saveSettings(med);
     3144            m->pMainConfigFile->llHardDisks.push_back(med);
    30123145            CheckComRCThrowRC(rc);
    30133146        }
    30143147
    30153148        /* CD/DVD images */
    3016         m_pMainConfigFile->llDvdImages.clear();
    3017         for (DVDImageList::const_iterator it = mData.mDVDImages.begin();
    3018              it != mData.mDVDImages.end();
     3149        m->pMainConfigFile->llDvdImages.clear();
     3150        for (DVDImageList::const_iterator it = m->llDVDImages.begin();
     3151             it != m->llDVDImages.end();
    30193152             ++it)
    30203153        {
    3021             settings::Medium m;
    3022             rc = (*it)->saveSettings(m);
     3154            settings::Medium med;
     3155            rc = (*it)->saveSettings(med);
    30233156            CheckComRCThrowRC(rc);
    3024             m_pMainConfigFile->llDvdImages.push_back(m);
     3157            m->pMainConfigFile->llDvdImages.push_back(med);
    30253158        }
    30263159
    30273160        /* floppy images */
    3028         m_pMainConfigFile->llFloppyImages.clear();
    3029         for (FloppyImageList::const_iterator it = mData.mFloppyImages.begin();
    3030              it != mData.mFloppyImages.end();
     3161        m->pMainConfigFile->llFloppyImages.clear();
     3162        for (FloppyImageList::const_iterator it = m->llFloppyImages.begin();
     3163             it != m->llFloppyImages.end();
    30313164             ++it)
    30323165        {
    3033             settings::Medium m;
    3034             rc = (*it)->saveSettings(m);
     3166            settings::Medium med;
     3167            rc = (*it)->saveSettings(med);
    30353168            CheckComRCThrowRC(rc);
    3036             m_pMainConfigFile->llFloppyImages.push_back(m);
     3169            m->pMainConfigFile->llFloppyImages.push_back(med);
    30373170        }
    30383171
    3039         m_pMainConfigFile->llDhcpServers.clear();
     3172        m->pMainConfigFile->llDhcpServers.clear();
    30403173        for (DHCPServerList::const_iterator it =
    3041                 mData.mDHCPServers.begin();
    3042                 it != mData.mDHCPServers.end();
     3174                m->llDHCPServers.begin();
     3175                it != m->llDHCPServers.end();
    30433176                ++ it)
    30443177        {
     
    30463179            rc = (*it)->saveSettings(d);
    30473180            CheckComRCThrowRC(rc);
    3048             m_pMainConfigFile->llDhcpServers.push_back(d);
     3181            m->pMainConfigFile->llDhcpServers.push_back(d);
    30493182        }
    30503183
    30513184        /* host data (USB filters) */
    3052         rc = mData.mHost->saveSettings(m_pMainConfigFile->host);
     3185        rc = m->pHost->saveSettings(m->pMainConfigFile->host);
    30533186        CheckComRCThrowRC(rc);
    30543187
    3055         rc = mData.mSystemProperties->saveSettings(m_pMainConfigFile->systemProperties);
     3188        rc = m->pSystemProperties->saveSettings(m->pMainConfigFile->systemProperties);
    30563189        CheckComRCThrowRC(rc);
    30573190
    30583191        // now write out the XML
    3059         m_pMainConfigFile->write(m_strSettingsFilePath);
     3192        m->pMainConfigFile->write(m->strSettingsFilePath);
    30603193    }
    30613194    catch (HRESULT err)
     
    31243257
    31253258    /* add to the collection of registered machines */
    3126     mData.mMachines.push_back(aMachine);
     3259    m->llMachines.push_back(aMachine);
    31273260
    31283261    if (autoCaller.state() != InInit)
     
    31533286
    31543287    AutoCaller autoCaller(this);
    3155     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3288    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    31563289
    31573290    AutoWriteLock alock(this);
    31583291
    31593292    AutoCaller hardDiskCaller (aHardDisk);
    3160     AssertComRCReturn (hardDiskCaller.rc(), hardDiskCaller.rc());
     3293    AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc());
    31613294
    31623295    AutoReadLock hardDiskLock (aHardDisk);
     
    31753308                        aHardDisk->id().raw(),
    31763309                        strConflict.raw(),
    3177                         m_strSettingsFilePath.raw());
     3310                        m->strSettingsFilePath.raw());
    31783311    }
    31793312
     
    31813314    {
    31823315        /* base (root) hard disk */
    3183         mData.mHardDisks.push_back (aHardDisk);
    3184     }
    3185 
    3186     mData.mHardDiskMap
     3316        m->llHardDisks.push_back (aHardDisk);
     3317    }
     3318
     3319    m->mapHardDisks
    31873320        .insert (HardDiskMap::value_type (
    31883321            aHardDisk->id(), HardDiskMap::mapped_type (aHardDisk)));
     
    32193352
    32203353    AutoCaller autoCaller(this);
    3221     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3354    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    32223355
    32233356    AutoWriteLock alock(this);
    32243357
    32253358    AutoCaller hardDiskCaller (aHardDisk);
    3226     AssertComRCReturn (hardDiskCaller.rc(), hardDiskCaller.rc());
     3359    AssertComRCReturn(hardDiskCaller.rc(), hardDiskCaller.rc());
    32273360
    32283361    AutoReadLock hardDiskLock (aHardDisk);
    32293362
    3230     size_t cnt = mData.mHardDiskMap.erase (aHardDisk->id());
     3363    size_t cnt = m->mapHardDisks.erase (aHardDisk->id());
    32313364    Assert (cnt == 1);
    32323365    NOREF(cnt);
     
    32353368    {
    32363369        /* base (root) hard disk */
    3237         mData.mHardDisks.remove (aHardDisk);
     3370        m->llHardDisks.remove (aHardDisk);
    32383371    }
    32393372
     
    32713404
    32723405    AutoCaller autoCaller(this);
    3273     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3406    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    32743407
    32753408    AutoWriteLock alock(this);
    32763409
    32773410    AutoCaller imageCaller (aImage);
    3278     AssertComRCReturn (imageCaller.rc(), imageCaller.rc());
     3411    AssertComRCReturn(imageCaller.rc(), imageCaller.rc());
    32793412
    32803413    AutoReadLock imageLock (aImage);
     
    32933426                        aImage->id().raw(),
    32943427                        strConflict.raw(),
    3295                         m_strSettingsFilePath.raw());
     3428                        m->strSettingsFilePath.raw());
    32963429    }
    32973430
    32983431    /* add to the collection */
    3299     mData.mDVDImages.push_back (aImage);
     3432    m->llDVDImages.push_back (aImage);
    33003433
    33013434    if (aSaveRegistry)
     
    33303463
    33313464    AutoCaller autoCaller(this);
    3332     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3465    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    33333466
    33343467    AutoWriteLock alock(this);
    33353468
    33363469    AutoCaller imageCaller (aImage);
    3337     AssertComRCReturn (imageCaller.rc(), imageCaller.rc());
     3470    AssertComRCReturn(imageCaller.rc(), imageCaller.rc());
    33383471
    33393472    AutoReadLock imageLock (aImage);
    33403473
    3341     mData.mDVDImages.remove (aImage);
     3474    m->llDVDImages.remove (aImage);
    33423475
    33433476    HRESULT rc = S_OK;
     
    33743507
    33753508    AutoCaller autoCaller(this);
    3376     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3509    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    33773510
    33783511    AutoWriteLock alock(this);
    33793512
    33803513    AutoCaller imageCaller (aImage);
    3381     AssertComRCReturn (imageCaller.rc(), imageCaller.rc());
     3514    AssertComRCReturn(imageCaller.rc(), imageCaller.rc());
    33823515
    33833516    AutoReadLock imageLock (aImage);
     
    33963529                        aImage->id().raw(),
    33973530                        strConflict.raw(),
    3398                         m_strSettingsFilePath.raw());
     3531                        m->strSettingsFilePath.raw());
    33993532    }
    34003533
    34013534    /* add to the collection */
    3402     mData.mFloppyImages.push_back (aImage);
     3535    m->llFloppyImages.push_back (aImage);
    34033536
    34043537    if (aSaveRegistry)
     
    34333566
    34343567    AutoCaller autoCaller(this);
    3435     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3568    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    34363569
    34373570    AutoWriteLock alock(this);
    34383571
    34393572    AutoCaller imageCaller (aImage);
    3440     AssertComRCReturn (imageCaller.rc(), imageCaller.rc());
     3573    AssertComRCReturn(imageCaller.rc(), imageCaller.rc());
    34413574
    34423575    AutoReadLock imageLock (aImage);
    34433576
    3444     mData.mFloppyImages.remove (aImage);
     3577    m->llFloppyImages.remove (aImage);
    34453578
    34463579    HRESULT rc = S_OK;
     
    34713604
    34723605    AutoCaller autoCaller(this);
    3473     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3606    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    34743607
    34753608    /* We need the children map lock here to keep the getDependentChild() result
     
    35083641
    35093642    AutoCaller autoCaller(this);
    3510     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     3643    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    35113644
    35123645    AutoWriteLock alock(this);
    35133646
    35143647    /* check DVD paths */
    3515     for (DVDImageList::iterator it = mData.mDVDImages.begin();
    3516          it != mData.mDVDImages.end();
     3648    for (DVDImageList::iterator it = m->llDVDImages.begin();
     3649         it != m->llDVDImages.end();
    35173650         ++ it)
    35183651    {
     
    35213654
    35223655    /* check Floppy paths */
    3523     for (FloppyImageList::iterator it = mData.mFloppyImages.begin();
    3524          it != mData.mFloppyImages  .end();
     3656    for (FloppyImageList::iterator it = m->llFloppyImages.begin();
     3657         it != m->llFloppyImages  .end();
    35253658         ++ it)
    35263659    {
     
    35293662
    35303663    /* check HardDisk paths */
    3531     for (HardDiskList::const_iterator it = mData.mHardDisks.begin();
    3532          it != mData.mHardDisks.end();
     3664    for (HardDiskList::const_iterator it = m->llHardDisks.begin();
     3665         it != m->llHardDisks.end();
    35333666         ++ it)
    35343667    {
     
    36243757}
    36253758
     3759const Utf8Str& VirtualBox::settingsFilePath()
     3760{
     3761    return m->strSettingsFilePath;
     3762}
     3763
     3764/**
     3765 * Returns a lock handle used to protect changes to the hard disk hierarchy
     3766 * (e.g. serialize access to the Medium::mParent fields and methods
     3767 * adding/removing children). When using this lock, the following rules must
     3768 * be obeyed:
     3769 *
     3770 * 1. The write lock on this handle must be either held alone on the thread
     3771 *    or requested *after* the VirtualBox object lock. Mixing with other
     3772 *    locks is prohibited.
     3773 *
     3774 * 2. The read lock on this handle may be intermixed with any other lock
     3775 *    with the exception that it must be requested *after* the VirtualBox
     3776 *    object lock.
     3777 */
     3778RWLockHandle& VirtualBox::hardDiskTreeLockHandle()
     3779{
     3780    return m->mtxHardDiskTree;
     3781}
     3782
     3783/**
     3784 * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a
     3785 * dedicated lock instead of the main object lock. The dedicated lock for
     3786 * child map operations frees callers of init() methods of these children
     3787 * from acquiring a write parent (VirtualBox) lock (which would be mandatory
     3788 * otherwise). Since VirtualBox has a lot of heterogenous children which
     3789 * init() methods are called here and there, it definitely makes sense.
     3790 */
     3791RWLockHandle* VirtualBox::childrenLock()
     3792{
     3793    return &m->mtxChildrenMap;
     3794}
     3795
    36263796/**
    36273797 *  Thread function that watches the termination of all client processes
     
    36293799 */
    36303800// static
    3631 DECLCALLBACK(int) VirtualBox::ClientWatcher (RTTHREAD /* thread */, void *pvUser)
     3801DECLCALLBACK(int) VirtualBox::ClientWatcher(RTTHREAD /* thread */, void *pvUser)
    36323802{
    36333803    LogFlowFuncEnter();
     
    36443814#if defined(RT_OS_WINDOWS)
    36453815
    3646     HRESULT hrc = CoInitializeEx (NULL,
    3647                                   COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
    3648                                   COINIT_SPEED_OVER_MEMORY);
     3816    HRESULT hrc = CoInitializeEx(NULL,
     3817                                 COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
     3818                                 COINIT_SPEED_OVER_MEMORY);
    36493819    AssertComRC (hrc);
    36503820
    36513821    /// @todo (dmik) processes reaping!
    36523822
    3653     HANDLE handles [MAXIMUM_WAIT_OBJECTS];
    3654     handles [0] = that->mWatcherData.mUpdateReq;
     3823    HANDLE handles[MAXIMUM_WAIT_OBJECTS];
     3824    handles[0] = that->m->updateReq;
    36553825
    36563826    do
     
    36663836            autoCaller.release();
    36673837
    3668             DWORD rc = ::WaitForMultipleObjects ((DWORD)(1 + cnt + cntSpawned),
    3669                                                  handles, FALSE, INFINITE);
     3838            DWORD rc = ::WaitForMultipleObjects((DWORD)(1 + cnt + cntSpawned),
     3839                                                handles,
     3840                                                FALSE,
     3841                                                INFINITE);
    36703842
    36713843            /* Restore the caller before using VirtualBox. If it fails, this
     
    37143886                machines.clear();
    37153887
    3716                 for (MachineList::iterator it = that->mData.mMachines.begin();
    3717                      it != that->mData.mMachines.end(); ++ it)
     3888                for (MachineList::iterator it = that->m->llMachines.begin();
     3889                     it != that->m->llMachines.end(); ++ it)
    37183890                {
    37193891                    /// @todo handle situations with more than 64 objects
     
    37373909                spawnedMachines.clear();
    37383910
    3739                 for (MachineList::iterator it = that->mData.mMachines.begin();
    3740                      it != that->mData.mMachines.end(); ++ it)
     3911                for (MachineList::iterator it = that->m->llMachines.begin();
     3912                     it != that->m->llMachines.end(); ++ it)
    37413913                {
    37423914                    /// @todo handle situations with more than 64 objects
     
    37973969            autoCaller.release();
    37983970
    3799             int vrc = RTSemEventWait (that->mWatcherData.mUpdateReq, 500);
     3971            int vrc = RTSemEventWait (that->m->updateReq, 500);
    38003972
    38013973            /* Restore the caller before using VirtualBox. If it fails, this
     
    39054077                    machines.clear();
    39064078
    3907                     for (MachineList::iterator it = that->mData.mMachines.begin();
    3908                          it != that->mData.mMachines.end(); ++ it)
     4079                    for (MachineList::iterator it = that->m->llMachines.begin();
     4080                         it != that->m->llMachines.end(); ++ it)
    39094081                    {
    39104082                        /// @todo handle situations with more than 64 objects
     
    39434115                    spawnedMachines.clear();
    39444116
    3945                     for (MachineList::iterator it = that->mData.mMachines.begin();
    3946                          it != that->mData.mMachines.end(); ++ it)
     4117                    for (MachineList::iterator it = that->m->llMachines.begin();
     4118                         it != that->m->llMachines.end(); ++ it)
    39474119                    {
    39484120                        if ((*it)->isSessionSpawning())
     
    39834155            autoCaller.release();
    39844156
    3985             int rc = RTSemEventWait (that->mWatcherData.mUpdateReq, 500);
     4157            int rc = RTSemEventWait(that->m->updateReq, 500);
    39864158
    39874159            /*
     
    40044176                    machines.clear();
    40054177
    4006                     for (MachineList::iterator it = that->mData.mMachines.begin();
    4007                          it != that->mData.mMachines.end(); ++ it)
     4178                    for (MachineList::iterator it = that->m->llMachines.begin();
     4179                         it != that->m->llMachines.end(); ++ it)
    40084180                    {
    40094181                        ComObjPtr<SessionMachine> sm;
     
    40214193                    spawnedMachines.clear();
    40224194
    4023                     for (MachineList::iterator it = that->mData.mMachines.begin();
    4024                          it != that->mData.mMachines.end(); ++ it)
     4195                    for (MachineList::iterator it = that->m->llMachines.begin();
     4196                         it != that->m->llMachines.end(); ++ it)
    40254197                    {
    40264198                        if ((*it)->isSessionSpawning())
     
    40444216            {
    40454217                AutoWriteLock alock(that);
    4046                 if (that->mWatcherData.mProcesses.size())
     4218                if (that->m->llProcesses.size())
    40474219                {
    40484220                    LogFlowFunc (("UPDATE: child process count = %d\n",
    4049                                   that->mWatcherData.mProcesses.size()));
    4050                     ClientWatcherData::ProcessList::iterator it =
    4051                         that->mWatcherData.mProcesses.begin();
    4052                     while (it != that->mWatcherData.mProcesses.end())
     4221                                  that->m->llProcesses.size()));
     4222                    VirtualBox::Data::ProcessList::iterator it = that->m->llProcesses.begin();
     4223                    while (it != that->m->llProcesses.end())
    40534224                    {
    40544225                        RTPROCESS pid = *it;
    40554226                        RTPROCSTATUS status;
    4056                         int vrc = ::RTProcWait (pid, RTPROCWAIT_FLAGS_NOBLOCK,
    4057                                                 &status);
     4227                        int vrc = ::RTProcWait(pid, RTPROCWAIT_FLAGS_NOBLOCK, &status);
    40584228                        if (vrc == VINF_SUCCESS)
    40594229                        {
     
    40624232                                          pid, pid, status.iStatus,
    40634233                                          status.enmReason));
    4064                             it = that->mWatcherData.mProcesses.erase (it);
     4234                            it = that->m->llProcesses.erase(it);
    40654235                        }
    40664236                        else
     
    40714241                            {
    40724242                                /* remove the process if it is not already running */
    4073                                 it = that->mWatcherData.mProcesses.erase (it);
     4243                                it = that->m->llProcesses.erase(it);
    40744244                            }
    40754245                            else
     
    41604330        /* Make a copy to release the lock before iterating */
    41614331        AutoReadLock alock(mVirtualBox);
    4162         callbacks = mVirtualBox->mData.mCallbacks;
     4332        callbacks = mVirtualBox->m->llCallbacks;
    41634333        /* We don't need mVirtualBox any more, so release it */
    41644334        mVirtualBox.setNull();
     
    42194389
    42204390    for (DHCPServerList::const_iterator it =
    4221             mData.mDHCPServers.begin();
    4222          it != mData.mDHCPServers.end();
     4391            m->llDHCPServers.begin();
     4392         it != m->llDHCPServers.end();
    42234393         ++ it)
    42244394    {
     
    42724442
    42734443    AutoCaller autoCaller(this);
    4274     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     4444    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    42754445
    42764446    AutoWriteLock alock(this);
    42774447
    42784448    AutoCaller dhcpServerCaller (aDHCPServer);
    4279     AssertComRCReturn (dhcpServerCaller.rc(), dhcpServerCaller.rc());
     4449    AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc());
    42804450
    42814451    AutoReadLock dhcpServerLock (aDHCPServer);
     
    42944464    rc = S_OK;
    42954465
    4296     mData.mDHCPServers.push_back (aDHCPServer);
     4466    m->llDHCPServers.push_back (aDHCPServer);
    42974467
    42984468    if (aSaveRegistry)
     
    43274497
    43284498    AutoCaller autoCaller(this);
    4329     AssertComRCReturn (autoCaller.rc(), autoCaller.rc());
     4499    AssertComRCReturn(autoCaller.rc(), autoCaller.rc());
    43304500
    43314501    AutoWriteLock alock(this);
    43324502
    43334503    AutoCaller dhcpServerCaller (aDHCPServer);
    4334     AssertComRCReturn (dhcpServerCaller.rc(), dhcpServerCaller.rc());
     4504    AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc());
    43354505
    43364506    AutoReadLock dhcpServerLock (aDHCPServer);
    43374507
    4338     mData.mDHCPServers.remove (aDHCPServer);
     4508    m->llDHCPServers.remove (aDHCPServer);
    43394509
    43404510    HRESULT rc = S_OK;
  • trunk/src/VBox/Main/include/VirtualBoxBase.h

    r23279 r23327  
    2424
    2525#include <iprt/cdefs.h>
    26 #include <iprt/critsect.h>
    27 #include <iprt/thread.h>
    2826
    2927#include <list>
  • trunk/src/VBox/Main/include/VirtualBoxImpl.h

    r23319 r23327  
    2727#include "VirtualBoxBase.h"
    2828
    29 #include <vector>
    30 
    3129#ifdef RT_OS_WINDOWS
    3230# include "win/resource.h"
    3331#endif
    34 
    35 #ifdef VBOX_WITH_RESOURCE_USAGE_API
    36 #include "PerformanceImpl.h"
    37 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
    3832
    3933namespace com
     
    5246class SystemProperties;
    5347class DHCPServer;
     48class PerformanceCollector;
    5449
    5550#ifdef RT_OS_WINDOWS
     
    7772
    7873    typedef std::list< ComPtr<IVirtualBoxCallback> > CallbackList;
    79     typedef std::vector< ComObjPtr<SessionMachine> > SessionMachineVector;
    80     typedef std::vector< ComPtr<IInternalSessionControl> > InternalControlVector;
     74    typedef std::list< ComObjPtr<SessionMachine> > SessionMachineList;
     75    typedef std::list< ComPtr<IInternalSessionControl> > InternalControlList;
    8176
    8277    class CallbackEvent;
     
    179174                                      BSTR *aChanged, BSTR *aValues);
    180175
    181 //    STDMETHOD(CreateDHCPServerForInterface) (/*IHostNetworkInterface * aIinterface, */IDHCPServer ** aServer);
    182176    STDMETHOD(CreateDHCPServer) (IN_BSTR aName, IDHCPServer ** aServer);
    183 //    STDMETHOD(FindDHCPServerForInterface) (IHostNetworkInterface * aIinterface, IDHCPServer ** aServer);
    184177    STDMETHOD(FindDHCPServerByNetworkName) (IN_BSTR aName, IDHCPServer ** aServer);
    185178    STDMETHOD(RemoveDHCPServer) (IDHCPServer * aServer);
     
    187180    /* public methods only for internal purposes */
    188181
    189     HRESULT postEvent (Event *event);
    190 
    191     HRESULT addProgress (IProgress *aProgress);
    192     HRESULT removeProgress (IN_GUID aId);
     182    HRESULT postEvent(Event *event);
     183
     184    HRESULT addProgress(IProgress *aProgress);
     185    HRESULT removeProgress(IN_GUID aId);
    193186
    194187#ifdef RT_OS_WINDOWS
    195188    typedef DECLCALLBACKPTR (HRESULT, SVCHelperClientFunc)
    196189        (SVCHlpClient *aClient, Progress *aProgress, void *aUser, int *aVrc);
    197     HRESULT startSVCHelperClient (bool aPrivileged,
    198                                   SVCHelperClientFunc aFunc,
    199                                   void *aUser, Progress *aProgress);
     190    HRESULT startSVCHelperClient(bool aPrivileged,
     191                                 SVCHelperClientFunc aFunc,
     192                                 void *aUser, Progress *aProgress);
    200193#endif
    201194
     
    219212    ComObjPtr<GuestOSType> getUnknownOSType();
    220213
    221     void getOpenedMachines (SessionMachineVector &aMachines,
    222                             InternalControlVector *aControls = NULL);
    223 
    224     /** Shortcut to #getOpenedMachines (aMachines, &aControls). */
    225     void getOpenedMachinesAndControls (SessionMachineVector &aMachines,
    226                                        InternalControlVector &aControls)
    227     { getOpenedMachines (aMachines, &aControls); }
    228 
    229     bool isMachineIdValid (const Guid &aId)
     214    void getOpenedMachines(SessionMachineList &aMachines,
     215                           InternalControlList *aControls = NULL);
     216
     217    bool isMachineIdValid(const Guid &aId)
    230218    {
    231         return SUCCEEDED (findMachine (aId, false /* aSetError */, NULL));
     219        return SUCCEEDED(findMachine(aId, false /* aSetError */, NULL));
    232220    }
    233221
     
    242230                            bool aSetError, ComObjPtr<Medium> *aImage = NULL);
    243231
    244     const ComObjPtr<Host> &host() { return mData.mHost; }
    245     const ComObjPtr<SystemProperties> &systemProperties()
    246         { return mData.mSystemProperties; }
     232    HRESULT findGuestOSType(CBSTR bstrOSType,
     233                            GuestOSType*& pGuestOSType);
     234
     235    const ComObjPtr<Host>& host() const;
     236    const ComObjPtr<SystemProperties>& systemProperties() const;
    247237#ifdef VBOX_WITH_RESOURCE_USAGE_API
    248     const ComObjPtr<PerformanceCollector> &performanceCollector()
    249         { return mData.mPerformanceCollector; }
     238    const ComObjPtr<PerformanceCollector>& performanceCollector() const;
    250239#endif /* VBOX_WITH_RESOURCE_USAGE_API */
    251240
     
    255244
    256245    /** Returns the VirtualBox home directory */
    257     const Utf8Str &homeDir() { return mData.mHomeDir; }
     246    const Utf8Str& homeDir() const;
    258247
    259248    int calculateFullPath(const Utf8Str &strPath, Utf8Str &aResult);
     
    278267    static HRESULT handleUnexpectedExceptions (RT_SRC_POS_DECL);
    279268
    280     const Utf8Str& settingsFilePath()
    281     {
    282         return m_strSettingsFilePath;
    283     }
    284 
    285     /**
    286      * Returns a lock handle used to protect changes to the hard disk hierarchy
    287      * (e.g. serialize access to the Medium::mParent fields and methods
    288      * adding/removing children). When using this lock, the following rules must
    289      * be obeyed:
    290      *
    291      * 1. The write lock on this handle must be either held alone on the thread
    292      *    or requested *after* the VirtualBox object lock. Mixing with other
    293      *    locks is prohibited.
    294      *
    295      * 2. The read lock on this handle may be intermixed with any other lock
    296      *    with the exception that it must be requested *after* the VirtualBox
    297      *    object lock.
    298      */
    299     RWLockHandle *hardDiskTreeLockHandle() { return &mHardDiskTreeLockHandle; }
     269    const Utf8Str& settingsFilePath();
     270
     271    RWLockHandle& hardDiskTreeLockHandle();
     272    RWLockHandle* childrenLock();
    300273
    301274    /* for VirtualBoxSupportErrorInfoImpl */
     
    304277private:
    305278
    306     typedef std::list< ComObjPtr<Machine> > MachineList;
    307     typedef std::list< ComObjPtr<GuestOSType> > GuestOSTypeList;
    308 
    309     typedef std::map<Guid, ComPtr<IProgress> > ProgressMap;
    310 
    311     typedef std::list <ComObjPtr<Medium> > HardDiskList;
    312     typedef std::list <ComObjPtr<Medium> > DVDImageList;
    313     typedef std::list <ComObjPtr<Medium> > FloppyImageList;
    314     typedef std::list <ComObjPtr<SharedFolder> > SharedFolderList;
    315     typedef std::list <ComObjPtr<DHCPServer> > DHCPServerList;
    316 
    317     typedef std::map<Guid, ComObjPtr<Medium> > HardDiskMap;
    318 
    319     /**
    320      * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a
    321      * dedicated lock instead of the main object lock. The dedicated lock for
    322      * child map operations frees callers of init() methods of these children
    323      * from acquiring a write parent (VirtualBox) lock (which would be mandatory
    324      * otherwise). Since VirtualBox has a lot of heterogenous children which
    325      * init() methods are called here and there, it definitely makes sense.
    326      */
    327     RWLockHandle *childrenLock() { return &mChildrenMapLockHandle; }
    328 
    329     HRESULT checkMediaForConflicts2 (const Guid &aId, const Bstr &aLocation,
    330                                      Utf8Str &aConflictType);
     279    HRESULT checkMediaForConflicts2(const Guid &aId, const Bstr &aLocation,
     280                                    Utf8Str &aConflictType);
    331281
    332282    HRESULT registerMachine (Machine *aMachine);
     
    337287                                 bool aSaveRegistry = true);
    338288
    339     // VirtualBox main settings file
    340     const Utf8Str m_strSettingsFilePath;
    341     settings::MainConfigFile *m_pMainConfigFile;
    342 
    343     /**
    344      *  Main VirtualBox data structure.
    345      *  @note |const| members are persistent during lifetime so can be accessed
    346      *  without locking.
    347      */
    348     struct Data
    349     {
    350         Data();
    351 
    352         // const data members not requiring locking
    353         const Utf8Str                       mHomeDir;
    354 
    355         // const objects not requiring locking
    356         const ComObjPtr<Host>               mHost;
    357         const ComObjPtr<SystemProperties>   mSystemProperties;
    358 #ifdef VBOX_WITH_RESOURCE_USAGE_API
    359         const ComObjPtr<PerformanceCollector> mPerformanceCollector;
    360 #endif /* VBOX_WITH_RESOURCE_USAGE_API */
    361 
    362         MachineList                         mMachines;
    363         GuestOSTypeList                     mGuestOSTypes;
    364 
    365         ProgressMap                         mProgressOperations;
    366 
    367         HardDiskList                        mHardDisks;
    368         DVDImageList                        mDVDImages;
    369         FloppyImageList                     mFloppyImages;
    370         SharedFolderList                    mSharedFolders;
    371         DHCPServerList                      mDHCPServers;
    372 
    373         /// @todo NEWMEDIA do we really need this map? Used only in
    374         /// find() it seems
    375         HardDiskMap                         mHardDiskMap;
    376 
    377         CallbackList                        mCallbacks;
    378     };
    379 
    380     Data mData;
    381 
    382 #if defined(RT_OS_WINDOWS)
    383     #define UPDATEREQARG NULL
    384     #define UPDATEREQTYPE HANDLE
    385 #elif defined(RT_OS_OS2)
    386     #define UPDATEREQARG NIL_RTSEMEVENT
    387     #define UPDATEREQTYPE RTSEMEVENT
    388 #elif defined(VBOX_WITH_SYS_V_IPC_SESSION_WATCHER)
    389     #define UPDATEREQARG
    390     #define UPDATEREQTYPE RTSEMEVENT
    391 #else
    392 # error "Port me!"
    393 #endif
    394 
    395     /** Client watcher thread data structure */
    396     struct ClientWatcherData
    397     {
    398         ClientWatcherData()
    399             : mUpdateReq(UPDATEREQARG),
    400               mThread(NIL_RTTHREAD)
    401         {}
    402 
    403         // const objects not requiring locking
    404         const UPDATEREQTYPE mUpdateReq;
    405         const RTTHREAD mThread;
    406 
    407         typedef std::list <RTPROCESS> ProcessList;
    408         ProcessList mProcesses;
    409     };
    410 
    411     ClientWatcherData mWatcherData;
    412 
    413     const RTTHREAD mAsyncEventThread;
    414     EventQueue * const mAsyncEventQ;
    415 
    416     /**
    417      * "Safe" lock. May only be used if guaranteed that no other locks are
    418      * requested while holding it and no functions that may do so are called.
    419      * Currently, protects the following:
    420      *
    421      * - mProgressOperations
    422      */
    423     RWLockHandle mSafeLock;
    424 
    425     RWLockHandle mHardDiskTreeLockHandle;
    426     RWLockHandle mChildrenMapLockHandle;
     289    struct Data;            // opaque data structure, defined in VirtualBoxImpl.cpp
     290    Data *m;
    427291
    428292    /* static variables (defined in VirtualBoxImpl.cpp) */
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