VirtualBox

Changeset 23379 in vbox for trunk/src


Ignore:
Timestamp:
Sep 28, 2009 2:00:18 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
52904
Message:

Main/ConsoleImpl: fix typos in error messages, whitespace cleanup, preincrement optimizations

File:
1 edited

Legend:

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

    r23335 r23379  
    118118 *    (e.g. passing it as a thread function argument). If #rc() returns a
    119119 *    failure, the Console object may not be used by the task (see
    120       Console::addCaller() for more details).
     120 *    Console::addCaller() for more details).
    121121 * 2. On successful initialization, the structure keeps the Console caller
    122122 *    until destruction (to ensure Console remains in the Ready state and won't
     
    133133    VMTask(Console *aConsole, bool aUsesVMPtr)
    134134        : mConsole(aConsole),
    135           mCallerAdded (false),
     135          mCallerAdded(false),
    136136          mVMCallerAdded(false)
    137137    {
    138         AssertReturnVoid (aConsole);
     138        AssertReturnVoid(aConsole);
    139139        mRC = aConsole->addCaller();
    140140        if (SUCCEEDED(mRC))
     
    260260
    261261Console::Console()
    262     : mSavedStateDataLoaded (false)
    263     , mConsoleVRDPServer (NULL)
    264     , mpVM (NULL)
    265     , mVMCallers (0)
    266     , mVMZeroCallersSem (NIL_RTSEMEVENT)
    267     , mVMDestroying (false)
    268     , mVMPoweredOff (false)
    269     , mVMMDev (NULL)
    270     , mAudioSniffer (NULL)
    271     , mVMStateChangeCallbackDisabled (false)
    272     , mMachineState (MachineState_PoweredOff)
    273 {
    274     for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; slot ++)
     262    : mSavedStateDataLoaded(false)
     263    , mConsoleVRDPServer(NULL)
     264    , mpVM(NULL)
     265    , mVMCallers(0)
     266    , mVMZeroCallersSem(NIL_RTSEMEVENT)
     267    , mVMDestroying(false)
     268    , mVMPoweredOff(false)
     269    , mVMMDev(NULL)
     270    , mAudioSniffer(NULL)
     271    , mVMStateChangeCallbackDisabled(false)
     272    , mMachineState(MachineState_PoweredOff)
     273{
     274    for (ULONG slot = 0; slot < SchemaDefs::NetworkAdapterCount; ++slot)
    275275        meAttachmentType[slot] = NetworkAttachmentType_Null;
    276276}
     
    304304/////////////////////////////////////////////////////////////////////////////
    305305
    306 HRESULT Console::init (IMachine *aMachine, IInternalMachineControl *aControl)
     306HRESULT Console::init(IMachine *aMachine, IInternalMachineControl *aControl)
    307307{
    308308    AssertReturn(aMachine && aControl, E_INVALIDARG);
     
    320320    unconst(mControl) = aControl;
    321321
    322     memset (&mCallbackData, 0, sizeof (mCallbackData));
     322    memset(&mCallbackData, 0, sizeof(mCallbackData));
    323323
    324324    /* Cache essential properties and objects */
    325325
    326     rc = mMachine->COMGETTER(State) (&mMachineState);
     326    rc = mMachine->COMGETTER(State)(&mMachineState);
    327327    AssertComRCReturnRC(rc);
    328328
    329329#ifdef VBOX_WITH_VRDP
    330     rc = mMachine->COMGETTER(VRDPServer) (unconst(mVRDPServer).asOutParam());
     330    rc = mMachine->COMGETTER(VRDPServer)(unconst(mVRDPServer).asOutParam());
    331331    AssertComRCReturnRC(rc);
    332332#endif
     
    335335
    336336    unconst(mGuest).createObject();
    337     rc = mGuest->init (this);
     337    rc = mGuest->init(this);
    338338    AssertComRCReturnRC(rc);
    339339
    340340    unconst(mKeyboard).createObject();
    341     rc = mKeyboard->init (this);
     341    rc = mKeyboard->init(this);
    342342    AssertComRCReturnRC(rc);
    343343
    344344    unconst(mMouse).createObject();
    345     rc = mMouse->init (this);
     345    rc = mMouse->init(this);
    346346    AssertComRCReturnRC(rc);
    347347
    348348    unconst(mDisplay).createObject();
    349     rc = mDisplay->init (this);
     349    rc = mDisplay->init(this);
    350350    AssertComRCReturnRC(rc);
    351351
    352352    unconst(mRemoteDisplayInfo).createObject();
    353     rc = mRemoteDisplayInfo->init (this);
     353    rc = mRemoteDisplayInfo->init(this);
    354354    AssertComRCReturnRC(rc);
    355355
    356356    /* Grab global and machine shared folder lists */
    357357
    358     rc = fetchSharedFolders (true /* aGlobal */);
     358    rc = fetchSharedFolders(true /* aGlobal */);
    359359    AssertComRCReturnRC(rc);
    360     rc = fetchSharedFolders (false /* aGlobal */);
     360    rc = fetchSharedFolders(false /* aGlobal */);
    361361    AssertComRCReturnRC(rc);
    362362
    363363    /* Create other child objects */
    364364
    365     unconst(mConsoleVRDPServer) = new ConsoleVRDPServer (this);
     365    unconst(mConsoleVRDPServer) = new ConsoleVRDPServer(this);
    366366    AssertReturn(mConsoleVRDPServer, E_FAIL);
    367367
     
    385385
    386386/**
    387  *  Uninitializes the Console object.
     387 * Uninitializes the Console object.
    388388 */
    389389void Console::uninit()
     
    412412    {
    413413        powerDown();
    414         Assert (mpVM == NULL);
     414        Assert(mpVM == NULL);
    415415    }
    416416
    417417    if (mVMZeroCallersSem != NIL_RTSEMEVENT)
    418418    {
    419         RTSemEventDestroy (mVMZeroCallersSem);
     419        RTSemEventDestroy(mVMZeroCallersSem);
    420420        mVMZeroCallersSem = NIL_RTSEMEVENT;
    421421    }
     
    497497    /* dynamically allocated members of mCallbackData are uninitialized
    498498     * at the end of powerDown() */
    499     Assert (!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
    500     Assert (!mCallbackData.mcc.valid);
    501     Assert (!mCallbackData.klc.valid);
     499    Assert(!mCallbackData.mpsc.valid && mCallbackData.mpsc.shape == NULL);
     500    Assert(!mCallbackData.mcc.valid);
     501    Assert(!mCallbackData.klc.valid);
    502502
    503503    LogFlowThisFuncLeave();
     
    505505
    506506#ifdef VBOX_WITH_GUEST_PROPS
    507 bool Console::enabledGuestPropertiesVRDP (void)
     507bool Console::enabledGuestPropertiesVRDP(void)
    508508{
    509509    Bstr value;
     
    519519}
    520520
    521 void Console::updateGuestPropertiesVRDPLogon (uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
     521void Console::updateGuestPropertiesVRDPLogon(uint32_t u32ClientId, const char *pszUser, const char *pszDomain)
    522522{
    523523    if (!enabledGuestPropertiesVRDP())
     
    564564}
    565565
    566 void Console::updateGuestPropertiesVRDPDisconnect (uint32_t u32ClientId)
     566void Console::updateGuestPropertiesVRDPDisconnect(uint32_t u32ClientId)
    567567{
    568568    if (!enabledGuestPropertiesVRDP())
     
    608608
    609609
    610 int Console::VRDPClientLogon (uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
     610int Console::VRDPClientLogon(uint32_t u32ClientId, const char *pszUser, const char *pszPassword, const char *pszDomain)
    611611{
    612612    LogFlowFuncEnter();
    613     LogFlowFunc (("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
     613    LogFlowFunc(("%d, %s, %s, %s\n", u32ClientId, pszUser, pszPassword, pszDomain));
    614614
    615615    AutoCaller autoCaller(this);
     
    623623
    624624    Bstr id;
    625     HRESULT hrc = mMachine->COMGETTER (Id) (id.asOutParam());
     625    HRESULT hrc = mMachine->COMGETTER(Id)(id.asOutParam());
    626626    Guid uuid = Guid(id);
    627627
    628     AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     628    AssertComRCReturn(hrc, VERR_ACCESS_DENIED);
    629629
    630630    VRDPAuthType_T authType = VRDPAuthType_Null;
    631     hrc = mVRDPServer->COMGETTER(AuthType) (&authType);
    632     AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     631    hrc = mVRDPServer->COMGETTER(AuthType)(&authType);
     632    AssertComRCReturn(hrc, VERR_ACCESS_DENIED);
    633633
    634634    ULONG authTimeout = 0;
    635     hrc = mVRDPServer->COMGETTER(AuthTimeout) (&authTimeout);
    636     AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     635    hrc = mVRDPServer->COMGETTER(AuthTimeout)(&authTimeout);
     636    AssertComRCReturn(hrc, VERR_ACCESS_DENIED);
    637637
    638638    VRDPAuthResult result = VRDPAuthAccessDenied;
     
    641641    LogFlowFunc(("Auth type %d\n", authType));
    642642
    643     LogRel (("VRDPAUTH: User: [%s]. Domain: [%s]. Authentication type: [%s]\n",
     643    LogRel(("VRDPAUTH: User: [%s]. Domain: [%s]. Authentication type: [%s]\n",
    644644                pszUser, pszDomain,
    645645                authType == VRDPAuthType_Null?
     
    665665        {
    666666            /* Call the external library. */
    667             result = mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
     667            result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
    668668
    669669            if (result != VRDPAuthDelegateToGuest)
     
    674674            LogRel(("VRDPAUTH: Delegated to guest.\n"));
    675675
    676             LogFlowFunc (("External auth asked for guest judgement\n"));
     676            LogFlowFunc(("External auth asked for guest judgement\n"));
    677677        } /* pass through */
    678678
     
    688688                uint32_t u32GuestFlags = VMMDEV_SETCREDENTIALS_JUDGE;
    689689
    690                 int rc = mVMMDev->getVMMDevPort()->pfnSetCredentials (mVMMDev->getVMMDevPort(),
     690                int rc = mVMMDev->getVMMDevPort()->pfnSetCredentials(mVMMDev->getVMMDevPort(),
    691691                             pszUser, pszPassword, pszDomain, u32GuestFlags);
    692692
    693                 if (VBOX_SUCCESS (rc))
     693                if (RT_SUCCESS(rc))
    694694                {
    695695                    /* Wait for guest. */
    696                     rc = mVMMDev->WaitCredentialsJudgement (authTimeout, &u32GuestFlags);
    697 
    698                     if (VBOX_SUCCESS (rc))
     696                    rc = mVMMDev->WaitCredentialsJudgement(authTimeout, &u32GuestFlags);
     697
     698                    if (RT_SUCCESS(rc))
    699699                    {
    700700                        switch (u32GuestFlags & (VMMDEV_CREDENTIALS_JUDGE_OK | VMMDEV_CREDENTIALS_JUDGE_DENY | VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT))
     
    704704                            case VMMDEV_CREDENTIALS_JUDGE_OK:          guestJudgement = VRDPAuthGuestAccessGranted; break;
    705705                            default:
    706                                 LogFlowFunc (("Invalid guest flags %08X!!!\n", u32GuestFlags)); break;
     706                                LogFlowFunc(("Invalid guest flags %08X!!!\n", u32GuestFlags)); break;
    707707                        }
    708708                    }
    709709                    else
    710710                    {
    711                         LogFlowFunc (("Wait for credentials judgement rc = %Rrc!!!\n", rc));
     711                        LogFlowFunc(("Wait for credentials judgement rc = %Rrc!!!\n", rc));
    712712                    }
    713713
    714                     LogFlowFunc (("Guest judgement %d\n", guestJudgement));
     714                    LogFlowFunc(("Guest judgement %d\n", guestJudgement));
    715715                }
    716716                else
    717717                {
    718                     LogFlowFunc (("Could not set credentials rc = %Rrc!!!\n", rc));
     718                    LogFlowFunc(("Could not set credentials rc = %Rrc!!!\n", rc));
    719719                }
    720720            }
     
    723723            {
    724724                LogRel(("VRDPAUTH: Guest judgement %d.\n", guestJudgement));
    725                 LogFlowFunc (("External auth called again with guest judgement = %d\n", guestJudgement));
    726                 result = mConsoleVRDPServer->Authenticate (uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
     725                LogFlowFunc(("External auth called again with guest judgement = %d\n", guestJudgement));
     726                result = mConsoleVRDPServer->Authenticate(uuid, guestJudgement, pszUser, pszPassword, pszDomain, u32ClientId);
    727727            }
    728728            else
     
    744744    }
    745745
    746     LogFlowFunc (("Result = %d\n", result));
     746    LogFlowFunc(("Result = %d\n", result));
    747747    LogFlowFuncLeave();
    748748
     
    758758    /* Multiconnection check must be made after authentication, so bad clients would not interfere with a good one. */
    759759    BOOL allowMultiConnection = FALSE;
    760     hrc = mVRDPServer->COMGETTER(AllowMultiConnection) (&allowMultiConnection);
    761     AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     760    hrc = mVRDPServer->COMGETTER(AllowMultiConnection)(&allowMultiConnection);
     761    AssertComRCReturn(hrc, VERR_ACCESS_DENIED);
    762762
    763763    BOOL reuseSingleConnection = FALSE;
    764     hrc = mVRDPServer->COMGETTER(ReuseSingleConnection) (&reuseSingleConnection);
    765     AssertComRCReturn (hrc, VERR_ACCESS_DENIED);
     764    hrc = mVRDPServer->COMGETTER(ReuseSingleConnection)(&reuseSingleConnection);
     765    AssertComRCReturn(hrc, VERR_ACCESS_DENIED);
    766766
    767767    LogFlowFunc(("allowMultiConnection %d, reuseSingleConnection = %d, mcVRDPClients = %d, mu32SingleRDPClientId = %d\n", allowMultiConnection, reuseSingleConnection, mcVRDPClients, mu32SingleRDPClientId));
     
    782782            {
    783783                LogRel(("VRDPAUTH: Multiple connections are not enabled. Disconnecting existing client.\n"));
    784                 mConsoleVRDPServer->DisconnectClient (mu32SingleRDPClientId, false);
     784                mConsoleVRDPServer->DisconnectClient(mu32SingleRDPClientId, false);
    785785            }
    786786            else
     
    797797
    798798#ifdef VBOX_WITH_GUEST_PROPS
    799     updateGuestPropertiesVRDPLogon (u32ClientId, pszUser, pszDomain);
     799    updateGuestPropertiesVRDPLogon(u32ClientId, pszUser, pszDomain);
    800800#endif /* VBOX_WITH_GUEST_PROPS */
    801801
     
    803803}
    804804
    805 void Console::VRDPClientConnect (uint32_t u32ClientId)
     805void Console::VRDPClientConnect(uint32_t u32ClientId)
    806806{
    807807    LogFlowFuncEnter();
    808808
    809809    AutoCaller autoCaller(this);
    810     AssertComRCReturnVoid (autoCaller.rc());
     810    AssertComRCReturnVoid(autoCaller.rc());
    811811
    812812#ifdef VBOX_WITH_VRDP
     
    816816    {
    817817        getVMMDev()->getVMMDevPort()->
    818             pfnVRDPChange (getVMMDev()->getVMMDevPort(),
    819                            true, VRDP_EXPERIENCE_LEVEL_FULL); // @todo configurable
     818            pfnVRDPChange(getVMMDev()->getVMMDevPort(),
     819                          true, VRDP_EXPERIENCE_LEVEL_FULL); // @todo configurable
    820820    }
    821821
    822822    NOREF(u32ClientId);
    823     mDisplay->VideoAccelVRDP (true);
     823    mDisplay->VideoAccelVRDP(true);
    824824#endif /* VBOX_WITH_VRDP */
    825825
     
    828828}
    829829
    830 void Console::VRDPClientDisconnect (uint32_t u32ClientId,
    831                                     uint32_t fu32Intercepted)
     830void Console::VRDPClientDisconnect(uint32_t u32ClientId,
     831                                   uint32_t fu32Intercepted)
    832832{
    833833    LogFlowFuncEnter();
    834834
    835835    AutoCaller autoCaller(this);
    836     AssertComRCReturnVoid (autoCaller.rc());
    837 
    838     AssertReturnVoid (mConsoleVRDPServer);
     836    AssertComRCReturnVoid(autoCaller.rc());
     837
     838    AssertReturnVoid(mConsoleVRDPServer);
    839839
    840840#ifdef VBOX_WITH_VRDP
     
    844844    {
    845845        getVMMDev()->getVMMDevPort()->
    846             pfnVRDPChange (getVMMDev()->getVMMDevPort(),
    847                            false, 0);
    848     }
    849 
    850     mDisplay->VideoAccelVRDP (false);
     846            pfnVRDPChange(getVMMDev()->getVMMDevPort(),
     847                          false, 0);
     848    }
     849
     850    mDisplay->VideoAccelVRDP(false);
    851851#endif /* VBOX_WITH_VRDP */
    852852
    853853    if (fu32Intercepted & VRDP_CLIENT_INTERCEPT_USB)
    854854    {
    855         mConsoleVRDPServer->USBBackendDelete (u32ClientId);
     855        mConsoleVRDPServer->USBBackendDelete(u32ClientId);
    856856    }
    857857
     
    859859    if (fu32Intercepted & VRDP_CLIENT_INTERCEPT_CLIPBOARD)
    860860    {
    861         mConsoleVRDPServer->ClipboardDelete (u32ClientId);
     861        mConsoleVRDPServer->ClipboardDelete(u32ClientId);
    862862    }
    863863
     
    873873                if (port)
    874874                {
    875                     port->pfnSetup (port, false, false);
     875                    port->pfnSetup(port, false, false);
    876876                }
    877877            }
     
    881881
    882882    Bstr uuid;
    883     HRESULT hrc = mMachine->COMGETTER (Id) (uuid.asOutParam());
    884     AssertComRC (hrc);
     883    HRESULT hrc = mMachine->COMGETTER(Id)(uuid.asOutParam());
     884    AssertComRC(hrc);
    885885
    886886    VRDPAuthType_T authType = VRDPAuthType_Null;
    887     hrc = mVRDPServer->COMGETTER(AuthType) (&authType);
    888     AssertComRC (hrc);
     887    hrc = mVRDPServer->COMGETTER(AuthType)(&authType);
     888    AssertComRC(hrc);
    889889
    890890    if (authType == VRDPAuthType_External)
    891         mConsoleVRDPServer->AuthDisconnect (uuid, u32ClientId);
     891        mConsoleVRDPServer->AuthDisconnect(uuid, u32ClientId);
    892892
    893893#ifdef VBOX_WITH_GUEST_PROPS
    894     updateGuestPropertiesVRDPDisconnect (u32ClientId);
     894    updateGuestPropertiesVRDPDisconnect(u32ClientId);
    895895#endif /* VBOX_WITH_GUEST_PROPS */
    896896
     
    899899}
    900900
    901 void Console::VRDPInterceptAudio (uint32_t u32ClientId)
     901void Console::VRDPInterceptAudio(uint32_t u32ClientId)
    902902{
    903903    LogFlowFuncEnter();
    904904
    905905    AutoCaller autoCaller(this);
    906     AssertComRCReturnVoid (autoCaller.rc());
    907 
    908     LogFlowFunc (("mAudioSniffer %p, u32ClientId %d.\n",
    909                   mAudioSniffer, u32ClientId));
     906    AssertComRCReturnVoid(autoCaller.rc());
     907
     908    LogFlowFunc(("mAudioSniffer %p, u32ClientId %d.\n",
     909                 mAudioSniffer, u32ClientId));
    910910    NOREF(u32ClientId);
    911911
    912912#ifdef VBOX_WITH_VRDP
    913     mcAudioRefs++;
     913    ++mcAudioRefs;
    914914
    915915    if (mcAudioRefs == 1)
     
    920920            if (port)
    921921            {
    922                 port->pfnSetup (port, true, true);
     922                port->pfnSetup(port, true, true);
    923923            }
    924924        }
     
    930930}
    931931
    932 void Console::VRDPInterceptUSB (uint32_t u32ClientId, void **ppvIntercept)
     932void Console::VRDPInterceptUSB(uint32_t u32ClientId, void **ppvIntercept)
    933933{
    934934    LogFlowFuncEnter();
    935935
    936936    AutoCaller autoCaller(this);
    937     AssertComRCReturnVoid (autoCaller.rc());
    938 
    939     AssertReturnVoid (mConsoleVRDPServer);
    940 
    941     mConsoleVRDPServer->USBBackendCreate (u32ClientId, ppvIntercept);
     937    AssertComRCReturnVoid(autoCaller.rc());
     938
     939    AssertReturnVoid(mConsoleVRDPServer);
     940
     941    mConsoleVRDPServer->USBBackendCreate(u32ClientId, ppvIntercept);
    942942
    943943    LogFlowFuncLeave();
     
    945945}
    946946
    947 void Console::VRDPInterceptClipboard (uint32_t u32ClientId)
     947void Console::VRDPInterceptClipboard(uint32_t u32ClientId)
    948948{
    949949    LogFlowFuncEnter();
    950950
    951951    AutoCaller autoCaller(this);
    952     AssertComRCReturnVoid (autoCaller.rc());
    953 
    954     AssertReturnVoid (mConsoleVRDPServer);
     952    AssertComRCReturnVoid(autoCaller.rc());
     953
     954    AssertReturnVoid(mConsoleVRDPServer);
    955955
    956956#ifdef VBOX_WITH_VRDP
    957     mConsoleVRDPServer->ClipboardCreate (u32ClientId);
     957    mConsoleVRDPServer->ClipboardCreate(u32ClientId);
    958958#endif /* VBOX_WITH_VRDP */
    959959
     
    969969
    970970/**
    971  *  Loads various console data stored in the saved state file.
    972  *  This method does validation of the state file and returns an error info
    973  *  when appropriate.
    974  *
    975  *  The method does nothing if the machine is not in the Saved file or if
    976  *  console data from it has already been loaded.
    977  *
    978  *  @note The caller must lock this object for writing.
     971 * Loads various console data stored in the saved state file.
     972 * This method does validation of the state file and returns an error info
     973 * when appropriate.
     974 *
     975 * The method does nothing if the machine is not in the Saved file or if
     976 * console data from it has already been loaded.
     977 *
     978 * @note The caller must lock this object for writing.
    979979 */
    980980HRESULT Console::loadDataFromSavedState()
     
    984984
    985985    Bstr savedStateFile;
    986     HRESULT rc = mMachine->COMGETTER(StateFilePath) (savedStateFile.asOutParam());
    987     if (FAILED (rc))
     986    HRESULT rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
     987    if (FAILED(rc))
    988988        return rc;
    989989
    990990    PSSMHANDLE ssm;
    991991    int vrc = SSMR3Open(Utf8Str(savedStateFile).c_str(), 0, &ssm);
    992     if (VBOX_SUCCESS (vrc))
     992    if (RT_SUCCESS(vrc))
    993993    {
    994994        uint32_t version = 0;
    995         vrc = SSMR3Seek (ssm, sSSMConsoleUnit, 0 /* iInstance */, &version);
    996         if (SSM_VERSION_MAJOR(version)  == SSM_VERSION_MAJOR(sSSMConsoleVer))
    997         {
    998             if (VBOX_SUCCESS (vrc))
    999                 vrc = loadStateFileExecInternal (ssm, version);
     995        vrc = SSMR3Seek(ssm, sSSMConsoleUnit, 0 /* iInstance */, &version);
     996        if (SSM_VERSION_MAJOR(version) == SSM_VERSION_MAJOR(sSSMConsoleVer))
     997        {
     998            if (RT_SUCCESS(vrc))
     999                vrc = loadStateFileExecInternal(ssm, version);
    10001000            else if (vrc == VERR_SSM_UNIT_NOT_FOUND)
    10011001                vrc = VINF_SUCCESS;
     
    10041004            vrc = VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
    10051005
    1006         SSMR3Close (ssm);
    1007     }
    1008 
    1009     if (VBOX_FAILURE (vrc))
    1010         rc = setError (VBOX_E_FILE_ERROR,
    1011             tr ("The saved state file '%ls' is invalid (%Rrc). "
    1012                 "Discard the saved state and try again"),
    1013                 savedStateFile.raw(), vrc);
     1006        SSMR3Close(ssm);
     1007    }
     1008
     1009    if (RT_FAILURE(vrc))
     1010        rc = setError(VBOX_E_FILE_ERROR,
     1011            tr("The saved state file '%ls' is invalid (%Rrc). Discard the saved state and try again"),
     1012            savedStateFile.raw(), vrc);
    10141013
    10151014    mSavedStateDataLoaded = true;
     
    10191018
    10201019/**
    1021  *  Callback handler to save various console data to the state file,
    1022  *  called when the user saves the VM state.
    1023  *
    1024  *  @param pvUser       pointer to Console
    1025  *
    1026  *  @note Locks the Console object for reading.
     1020 * Callback handler to save various console data to the state file,
     1021 * called when the user saves the VM state.
     1022 *
     1023 * @param pvUser       pointer to Console
     1024 *
     1025 * @note Locks the Console object for reading.
    10271026 */
    10281027//static
    10291028DECLCALLBACK(void)
    1030 Console::saveStateFileExec (PSSMHANDLE pSSM, void *pvUser)
    1031 {
    1032     LogFlowFunc (("\n"));
    1033 
    1034     Console *that = static_cast <Console *> (pvUser);
    1035     AssertReturnVoid (that);
     1029Console::saveStateFileExec(PSSMHANDLE pSSM, void *pvUser)
     1030{
     1031    LogFlowFunc(("\n"));
     1032
     1033    Console *that = static_cast<Console *>(pvUser);
     1034    AssertReturnVoid(that);
    10361035
    10371036    AutoCaller autoCaller(that);
    1038     AssertComRCReturnVoid (autoCaller.rc());
     1037    AssertComRCReturnVoid(autoCaller.rc());
    10391038
    10401039    AutoReadLock alock(that);
    10411040
    1042     int vrc = SSMR3PutU32 (pSSM, (uint32_t)that->mSharedFolders.size());
    1043     AssertRC (vrc);
     1041    int vrc = SSMR3PutU32(pSSM, (uint32_t)that->mSharedFolders.size());
     1042    AssertRC(vrc);
    10441043
    10451044    for (SharedFolderMap::const_iterator it = that->mSharedFolders.begin();
     
    10511050
    10521051        Utf8Str name = folder->name();
    1053         vrc = SSMR3PutU32 (pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
    1054         AssertRC (vrc);
     1052        vrc = SSMR3PutU32(pSSM, (uint32_t)name.length() + 1 /* term. 0 */);
     1053        AssertRC(vrc);
    10551054        vrc = SSMR3PutStrZ(pSSM, name.c_str());
    1056         AssertRC (vrc);
     1055        AssertRC(vrc);
    10571056
    10581057        Utf8Str hostPath = folder->hostPath();
    1059         vrc = SSMR3PutU32 (pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
    1060         AssertRC (vrc);
    1061         vrc = SSMR3PutStrZ (pSSM, hostPath.c_str());
    1062         AssertRC (vrc);
    1063 
    1064         vrc = SSMR3PutBool (pSSM, !!folder->writable());
    1065         AssertRC (vrc);
     1058        vrc = SSMR3PutU32(pSSM, (uint32_t)hostPath.length() + 1 /* term. 0 */);
     1059        AssertRC(vrc);
     1060        vrc = SSMR3PutStrZ(pSSM, hostPath.c_str());
     1061        AssertRC(vrc);
     1062
     1063        vrc = SSMR3PutBool(pSSM, !!folder->writable());
     1064        AssertRC(vrc);
    10661065    }
    10671066
     
    10701069
    10711070/**
    1072  *  Callback handler to load various console data from the state file.
    1073  *  Called when the VM is being restored from the saved state.
    1074  *
    1075  *  @param pvUser       pointer to Console
    1076  *  @param uVersion     Console unit version.
    1077  *                      Should match sSSMConsoleVer.
    1078  *  @param uPass        The data pass.
    1079  *
    1080  *  @note Should locks the Console object for writing, if necessary.
     1071 * Callback handler to load various console data from the state file.
     1072 * Called when the VM is being restored from the saved state.
     1073 *
     1074 * @param pvUser       pointer to Console
     1075 * @param uVersion     Console unit version.
     1076 *                     Should match sSSMConsoleVer.
     1077 * @param uPass        The data pass.
     1078 *
     1079 * @note Should locks the Console object for writing, if necessary.
    10811080 */
    10821081//static
     
    10841083Console::loadStateFileExec(PSSMHANDLE pSSM, void *pvUser, uint32_t uVersion, uint32_t uPass)
    10851084{
    1086     LogFlowFunc (("\n"));
     1085    LogFlowFunc(("\n"));
    10871086
    10881087    if (SSM_VERSION_MAJOR_CHANGED(uVersion, sSSMConsoleVer))
     
    10981097
    10991098/**
    1100  *  Method to load various console data from the state file.
    1101  *  Called from #loadDataFromSavedState.
    1102  *
    1103  *  @param pvUser       pointer to Console
    1104  *  @param u32Version   Console unit version.
    1105  *                      Should match sSSMConsoleVer.
    1106  *
    1107  *  @note Locks the Console object for writing.
     1099 * Method to load various console data from the state file.
     1100 * Called from #loadDataFromSavedState.
     1101 *
     1102 * @param pvUser       pointer to Console
     1103 * @param u32Version   Console unit version.
     1104 *                     Should match sSSMConsoleVer.
     1105 *
     1106 * @note Locks the Console object for writing.
    11081107 */
    11091108int
    1110 Console::loadStateFileExecInternal (PSSMHANDLE pSSM, uint32_t u32Version)
     1109Console::loadStateFileExecInternal(PSSMHANDLE pSSM, uint32_t u32Version)
    11111110{
    11121111    AutoCaller autoCaller(this);
    1113     AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
     1112    AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
    11141113
    11151114    AutoWriteLock alock(this);
     
    11181117
    11191118    uint32_t size = 0;
    1120     int vrc = SSMR3GetU32 (pSSM, &size);
    1121     AssertRCReturn (vrc, vrc);
     1119    int vrc = SSMR3GetU32(pSSM, &size);
     1120    AssertRCReturn(vrc, vrc);
    11221121
    11231122    for (uint32_t i = 0; i < size; ++ i)
     
    11301129        char *buf = NULL;
    11311130
    1132         vrc = SSMR3GetU32 (pSSM, &szBuf);
    1133         AssertRCReturn (vrc, vrc);
    1134         buf = new char [szBuf];
    1135         vrc = SSMR3GetStrZ (pSSM, buf, szBuf);
    1136         AssertRC (vrc);
     1131        vrc = SSMR3GetU32(pSSM, &szBuf);
     1132        AssertRCReturn(vrc, vrc);
     1133        buf = new char[szBuf];
     1134        vrc = SSMR3GetStrZ(pSSM, buf, szBuf);
     1135        AssertRC(vrc);
    11371136        name = buf;
    11381137        delete[] buf;
    11391138
    1140         vrc = SSMR3GetU32 (pSSM, &szBuf);
    1141         AssertRCReturn (vrc, vrc);
    1142         buf = new char [szBuf];
    1143         vrc = SSMR3GetStrZ (pSSM, buf, szBuf);
    1144         AssertRC (vrc);
     1139        vrc = SSMR3GetU32(pSSM, &szBuf);
     1140        AssertRCReturn(vrc, vrc);
     1141        buf = new char[szBuf];
     1142        vrc = SSMR3GetStrZ(pSSM, buf, szBuf);
     1143        AssertRC(vrc);
    11451144        hostPath = buf;
    11461145        delete[] buf;
    11471146
    11481147        if (u32Version > 0x00010000)
    1149             SSMR3GetBool (pSSM, &writable);
     1148            SSMR3GetBool(pSSM, &writable);
    11501149
    11511150        ComObjPtr<SharedFolder> sharedFolder;
    11521151        sharedFolder.createObject();
    1153         HRESULT rc = sharedFolder->init (this, name, hostPath, writable);
    1154         AssertComRCReturn (rc, VERR_INTERNAL_ERROR);
    1155 
    1156         mSharedFolders.insert (std::make_pair (name, sharedFolder));
     1152        HRESULT rc = sharedFolder->init(this, name, hostPath, writable);
     1153        AssertComRCReturn(rc, VERR_INTERNAL_ERROR);
     1154
     1155        mSharedFolders.insert(std::make_pair(name, sharedFolder));
    11571156    }
    11581157
     
    11631162// static
    11641163DECLCALLBACK(int)
    1165 Console::doGuestPropNotification (void *pvExtension, uint32_t,
    1166                                   void *pvParms, uint32_t cbParms)
     1164Console::doGuestPropNotification(void *pvExtension, uint32_t,
     1165                                 void *pvParms, uint32_t cbParms)
    11671166{
    11681167    using namespace guestProp;
    11691168
    1170 //     LogFlowFunc (("pvExtension=%p, pvParms=%p, cbParms=%u\n", pvExtension, pvParms, cbParms));
     1169//     LogFlowFunc(("pvExtension=%p, pvParms=%p, cbParms=%u\n", pvExtension, pvParms, cbParms));
    11711170    int rc = VINF_SUCCESS;
    11721171    /* No locking, as this is purely a notification which does not make any
     
    11751174    AssertReturn(sizeof(HOSTCALLBACKDATA) == cbParms, VERR_INVALID_PARAMETER);
    11761175    AssertReturn(HOSTCALLBACKMAGIC == pCBData->u32Magic, VERR_INVALID_PARAMETER);
    1177     ComObjPtr<Console> pConsole = reinterpret_cast <Console *> (pvExtension);
    1178 //     LogFlowFunc (("pCBData->pcszName=%s, pCBData->pcszValue=%s, pCBData->pcszFlags=%s\n", pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
     1176    ComObjPtr<Console> pConsole = reinterpret_cast<Console *>(pvExtension);
     1177//     LogFlowFunc(("pCBData->pcszName=%s, pCBData->pcszValue=%s, pCBData->pcszFlags=%s\n", pCBData->pcszName, pCBData->pcszValue, pCBData->pcszFlags));
    11791178    Bstr name(pCBData->pcszName);
    11801179    Bstr value(pCBData->pcszValue);
     
    11901189                                                            pCBData->u64Timestamp,
    11911190                                                            flags);
    1192         if (FAILED (hrc))
    1193         {
    1194 //             LogFunc (("pConsole->mControl->PushGuestProperty failed, hrc=0x%x\n", hrc));
    1195 //             LogFunc (("pCBData->pcszName=%s\n", pCBData->pcszName));
    1196 //             LogFunc (("pCBData->pcszValue=%s\n", pCBData->pcszValue));
    1197 //             LogFunc (("pCBData->pcszFlags=%s\n", pCBData->pcszFlags));
     1191        if (FAILED(hrc))
     1192        {
     1193//             LogFunc(("pConsole->mControl->PushGuestProperty failed, hrc=0x%x\n", hrc));
     1194//             LogFunc(("pCBData->pcszName=%s\n", pCBData->pcszName));
     1195//             LogFunc(("pCBData->pcszValue=%s\n", pCBData->pcszValue));
     1196//             LogFunc(("pCBData->pcszFlags=%s\n", pCBData->pcszFlags));
    11981197            rc = VERR_UNRESOLVED_ERROR;  /** @todo translate error code */
    11991198        }
    12001199    }
    1201 //     LogFlowFunc (("rc=%Rrc\n", rc));
     1200//     LogFlowFunc(("rc=%Rrc\n", rc));
    12021201    return rc;
    12031202}
    12041203
    1205 HRESULT Console::doEnumerateGuestProperties (CBSTR aPatterns,
    1206                                              ComSafeArrayOut(BSTR, aNames),
    1207                                              ComSafeArrayOut(BSTR, aValues),
    1208                                              ComSafeArrayOut(ULONG64, aTimestamps),
    1209                                              ComSafeArrayOut(BSTR, aFlags))
     1204HRESULT Console::doEnumerateGuestProperties(CBSTR aPatterns,
     1205                                            ComSafeArrayOut(BSTR, aNames),
     1206                                            ComSafeArrayOut(BSTR, aValues),
     1207                                            ComSafeArrayOut(ULONG64, aTimestamps),
     1208                                            ComSafeArrayOut(BSTR, aFlags))
    12101209{
    12111210    using namespace guestProp;
     
    12191218
    12201219    /*
    1221      * Now things get slightly complicated.  Due to a race with the guest adding
     1220     * Now things get slightly complicated. Due to a race with the guest adding
    12221221     * properties, there is no good way to know how much to enlarge a buffer for
    1223      * the service to enumerate into.  We choose a decent starting size and loop a
     1222     * the service to enumerate into. We choose a decent starting size and loop a
    12241223     * few times, each time retrying with the size suggested by the service plus
    12251224     * one Kb.
     
    12411240        parm[1].u.pointer.addr = Utf8Buf.mutableRaw();
    12421241        parm[1].u.pointer.size = (uint32_t)cchBuf + 1024;
    1243         vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3,
    1244                                      &parm[0]);
     1242        vrc = mVMMDev->hgcmHostCall("VBoxGuestPropSvc", ENUM_PROPS_HOST, 3,
     1243                                    &parm[0]);
    12451244        Utf8Buf.jolt();
    12461245        if (parm[2].type != VBOX_HGCM_SVC_PARM_32BIT)
    1247             return setError (E_FAIL, tr ("Internal application error"));
     1246            return setError(E_FAIL, tr("Internal application error"));
    12481247        cchBuf = parm[2].u.uint32;
    12491248    }
    12501249    if (VERR_BUFFER_OVERFLOW == vrc)
    1251         return setError (E_UNEXPECTED, tr ("Temporary failure due to guest activity, please retry"));
     1250        return setError(E_UNEXPECTED,
     1251            tr("Temporary failure due to guest activity, please retry"));
    12521252
    12531253    /*
    12541254     * Finally we have to unpack the data returned by the service into the safe
    1255      * arrays supplied by the caller.  We start by counting the number of entries.
     1255     * arrays supplied by the caller. We start by counting the number of entries.
    12561256     */
    12571257    const char *pszBuf
     
    13041304/////////////////////////////////////////////////////////////////////////////
    13051305
    1306 STDMETHODIMP Console::COMGETTER(Machine) (IMachine **aMachine)
     1306STDMETHODIMP Console::COMGETTER(Machine)(IMachine **aMachine)
    13071307{
    13081308    CheckComArgOutPointerValid(aMachine);
     
    13171317}
    13181318
    1319 STDMETHODIMP Console::COMGETTER(State) (MachineState_T *aMachineState)
     1319STDMETHODIMP Console::COMGETTER(State)(MachineState_T *aMachineState)
    13201320{
    13211321    CheckComArgOutPointerValid(aMachineState);
     
    13321332}
    13331333
    1334 STDMETHODIMP Console::COMGETTER(Guest) (IGuest **aGuest)
     1334STDMETHODIMP Console::COMGETTER(Guest)(IGuest **aGuest)
    13351335{
    13361336    CheckComArgOutPointerValid(aGuest);
     
    13451345}
    13461346
    1347 STDMETHODIMP Console::COMGETTER(Keyboard) (IKeyboard **aKeyboard)
     1347STDMETHODIMP Console::COMGETTER(Keyboard)(IKeyboard **aKeyboard)
    13481348{
    13491349    CheckComArgOutPointerValid(aKeyboard);
     
    13581358}
    13591359
    1360 STDMETHODIMP Console::COMGETTER(Mouse) (IMouse **aMouse)
     1360STDMETHODIMP Console::COMGETTER(Mouse)(IMouse **aMouse)
    13611361{
    13621362    CheckComArgOutPointerValid(aMouse);
     
    13711371}
    13721372
    1373 STDMETHODIMP Console::COMGETTER(Display) (IDisplay **aDisplay)
     1373STDMETHODIMP Console::COMGETTER(Display)(IDisplay **aDisplay)
    13741374{
    13751375    CheckComArgOutPointerValid(aDisplay);
     
    13841384}
    13851385
    1386 STDMETHODIMP Console::COMGETTER(Debugger) (IMachineDebugger **aDebugger)
     1386STDMETHODIMP Console::COMGETTER(Debugger)(IMachineDebugger **aDebugger)
    13871387{
    13881388    CheckComArgOutPointerValid(aDebugger);
     
    13981398    {
    13991399        unconst(mDebugger).createObject();
    1400         mDebugger->init (this);
     1400        mDebugger->init(this);
    14011401    }
    14021402
     
    14061406}
    14071407
    1408 STDMETHODIMP Console::COMGETTER(USBDevices) (ComSafeArrayOut(IUSBDevice *, aUSBDevices))
     1408STDMETHODIMP Console::COMGETTER(USBDevices)(ComSafeArrayOut(IUSBDevice *, aUSBDevices))
    14091409{
    14101410    CheckComArgOutSafeArrayPointerValid(aUSBDevices);
     
    14151415    AutoReadLock alock(this);
    14161416
    1417     SafeIfaceArray<IUSBDevice> collection (mUSBDevices);
     1417    SafeIfaceArray<IUSBDevice> collection(mUSBDevices);
    14181418    collection.detachTo(ComSafeArrayOutArg(aUSBDevices));
    14191419
     
    14211421}
    14221422
    1423 STDMETHODIMP Console::COMGETTER(RemoteUSBDevices) (ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices))
     1423STDMETHODIMP Console::COMGETTER(RemoteUSBDevices)(ComSafeArrayOut(IHostUSBDevice *, aRemoteUSBDevices))
    14241424{
    14251425    CheckComArgOutSafeArrayPointerValid(aRemoteUSBDevices);
     
    14301430    AutoReadLock alock(this);
    14311431
    1432     SafeIfaceArray<IHostUSBDevice> collection (mRemoteUSBDevices);
     1432    SafeIfaceArray<IHostUSBDevice> collection(mRemoteUSBDevices);
    14331433    collection.detachTo(ComSafeArrayOutArg(aRemoteUSBDevices));
    14341434
     
    14361436}
    14371437
    1438 STDMETHODIMP Console::COMGETTER(RemoteDisplayInfo) (IRemoteDisplayInfo **aRemoteDisplayInfo)
     1438STDMETHODIMP Console::COMGETTER(RemoteDisplayInfo)(IRemoteDisplayInfo **aRemoteDisplayInfo)
    14391439{
    14401440    CheckComArgOutPointerValid(aRemoteDisplayInfo);
     
    14501450
    14511451STDMETHODIMP
    1452 Console::COMGETTER(SharedFolders) (ComSafeArrayOut(ISharedFolder *, aSharedFolders))
     1452Console::COMGETTER(SharedFolders)(ComSafeArrayOut(ISharedFolder *, aSharedFolders))
    14531453{
    14541454    CheckComArgOutSafeArrayPointerValid(aSharedFolders);
     
    14641464    CheckComRCReturnRC(rc);
    14651465
    1466     SafeIfaceArray<ISharedFolder> sf (mSharedFolders);
     1466    SafeIfaceArray<ISharedFolder> sf(mSharedFolders);
    14671467    sf.detachTo(ComSafeArrayOutArg(aSharedFolders));
    14681468
     
    14751475
    14761476
    1477 STDMETHODIMP Console::PowerUp (IProgress **aProgress)
    1478 {
    1479     return powerUp (aProgress, false /* aPaused */);
    1480 }
    1481 
    1482 STDMETHODIMP Console::PowerUpPaused (IProgress **aProgress)
    1483 {
    1484     return powerUp (aProgress, true /* aPaused */);
    1485 }
    1486 
    1487 STDMETHODIMP Console::PowerDown (IProgress **aProgress)
     1477STDMETHODIMP Console::PowerUp(IProgress **aProgress)
     1478{
     1479    return powerUp(aProgress, false /* aPaused */);
     1480}
     1481
     1482STDMETHODIMP Console::PowerUpPaused(IProgress **aProgress)
     1483{
     1484    return powerUp(aProgress, true /* aPaused */);
     1485}
     1486
     1487STDMETHODIMP Console::PowerDown(IProgress **aProgress)
    14881488{
    14891489    if (aProgress == NULL)
     
    14981498    AutoWriteLock alock(this);
    14991499
    1500     if (!Global::IsActive (mMachineState))
     1500    if (!Global::IsActive(mMachineState))
    15011501    {
    15021502        /* extra nice error message for a common case */
    15031503        if (mMachineState == MachineState_Saved)
    1504             return setError (VBOX_E_INVALID_VM_STATE,
    1505                 tr ("Cannot power down a saved virtual machine"));
     1504            return setError(VBOX_E_INVALID_VM_STATE,
     1505                tr("Cannot power down a saved virtual machine"));
    15061506        else if (mMachineState == MachineState_Stopping)
    1507             return setError (VBOX_E_INVALID_VM_STATE,
    1508                 tr ("Virtual machine is being powered down."));
     1507            return setError(VBOX_E_INVALID_VM_STATE,
     1508                tr("Virtual machine is being powered down."));
    15091509        else
    15101510            return setError(VBOX_E_INVALID_VM_STATE,
    1511                 tr ("Invalid machine state: %d (must be Running, Paused "
    1512                     "or Stuck)"),
     1511                tr("Invalid machine state: %d (must be Running, Paused or Stuck)"),
    15131512                mMachineState);
    15141513    }
     
    15191518    ComObjPtr<Progress> progress;
    15201519    progress.createObject();
    1521     progress->init (static_cast <IConsole *> (this),
    1522                     Bstr (tr ("Stopping virtual machine")),
    1523                     FALSE /* aCancelable */);
     1520    progress->init(static_cast<IConsole *>(this),
     1521                   Bstr(tr("Stopping virtual machine")),
     1522                   FALSE /* aCancelable */);
    15241523
    15251524    /* setup task object and thread to carry out the operation asynchronously */
    1526     std::auto_ptr <VMProgressTask> task (
    1527         new VMProgressTask (this, progress, true /* aUsesVMPtr */));
     1525    std::auto_ptr <VMProgressTask> task(
     1526        new VMProgressTask(this, progress, true /* aUsesVMPtr */));
    15281527    AssertReturn(task->isOk(), E_FAIL);
    15291528
    1530     int vrc = RTThreadCreate (NULL, Console::powerDownThread,
    1531                               (void *) task.get(), 0,
    1532                               RTTHREADTYPE_MAIN_WORKER, 0,
    1533                               "VMPowerDown");
    1534     ComAssertMsgRCRet (vrc,
     1529    int vrc = RTThreadCreate(NULL, Console::powerDownThread,
     1530                             (void *) task.get(), 0,
     1531                             RTTHREADTYPE_MAIN_WORKER, 0,
     1532                             "VMPowerDown");
     1533    ComAssertMsgRCRet(vrc,
    15351534         ("Could not create VMPowerDown thread (%Rrc)", vrc), E_FAIL);
    15361535
     
    15391538
    15401539    /* go to Stopping state to forbid state-dependant operations */
    1541     setMachineState (MachineState_Stopping);
     1540    setMachineState(MachineState_Stopping);
    15421541
    15431542    /* pass the progress to the caller */
     
    15601559
    15611560    if (mMachineState != MachineState_Running)
    1562         return setError (VBOX_E_INVALID_VM_STATE,
    1563             tr ("Invalid machine state: %d)"), mMachineState);
     1561        return setError(VBOX_E_INVALID_VM_STATE,
     1562            tr("Invalid machine state: %d"),
     1563            mMachineState);
    15641564
    15651565    /* protect mpVM */
    1566     AutoVMCaller autoVMCaller (this);
     1566    AutoVMCaller autoVMCaller(this);
    15671567    CheckComRCReturnRC(autoVMCaller.rc());
    15681568
     
    15701570    alock.leave();
    15711571
    1572     int vrc = VMR3Reset (mpVM);
    1573 
    1574     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1575         setError (VBOX_E_VM_ERROR, tr ("Could not reset the machine (%Rrc)"), vrc);
     1572    int vrc = VMR3Reset(mpVM);
     1573
     1574    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1575        setError(VBOX_E_VM_ERROR,
     1576            tr("Could not reset the machine (%Rrc)"),
     1577            vrc);
    15761578
    15771579    LogFlowThisFunc(("mMachineState=%d, rc=%08X\n", mMachineState, rc));
     
    15901592
    15911593    if (mMachineState != MachineState_Running)
    1592         return setError (VBOX_E_INVALID_VM_STATE,
    1593             tr ("Invalid machine state: %d)"), mMachineState);
     1594        return setError(VBOX_E_INVALID_VM_STATE,
     1595            tr("Invalid machine state: %d)"),
     1596            mMachineState);
    15941597
    15951598    /* protect mpVM */
    1596     AutoVMCaller autoVMCaller (this);
     1599    AutoVMCaller autoVMCaller(this);
    15971600    CheckComRCReturnRC(autoVMCaller.rc());
    15981601
     
    16021605    alock.leave();
    16031606
    1604     int vrc = VMR3Suspend (mpVM);
    1605 
    1606     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1607         setError (VBOX_E_VM_ERROR,
    1608             tr ("Could not suspend the machine execution (%Rrc)"), vrc);
     1607    int vrc = VMR3Suspend(mpVM);
     1608
     1609    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1610        setError(VBOX_E_VM_ERROR,
     1611            tr("Could not suspend the machine execution (%Rrc)"),
     1612            vrc);
    16091613
    16101614    LogFlowThisFunc(("rc=%08X\n", rc));
     
    16231627
    16241628    if (mMachineState != MachineState_Paused)
    1625         return setError (VBOX_E_INVALID_VM_STATE,
    1626             tr ("Cannot resume the machine as it is not paused "
    1627                 "(machine state: %d)"), mMachineState);
     1629        return setError(VBOX_E_INVALID_VM_STATE,
     1630            tr("Cannot resume the machine as it is not paused (machine state: %d)"),
     1631            mMachineState);
    16281632
    16291633    /* protect mpVM */
    1630     AutoVMCaller autoVMCaller (this);
     1634    AutoVMCaller autoVMCaller(this);
    16311635    CheckComRCReturnRC(autoVMCaller.rc());
    16321636
     
    16381642    int vrc;
    16391643    if (VMR3GetState(mpVM) == VMSTATE_CREATED)
    1640         vrc = VMR3PowerOn (mpVM); /* (PowerUpPaused) */
     1644        vrc = VMR3PowerOn(mpVM); /* (PowerUpPaused) */
    16411645    else
    1642         vrc = VMR3Resume (mpVM);
    1643 
    1644     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1645         setError (VBOX_E_VM_ERROR,
    1646             tr ("Could not resume the machine execution (%Rrc)"), vrc);
     1646        vrc = VMR3Resume(mpVM);
     1647
     1648    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1649        setError(VBOX_E_VM_ERROR,
     1650            tr("Could not resume the machine execution (%Rrc)"),
     1651            vrc);
    16471652
    16481653    LogFlowThisFunc(("rc=%08X\n", rc));
     
    16611666
    16621667    if (mMachineState != MachineState_Running)
    1663         return setError (VBOX_E_INVALID_VM_STATE,
    1664             tr ("Invalid machine state: %d)"), mMachineState);
     1668        return setError(VBOX_E_INVALID_VM_STATE,
     1669            tr("Invalid machine state: %d)"),
     1670            mMachineState);
    16651671
    16661672    /* protect mpVM */
    1667     AutoVMCaller autoVMCaller (this);
     1673    AutoVMCaller autoVMCaller(this);
    16681674    CheckComRCReturnRC(autoVMCaller.rc());
    16691675
    16701676    PPDMIBASE pBase;
    1671     int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
    1672     if (VBOX_SUCCESS (vrc))
    1673     {
    1674         Assert (pBase);
     1677    int vrc = PDMR3QueryDeviceLun(mpVM, "acpi", 0, 0, &pBase);
     1678    if (RT_SUCCESS(vrc))
     1679    {
     1680        Assert(pBase);
    16751681        PPDMIACPIPORT pPort =
    16761682            (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
     
    16781684    }
    16791685
    1680     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1681         setError (VBOX_E_PDM_ERROR,
    1682             tr ("Controlled power off failed (%Rrc)"), vrc);
     1686    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1687        setError(VBOX_E_PDM_ERROR,
     1688            tr("Controlled power off failed (%Rrc)"),
     1689            vrc);
    16831690
    16841691    LogFlowThisFunc(("rc=%08X\n", rc));
     
    17001707
    17011708    if (mMachineState != MachineState_Running)
    1702         return setError (VBOX_E_INVALID_VM_STATE,
    1703             tr ("Invalid machine state: %d)"), mMachineState);
     1709        return setError(VBOX_E_INVALID_VM_STATE,
     1710            tr("Invalid machine state: %d)"),
     1711            mMachineState);
    17041712
    17051713    /* protect mpVM */
    1706     AutoVMCaller autoVMCaller (this);
     1714    AutoVMCaller autoVMCaller(this);
    17071715    CheckComRCReturnRC(autoVMCaller.rc());
    17081716
    17091717    PPDMIBASE pBase;
    1710     int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
     1718    int vrc = PDMR3QueryDeviceLun(mpVM, "acpi", 0, 0, &pBase);
    17111719    bool handled = false;
    1712     if (VBOX_SUCCESS (vrc))
    1713     {
    1714         Assert (pBase);
     1720    if (RT_SUCCESS(vrc))
     1721    {
     1722        Assert(pBase);
    17151723        PPDMIACPIPORT pPort =
    17161724            (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
     
    17181726    }
    17191727
    1720     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1721         setError (VBOX_E_PDM_ERROR,
    1722             tr ("Checking if the ACPI Power Button event was handled by the "
    1723                 "guest OS failed (%Rrc)"), vrc);
     1728    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1729        setError(VBOX_E_PDM_ERROR,
     1730            tr("Checking if the ACPI Power Button event was handled by the guest OS failed (%Rrc)"),
     1731            vrc);
    17241732
    17251733    *aHandled = handled;
     
    17431751
    17441752    if (mMachineState != MachineState_Running)
    1745         return setError (VBOX_E_INVALID_VM_STATE,
    1746             tr ("Invalid machine state %d when checking if the guest entered "
    1747                 "the ACPI mode)"), mMachineState);
     1753        return setError(VBOX_E_INVALID_VM_STATE,
     1754            tr("Invalid machine state %d when checking if the guest entered the ACPI mode)"),
     1755            mMachineState);
    17481756
    17491757    /* protect mpVM */
    1750     AutoVMCaller autoVMCaller (this);
     1758    AutoVMCaller autoVMCaller(this);
    17511759    CheckComRCReturnRC(autoVMCaller.rc());
    17521760
    17531761    PPDMIBASE pBase;
    1754     int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
     1762    int vrc = PDMR3QueryDeviceLun(mpVM, "acpi", 0, 0, &pBase);
    17551763    bool entered = false;
    17561764    if (RT_SUCCESS(vrc))
    17571765    {
    1758         Assert (pBase);
     1766        Assert(pBase);
    17591767        PPDMIACPIPORT pPort =
    17601768            (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
     
    17781786
    17791787    if (mMachineState != MachineState_Running)
    1780         return setError (VBOX_E_INVALID_VM_STATE,
    1781             tr ("Invalid machine state: %d)"), mMachineState);
     1788        return setError(VBOX_E_INVALID_VM_STATE,
     1789            tr("Invalid machine state: %d)"),
     1790            mMachineState);
    17821791
    17831792    /* protect mpVM */
    1784     AutoVMCaller autoVMCaller (this);
     1793    AutoVMCaller autoVMCaller(this);
    17851794    CheckComRCReturnRC(autoVMCaller.rc());
    17861795
    17871796    PPDMIBASE pBase;
    1788     int vrc = PDMR3QueryDeviceLun (mpVM, "acpi", 0, 0, &pBase);
    1789     if (VBOX_SUCCESS (vrc))
    1790     {
    1791         Assert (pBase);
     1797    int vrc = PDMR3QueryDeviceLun(mpVM, "acpi", 0, 0, &pBase);
     1798    if (RT_SUCCESS(vrc))
     1799    {
     1800        Assert(pBase);
    17921801        PPDMIACPIPORT pPort =
    17931802            (PPDMIACPIPORT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_ACPI_PORT);
     
    17951804    }
    17961805
    1797     HRESULT rc = VBOX_SUCCESS (vrc) ? S_OK :
    1798         setError (VBOX_E_PDM_ERROR,
    1799             tr ("Sending sleep button event failed (%Rrc)"), vrc);
     1806    HRESULT rc = RT_SUCCESS(vrc) ? S_OK :
     1807        setError(VBOX_E_PDM_ERROR,
     1808            tr("Sending sleep button event failed (%Rrc)"),
     1809            vrc);
    18001810
    18011811    LogFlowThisFunc(("rc=%08X\n", rc));
     
    18041814}
    18051815
    1806 STDMETHODIMP Console::SaveState (IProgress **aProgress)
     1816STDMETHODIMP Console::SaveState(IProgress **aProgress)
    18071817{
    18081818    LogFlowThisFuncEnter();
     
    18191829        mMachineState != MachineState_Paused)
    18201830    {
    1821         return setError (VBOX_E_INVALID_VM_STATE,
    1822             tr ("Cannot save the execution state as the machine "
    1823                 "is not running or paused (machine state: %d)"), mMachineState);
     1831        return setError(VBOX_E_INVALID_VM_STATE,
     1832            tr("Cannot save the execution state as the machine is not running or paused (machine state: %d)"),
     1833            mMachineState);
    18241834    }
    18251835
     
    18381848    ComObjPtr<Progress> progress;
    18391849    progress.createObject();
    1840     progress->init (static_cast <IConsole *> (this),
    1841                     Bstr (tr ("Saving the execution state of the virtual machine")),
    1842                     FALSE /* aCancelable */);
     1850    progress->init(static_cast<IConsole *>(this),
     1851                   Bstr(tr("Saving the execution state of the virtual machine")),
     1852                   FALSE /* aCancelable */);
    18431853
    18441854    bool fBeganSavingState = false;
     
    18481858    {
    18491859        /* create a task object early to ensure mpVM protection is successful */
    1850         std::auto_ptr <VMSaveTask> task (new VMSaveTask (this, progress));
     1860        std::auto_ptr <VMSaveTask> task(new VMSaveTask(this, progress));
    18511861        rc = task->rc();
    18521862        /*
    1853          *  If we fail here it means a PowerDown() call happened on another
    1854          *  thread while we were doing Pause() (which leaves the Console lock).
    1855          *  We assign PowerDown() a higher precedence than SaveState(),
    1856          *  therefore just return the error to the caller.
     1863         * If we fail here it means a PowerDown() call happened on another
     1864         * thread while we were doing Pause() (which leaves the Console lock).
     1865         * We assign PowerDown() a higher precedence than SaveState(),
     1866         * therefore just return the error to the caller.
    18571867         */
    1858         if (FAILED (rc))
     1868        if (FAILED(rc))
    18591869        {
    18601870            fTaskCreationFailed = true;
     
    18651875
    18661876        /*
    1867          *  request a saved state file path from the server
    1868          *  (this will set the machine state to Saving on the server to block
    1869          *  others from accessing this machine)
     1877         * request a saved state file path from the server
     1878         * (this will set the machine state to Saving on the server to block
     1879         * others from accessing this machine)
    18701880         */
    1871         rc = mControl->BeginSavingState (progress, stateFilePath.asOutParam());
    1872         CheckComRCBreakRC (rc);
     1881        rc = mControl->BeginSavingState(progress, stateFilePath.asOutParam());
     1882        CheckComRCBreakRC(rc);
    18731883
    18741884        fBeganSavingState = true;
    18751885
    18761886        /* sync the state with the server */
    1877         setMachineStateLocally (MachineState_Saving);
     1887        setMachineStateLocally(MachineState_Saving);
    18781888
    18791889        /* ensure the directory for the saved state file exists */
     
    18841894            {
    18851895                int vrc = RTDirCreateFullPath(dir.c_str(), 0777);
    1886                 if (VBOX_FAILURE (vrc))
     1896                if (RT_FAILURE(vrc))
    18871897                {
    1888                     rc = setError (VBOX_E_FILE_ERROR,
    1889                         tr ("Could not create a directory '%s' to save the state to (%Rrc)"),
     1898                    rc = setError(VBOX_E_FILE_ERROR,
     1899                        tr("Could not create a directory '%s' to save the state to (%Rrc)"),
    18901900                        dir.raw(), vrc);
    18911901                    break;
     
    19001910
    19011911        /* create a thread to wait until the VM state is saved */
    1902         int vrc = RTThreadCreate (NULL, Console::saveStateThread, (void *) task.get(),
    1903                                   0, RTTHREADTYPE_MAIN_WORKER, 0, "VMSave");
    1904 
    1905         ComAssertMsgRCBreak (vrc, ("Could not create VMSave thread (%Rrc)", vrc),
    1906                              rc = E_FAIL);
     1912        int vrc = RTThreadCreate(NULL, Console::saveStateThread, (void *) task.get(),
     1913                                 0, RTTHREADTYPE_MAIN_WORKER, 0, "VMSave");
     1914
     1915        ComAssertMsgRCBreak(vrc, ("Could not create VMSave thread (%Rrc)", vrc),
     1916                            rc = E_FAIL);
    19071917
    19081918        /* task is now owned by saveStateThread(), so release it */
     
    19141924    while (0);
    19151925
    1916     if (FAILED (rc) && !fTaskCreationFailed)
     1926    if (FAILED(rc) && !fTaskCreationFailed)
    19171927    {
    19181928        /* preserve existing error info */
     
    19221932        {
    19231933            /*
    1924              *  cancel the requested save state procedure.
    1925              *  This will reset the machine state to the state it had right
    1926              *  before calling mControl->BeginSavingState().
     1934             * cancel the requested save state procedure.
     1935             * This will reset the machine state to the state it had right
     1936             * before calling mControl->BeginSavingState().
    19271937             */
    1928             mControl->EndSavingState (FALSE);
     1938            mControl->EndSavingState(FALSE);
    19291939        }
    19301940
     
    19321942        {
    19331943            /* restore the paused state if appropriate */
    1934             setMachineStateLocally (MachineState_Paused);
     1944            setMachineStateLocally(MachineState_Paused);
    19351945            /* restore the running state if appropriate */
    19361946            Resume();
    19371947        }
    19381948        else
    1939             setMachineStateLocally (lastMachineState);
     1949            setMachineStateLocally(lastMachineState);
    19401950    }
    19411951
     
    19451955}
    19461956
    1947 STDMETHODIMP Console::AdoptSavedState (IN_BSTR aSavedStateFile)
     1957STDMETHODIMP Console::AdoptSavedState(IN_BSTR aSavedStateFile)
    19481958{
    19491959    CheckComArgNotNull(aSavedStateFile);
     
    19561966    if (mMachineState != MachineState_PoweredOff &&
    19571967        mMachineState != MachineState_Aborted)
    1958         return setError (VBOX_E_INVALID_VM_STATE,
    1959             tr ("Cannot adopt the saved machine state as the machine is "
    1960                 "not in Powered Off or Aborted state (machine state: %d)"),
     1968        return setError(VBOX_E_INVALID_VM_STATE,
     1969            tr("Cannot adopt the saved machine state as the machine is not in Powered Off or Aborted state (machine state: %d)"),
    19611970            mMachineState);
    19621971
    1963     return mControl->AdoptSavedState (aSavedStateFile);
     1972    return mControl->AdoptSavedState(aSavedStateFile);
    19641973}
    19651974
     
    19721981
    19731982    if (mMachineState != MachineState_Saved)
    1974         return setError (VBOX_E_INVALID_VM_STATE,
    1975             tr ("Cannot discard the machine state as the machine is "
    1976                 "not in the saved state (machine state: %d)"),
     1983        return setError(VBOX_E_INVALID_VM_STATE,
     1984            tr("Cannot discard the machine state as the machine is not in the saved state (machine state: %d)"),
    19771985            mMachineState);
    19781986
     
    19831991
    19841992    /*
    1985      *  Saved -> PoweredOff transition will be detected in the SessionMachine
    1986      *  and properly handled.
     1993     * Saved -> PoweredOff transition will be detected in the SessionMachine
     1994     * and properly handled.
    19871995     */
    1988     rc = setMachineState (MachineState_PoweredOff);
     1996    rc = setMachineState(MachineState_PoweredOff);
    19891997
    19901998    return rc;
     
    20012009}
    20022010
    2003 STDMETHODIMP Console::GetDeviceActivity (DeviceType_T aDeviceType,
    2004                                          DeviceActivity_T *aDeviceActivity)
     2011STDMETHODIMP Console::GetDeviceActivity(DeviceType_T aDeviceType,
     2012                                        DeviceActivity_T *aDeviceActivity)
    20052013{
    20062014    CheckComArgNotNull(aDeviceActivity);
     
    20102018
    20112019    /*
    2012      *  Note: we don't lock the console object here because
    2013      *  readAndClearLed() should be thread safe.
     2020     * Note: we don't lock the console object here because
     2021     * readAndClearLed() should be thread safe.
    20142022     */
    20152023
    20162024    /* Get LED array to read */
    2017     PDMLEDCORE  SumLed = {0};
     2025    PDMLEDCORE SumLed = {0};
    20182026    switch (aDeviceType)
    20192027    {
    20202028        case DeviceType_Floppy:
    20212029        {
    2022             for (unsigned i = 0; i < RT_ELEMENTS(mapFDLeds); i++)
     2030            for (unsigned i = 0; i < RT_ELEMENTS(mapFDLeds); ++i)
    20232031                SumLed.u32 |= readAndClearLed(mapFDLeds[i]);
    20242032            break;
     
    20362044            SumLed.u32 |= readAndClearLed(mapIDELeds[1]);
    20372045            SumLed.u32 |= readAndClearLed(mapIDELeds[3]);
    2038             for (unsigned i = 0; i < RT_ELEMENTS(mapSATALeds); i++)
     2046            for (unsigned i = 0; i < RT_ELEMENTS(mapSATALeds); ++i)
    20392047                SumLed.u32 |= readAndClearLed(mapSATALeds[i]);
    2040             for (unsigned i = 0; i < RT_ELEMENTS(mapSCSILeds); i++)
     2048            for (unsigned i = 0; i < RT_ELEMENTS(mapSCSILeds); ++i)
    20412049                SumLed.u32 |= readAndClearLed(mapSCSILeds[i]);
    20422050            break;
     
    20452053        case DeviceType_Network:
    20462054        {
    2047             for (unsigned i = 0; i < RT_ELEMENTS(mapNetworkLeds); i++)
     2055            for (unsigned i = 0; i < RT_ELEMENTS(mapNetworkLeds); ++i)
    20482056                SumLed.u32 |= readAndClearLed(mapNetworkLeds[i]);
    20492057            break;
     
    20522060        case DeviceType_USB:
    20532061        {
    2054             for (unsigned i = 0; i < RT_ELEMENTS(mapUSBLed); i++)
     2062            for (unsigned i = 0; i < RT_ELEMENTS(mapUSBLed); ++i)
    20552063                SumLed.u32 |= readAndClearLed(mapUSBLed[i]);
    20562064            break;
     
    20642072
    20652073        default:
    2066             return setError (E_INVALIDARG,
    2067                 tr ("Invalid device type: %d"), aDeviceType);
     2074            return setError(E_INVALIDARG,
     2075                tr("Invalid device type: %d"),
     2076                aDeviceType);
    20682077    }
    20692078
     
    20862095}
    20872096
    2088 STDMETHODIMP Console::AttachUSBDevice (IN_BSTR aId)
     2097STDMETHODIMP Console::AttachUSBDevice(IN_BSTR aId)
    20892098{
    20902099#ifdef VBOX_WITH_USB
     
    20962105    if (mMachineState != MachineState_Running &&
    20972106        mMachineState != MachineState_Paused)
    2098         return setError (VBOX_E_INVALID_VM_STATE,
    2099             tr ("Cannot attach a USB device to the machine which is not "
    2100                 "running or paused (machine state: %d)"), mMachineState);
     2107        return setError(VBOX_E_INVALID_VM_STATE,
     2108            tr("Cannot attach a USB device to the machine which is not running or paused (machine state: %d)"),
     2109            mMachineState);
    21012110
    21022111    /* protect mpVM */
    2103     AutoVMCaller autoVMCaller (this);
     2112    AutoVMCaller autoVMCaller(this);
    21042113    CheckComRCReturnRC(autoVMCaller.rc());
    21052114
    21062115    /* Don't proceed unless we've found the usb controller. */
    21072116    PPDMIBASE pBase = NULL;
    2108     int vrc = PDMR3QueryLun (mpVM, "usb-ohci", 0, 0, &pBase);
    2109     if (VBOX_FAILURE (vrc))
    2110         return setError (VBOX_E_PDM_ERROR,
    2111             tr ("The virtual machine does not have a USB controller"));
     2117    int vrc = PDMR3QueryLun(mpVM, "usb-ohci", 0, 0, &pBase);
     2118    if (RT_FAILURE(vrc))
     2119        return setError(VBOX_E_PDM_ERROR,
     2120            tr("The virtual machine does not have a USB controller"));
    21122121
    21132122    /* leave the lock because the USB Proxy service may call us back
     
    21162125
    21172126    /* Request the device capture */
    2118     HRESULT rc = mControl->CaptureUSBDevice (aId);
     2127    HRESULT rc = mControl->CaptureUSBDevice(aId);
    21192128    CheckComRCReturnRC(rc);
    21202129
     
    21222131
    21232132#else   /* !VBOX_WITH_USB */
    2124     return setError (VBOX_E_PDM_ERROR,
    2125         tr ("The virtual machine does not have a USB controller"));
     2133    return setError(VBOX_E_PDM_ERROR,
     2134        tr("The virtual machine does not have a USB controller"));
    21262135#endif  /* !VBOX_WITH_USB */
    21272136}
    21282137
    2129 STDMETHODIMP Console::DetachUSBDevice (IN_BSTR aId, IUSBDevice **aDevice)
     2138STDMETHODIMP Console::DetachUSBDevice(IN_BSTR aId, IUSBDevice **aDevice)
    21302139{
    21312140#ifdef VBOX_WITH_USB
     
    21522161
    21532162    if (!device)
    2154         return setError (E_INVALIDARG,
    2155             tr ("USB device with UUID {%RTuuid} is not attached to this machine"),
    2156             Guid (aId).raw());
     2163        return setError(E_INVALIDARG,
     2164            tr("USB device with UUID {%RTuuid} is not attached to this machine"),
     2165            Guid(aId).raw());
    21572166
    21582167    /*
     
    21602169     */
    21612170    alock.leave();
    2162     HRESULT rc2 = mControl->DetachUSBDevice (aId, false /* aDone */);
    2163     if (FAILED (rc2))
     2171    HRESULT rc2 = mControl->DetachUSBDevice(aId, false /* aDone */);
     2172    if (FAILED(rc2))
    21642173        return rc2;
    21652174    alock.enter();
    21662175
    21672176    /* Request the PDM to detach the USB device. */
    2168     HRESULT rc = detachUSBDevice (it);
     2177    HRESULT rc = detachUSBDevice(it);
    21692178
    21702179    if (SUCCEEDED(rc))
     
    21762185        /* Request the device release. Even if it fails, the device will
    21772186         * remain as held by proxy, which is OK for us (the VM process). */
    2178         rc = mControl->DetachUSBDevice (aId, true /* aDone */);
     2187        rc = mControl->DetachUSBDevice(aId, true /* aDone */);
    21792188    }
    21802189
     
    21832192
    21842193#else   /* !VBOX_WITH_USB */
    2185     return setError (VBOX_E_PDM_ERROR,
    2186         tr ("The virtual machine does not have a USB controller"));
     2194    return setError(VBOX_E_PDM_ERROR,
     2195        tr("The virtual machine does not have a USB controller"));
    21872196#endif  /* !VBOX_WITH_USB */
    21882197}
     
    21972206
    21982207    SafeIfaceArray<IUSBDevice> devsvec;
    2199     HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec));
     2208    HRESULT rc = COMGETTER(USBDevices)(ComSafeArrayAsOutParam(devsvec));
    22002209    CheckComRCReturnRC(rc);
    22012210
     
    22032212    {
    22042213        Bstr address;
    2205         rc = devsvec[i]->COMGETTER(Address) (address.asOutParam());
     2214        rc = devsvec[i]->COMGETTER(Address)(address.asOutParam());
    22062215        CheckComRCReturnRC(rc);
    22072216        if (address == aAddress)
    2208         {
    2209             ComObjPtr<OUSBDevice> found;
    2210             found.createObject();
    2211             found->init (devsvec[i]);
    2212             return found.queryInterfaceTo(aDevice);
    2213         }
    2214     }
    2215 
    2216     return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr (
    2217         "Could not find a USB device with address '%ls'"),
    2218         aAddress);
    2219 
    2220 #else   /* !VBOX_WITH_USB */
    2221     return E_NOTIMPL;
    2222 #endif  /* !VBOX_WITH_USB */
    2223 }
    2224 
    2225 STDMETHODIMP Console::FindUSBDeviceById(IN_BSTR aId, IUSBDevice **aDevice)
    2226 {
    2227 #ifdef VBOX_WITH_USB
    2228     CheckComArgExpr(aId, Guid (aId).isEmpty() == false);
    2229     CheckComArgOutPointerValid(aDevice);
    2230 
    2231     *aDevice = NULL;
    2232 
    2233     SafeIfaceArray<IUSBDevice> devsvec;
    2234     HRESULT rc = COMGETTER(USBDevices) (ComSafeArrayAsOutParam(devsvec));
    2235     CheckComRCReturnRC(rc);
    2236 
    2237     for (size_t i = 0; i < devsvec.size(); ++i)
    2238     {
    2239         Bstr id;
    2240         rc = devsvec[i]->COMGETTER(Id) (id.asOutParam());
    2241         CheckComRCReturnRC(rc);
    2242         if (id == aId)
    22432217        {
    22442218            ComObjPtr<OUSBDevice> found;
     
    22492223    }
    22502224
    2251     return setErrorNoLog (VBOX_E_OBJECT_NOT_FOUND, tr (
    2252         "Could not find a USB device with uuid {%RTuuid}"),
    2253         Guid (aId).raw());
     2225    return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND,
     2226        tr("Could not find a USB device with address '%ls'"),
     2227        aAddress);
    22542228
    22552229#else   /* !VBOX_WITH_USB */
     
    22582232}
    22592233
     2234STDMETHODIMP Console::FindUSBDeviceById(IN_BSTR aId, IUSBDevice **aDevice)
     2235{
     2236#ifdef VBOX_WITH_USB
     2237    CheckComArgExpr(aId, Guid(aId).isEmpty() == false);
     2238    CheckComArgOutPointerValid(aDevice);
     2239
     2240    *aDevice = NULL;
     2241
     2242    SafeIfaceArray<IUSBDevice> devsvec;
     2243    HRESULT rc = COMGETTER(USBDevices)(ComSafeArrayAsOutParam(devsvec));
     2244    CheckComRCReturnRC(rc);
     2245
     2246    for (size_t i = 0; i < devsvec.size(); ++i)
     2247    {
     2248        Bstr id;
     2249        rc = devsvec[i]->COMGETTER(Id)(id.asOutParam());
     2250        CheckComRCReturnRC(rc);
     2251        if (id == aId)
     2252        {
     2253            ComObjPtr<OUSBDevice> found;
     2254            found.createObject();
     2255            found->init(devsvec[i]);
     2256            return found.queryInterfaceTo(aDevice);
     2257        }
     2258    }
     2259
     2260    return setErrorNoLog(VBOX_E_OBJECT_NOT_FOUND,
     2261        tr("Could not find a USB device with uuid {%RTuuid}"),
     2262        Guid(aId).raw());
     2263
     2264#else   /* !VBOX_WITH_USB */
     2265    return E_NOTIMPL;
     2266#endif  /* !VBOX_WITH_USB */
     2267}
     2268
    22602269STDMETHODIMP
    2261 Console::CreateSharedFolder (IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
     2270Console::CreateSharedFolder(IN_BSTR aName, IN_BSTR aHostPath, BOOL aWritable)
    22622271{
    22632272    CheckComArgNotNull(aName);
     
    22712280    /// @todo see @todo in AttachUSBDevice() about the Paused state
    22722281    if (mMachineState == MachineState_Saved)
    2273         return setError (VBOX_E_INVALID_VM_STATE,
    2274             tr ("Cannot create a transient shared folder on the "
    2275                 "machine in the saved state"));
     2282        return setError(VBOX_E_INVALID_VM_STATE,
     2283            tr("Cannot create a transient shared folder on the machine in the saved state"));
    22762284    if (mMachineState > MachineState_Paused)
    2277         return setError (VBOX_E_INVALID_VM_STATE,
    2278             tr ("Cannot create a transient shared folder on the "
    2279                 "machine while it is changing the state (machine state: %d)"),
     2285        return setError(VBOX_E_INVALID_VM_STATE,
     2286            tr("Cannot create a transient shared folder on the machine while it is changing the state (machine state: %d)"),
    22802287            mMachineState);
    22812288
    22822289    ComObjPtr<SharedFolder> sharedFolder;
    2283     HRESULT rc = findSharedFolder (aName, sharedFolder, false /* aSetError */);
     2290    HRESULT rc = findSharedFolder(aName, sharedFolder, false /* aSetError */);
    22842291    if (SUCCEEDED(rc))
    2285         return setError (VBOX_E_FILE_ERROR,
    2286             tr ("Shared folder named '%ls' already exists"), aName);
     2292        return setError(VBOX_E_FILE_ERROR,
     2293            tr("Shared folder named '%ls' already exists"),
     2294            aName);
    22872295
    22882296    sharedFolder.createObject();
    2289     rc = sharedFolder->init (this, aName, aHostPath, aWritable);
     2297    rc = sharedFolder->init(this, aName, aHostPath, aWritable);
    22902298    CheckComRCReturnRC(rc);
    22912299
    22922300    /* protect mpVM (if not NULL) */
    2293     AutoVMCallerQuietWeak autoVMCaller (this);
     2301    AutoVMCallerQuietWeak autoVMCaller(this);
    22942302
    22952303    if (mpVM && autoVMCaller.isOk() && mVMMDev->isShFlActive())
     
    23002308        /* first, remove the machine or the global folder if there is any */
    23012309        SharedFolderDataMap::const_iterator it;
    2302         if (findOtherSharedFolder (aName, it))
    2303         {
    2304             rc = removeSharedFolder (aName);
     2310        if (findOtherSharedFolder(aName, it))
     2311        {
     2312            rc = removeSharedFolder(aName);
    23052313            CheckComRCReturnRC(rc);
    23062314        }
    23072315
    23082316        /* second, create the given folder */
    2309         rc = createSharedFolder (aName, SharedFolderData (aHostPath, aWritable));
     2317        rc = createSharedFolder(aName, SharedFolderData(aHostPath, aWritable));
    23102318        CheckComRCReturnRC(rc);
    23112319    }
    23122320
    2313     mSharedFolders.insert (std::make_pair (aName, sharedFolder));
     2321    mSharedFolders.insert(std::make_pair(aName, sharedFolder));
    23142322
    23152323    /* notify console callbacks after the folder is added to the list */
     
    23172325        CallbackList::iterator it = mCallbacks.begin();
    23182326        while (it != mCallbacks.end())
    2319             (*it++)->OnSharedFolderChange (Scope_Session);
     2327            (*it++)->OnSharedFolderChange(Scope_Session);
    23202328    }
    23212329
     
    23232331}
    23242332
    2325 STDMETHODIMP Console::RemoveSharedFolder (IN_BSTR aName)
     2333STDMETHODIMP Console::RemoveSharedFolder(IN_BSTR aName)
    23262334{
    23272335    CheckComArgNotNull(aName);
     
    23342342    /// @todo see @todo in AttachUSBDevice() about the Paused state
    23352343    if (mMachineState == MachineState_Saved)
    2336         return setError (VBOX_E_INVALID_VM_STATE,
    2337             tr ("Cannot remove a transient shared folder from the "
    2338                 "machine in the saved state"));
     2344        return setError(VBOX_E_INVALID_VM_STATE,
     2345            tr("Cannot remove a transient shared folder from the machine in the saved state"));
    23392346    if (mMachineState > MachineState_Paused)
    2340         return setError (VBOX_E_INVALID_VM_STATE,
    2341             tr ("Cannot remove a transient shared folder from the "
    2342                 "machine while it is changing the state (machine state: %d)"),
     2347        return setError(VBOX_E_INVALID_VM_STATE,
     2348            tr("Cannot remove a transient shared folder from the machine while it is changing the state (machine state: %d)"),
    23432349            mMachineState);
    23442350
    23452351    ComObjPtr<SharedFolder> sharedFolder;
    2346     HRESULT rc = findSharedFolder (aName, sharedFolder, true /* aSetError */);
     2352    HRESULT rc = findSharedFolder(aName, sharedFolder, true /* aSetError */);
    23472353    CheckComRCReturnRC(rc);
    23482354
    23492355    /* protect mpVM (if not NULL) */
    2350     AutoVMCallerQuietWeak autoVMCaller (this);
     2356    AutoVMCallerQuietWeak autoVMCaller(this);
    23512357
    23522358    if (mpVM && autoVMCaller.isOk() && mVMMDev->isShFlActive())
     
    23562362
    23572363        /* first, remove the given folder */
    2358         rc = removeSharedFolder (aName);
     2364        rc = removeSharedFolder(aName);
    23592365        CheckComRCReturnRC(rc);
    23602366
    23612367        /* first, remove the machine or the global folder if there is any */
    23622368        SharedFolderDataMap::const_iterator it;
    2363         if (findOtherSharedFolder (aName, it))
    2364         {
    2365             rc = createSharedFolder (aName, it->second);
     2369        if (findOtherSharedFolder(aName, it))
     2370        {
     2371            rc = createSharedFolder(aName, it->second);
    23662372            /* don't check rc here because we need to remove the console
    23672373             * folder from the collection even on failure */
     
    23692375    }
    23702376
    2371     mSharedFolders.erase (aName);
     2377    mSharedFolders.erase(aName);
    23722378
    23732379    /* notify console callbacks after the folder is removed to the list */
     
    23752381        CallbackList::iterator it = mCallbacks.begin();
    23762382        while (it != mCallbacks.end())
    2377             (*it++)->OnSharedFolderChange (Scope_Session);
     2383            (*it++)->OnSharedFolderChange(Scope_Session);
    23782384    }
    23792385
     
    24722478    {
    24732479        /*
    2474          *  If we fail here it means a PowerDown() call happened on another
    2475          *  thread while we were doing Pause() (which leaves the Console lock).
    2476          *  We assign PowerDown() a higher precedence than TakeSnapshot(),
    2477          *  therefore just return the error to the caller.
     2480         * If we fail here it means a PowerDown() call happened on another
     2481         * thread while we were doing Pause() (which leaves the Console lock).
     2482         * We assign PowerDown() a higher precedence than TakeSnapshot(),
     2483         * therefore just return the error to the caller.
    24782484         */
    24792485        rc = pTask->rc();
     
    25202526STDMETHODIMP Console::DiscardSnapshot(IN_BSTR aId, IProgress **aProgress)
    25212527{
    2522     CheckComArgExpr(aId, Guid (aId).isEmpty() == false);
     2528    CheckComArgExpr(aId, Guid(aId).isEmpty() == false);
    25232529    CheckComArgOutPointerValid(aProgress);
    25242530
     
    25282534    AutoWriteLock alock(this);
    25292535
    2530     if (Global::IsOnlineOrTransient (mMachineState))
    2531         return setError (VBOX_E_INVALID_VM_STATE,
    2532             tr ("Cannot discard a snapshot of the running machine "
    2533                 "(machine state: %d)"),
     2536    if (Global::IsOnlineOrTransient(mMachineState))
     2537        return setError(VBOX_E_INVALID_VM_STATE,
     2538            tr("Cannot discard a snapshot of the running machine (machine state: %d)"),
    25342539            mMachineState);
    25352540
    25362541    MachineState_T machineState = MachineState_Null;
    2537     HRESULT rc = mControl->DiscardSnapshot (this, aId, &machineState, aProgress);
     2542    HRESULT rc = mControl->DiscardSnapshot(this, aId, &machineState, aProgress);
    25382543    CheckComRCReturnRC(rc);
    25392544
    2540     setMachineStateLocally (machineState);
     2545    setMachineStateLocally(machineState);
    25412546    return S_OK;
    25422547}
    25432548
    2544 STDMETHODIMP Console::DiscardCurrentState (IProgress **aProgress)
     2549STDMETHODIMP Console::DiscardCurrentState(IProgress **aProgress)
    25452550{
    25462551    AutoCaller autoCaller(this);
     
    25492554    AutoWriteLock alock(this);
    25502555
    2551     if (Global::IsOnlineOrTransient (mMachineState))
    2552         return setError (VBOX_E_INVALID_VM_STATE,
    2553             tr ("Cannot discard the current state of the running machine "
    2554                 "(nachine state: %d)"),
     2556    if (Global::IsOnlineOrTransient(mMachineState))
     2557        return setError(VBOX_E_INVALID_VM_STATE,
     2558            tr("Cannot discard the current state of the running machine (machine state: %d)"),
    25552559            mMachineState);
    25562560
    25572561    MachineState_T machineState = MachineState_Null;
    2558     HRESULT rc = mControl->DiscardCurrentState (this, &machineState, aProgress);
     2562    HRESULT rc = mControl->DiscardCurrentState(this, &machineState, aProgress);
    25592563    CheckComRCReturnRC(rc);
    25602564
    2561     setMachineStateLocally (machineState);
     2565    setMachineStateLocally(machineState);
    25622566    return S_OK;
    25632567}
    25642568
    2565 STDMETHODIMP Console::DiscardCurrentSnapshotAndState (IProgress **aProgress)
     2569STDMETHODIMP Console::DiscardCurrentSnapshotAndState(IProgress **aProgress)
    25662570{
    25672571    AutoCaller autoCaller(this);
     
    25702574    AutoWriteLock alock(this);
    25712575
    2572     if (Global::IsOnlineOrTransient (mMachineState))
    2573         return setError (VBOX_E_INVALID_VM_STATE,
    2574             tr ("Cannot discard the current snapshot and state of the "
    2575                 "running machine (machine state: %d)"),
     2576    if (Global::IsOnlineOrTransient(mMachineState))
     2577        return setError(VBOX_E_INVALID_VM_STATE,
     2578            tr("Cannot discard the current snapshot and state of the running machine (machine state: %d)"),
    25762579            mMachineState);
    25772580
    25782581    MachineState_T machineState = MachineState_Null;
    25792582    HRESULT rc =
    2580         mControl->DiscardCurrentSnapshotAndState (this, &machineState, aProgress);
     2583        mControl->DiscardCurrentSnapshotAndState(this, &machineState, aProgress);
    25812584    CheckComRCReturnRC(rc);
    25822585
    2583     setMachineStateLocally (machineState);
     2586    setMachineStateLocally(machineState);
    25842587    return S_OK;
    25852588}
    25862589
    2587 STDMETHODIMP Console::RegisterCallback (IConsoleCallback *aCallback)
     2590STDMETHODIMP Console::RegisterCallback(IConsoleCallback *aCallback)
    25882591{
    25892592    CheckComArgNotNull(aCallback);
     
    26022605    AutoWriteLock alock(this);
    26032606
    2604     mCallbacks.push_back (CallbackList::value_type (aCallback));
     2607    mCallbacks.push_back(CallbackList::value_type(aCallback));
    26052608
    26062609    /* Inform the callback about the current status (for example, the new
     
    26092612
    26102613    if (mCallbackData.mpsc.valid)
    2611         aCallback->OnMousePointerShapeChange (mCallbackData.mpsc.visible,
    2612                                               mCallbackData.mpsc.alpha,
    2613                                               mCallbackData.mpsc.xHot,
    2614                                               mCallbackData.mpsc.yHot,
    2615                                               mCallbackData.mpsc.width,
    2616                                               mCallbackData.mpsc.height,
    2617                                               mCallbackData.mpsc.shape);
     2614        aCallback->OnMousePointerShapeChange(mCallbackData.mpsc.visible,
     2615                                             mCallbackData.mpsc.alpha,
     2616                                             mCallbackData.mpsc.xHot,
     2617                                             mCallbackData.mpsc.yHot,
     2618                                             mCallbackData.mpsc.width,
     2619                                             mCallbackData.mpsc.height,
     2620                                             mCallbackData.mpsc.shape);
    26182621    if (mCallbackData.mcc.valid)
    2619         aCallback->OnMouseCapabilityChange (mCallbackData.mcc.supportsAbsolute,
    2620                                             mCallbackData.mcc.needsHostCursor);
     2622        aCallback->OnMouseCapabilityChange(mCallbackData.mcc.supportsAbsolute,
     2623                                           mCallbackData.mcc.needsHostCursor);
    26212624
    26222625    aCallback->OnAdditionsStateChange();
    26232626
    26242627    if (mCallbackData.klc.valid)
    2625         aCallback->OnKeyboardLedsChange (mCallbackData.klc.numLock,
    2626                                          mCallbackData.klc.capsLock,
    2627                                          mCallbackData.klc.scrollLock);
     2628        aCallback->OnKeyboardLedsChange(mCallbackData.klc.numLock,
     2629                                        mCallbackData.klc.capsLock,
     2630                                        mCallbackData.klc.scrollLock);
    26282631
    26292632    /* Note: we don't call OnStateChange for new callbacks because the
     
    26342637}
    26352638
    2636 STDMETHODIMP Console::UnregisterCallback (IConsoleCallback *aCallback)
     2639STDMETHODIMP Console::UnregisterCallback(IConsoleCallback *aCallback)
    26372640{
    26382641    CheckComArgNotNull(aCallback);
     
    26442647
    26452648    CallbackList::iterator it;
    2646     it = std::find (mCallbacks.begin(),
    2647                     mCallbacks.end(),
    2648                     CallbackList::value_type (aCallback));
     2649    it = std::find(mCallbacks.begin(),
     2650                   mCallbacks.end(),
     2651                   CallbackList::value_type(aCallback));
    26492652    if (it == mCallbacks.end())
    2650         return setError (E_INVALIDARG,
    2651             tr ("The given callback handler is not registered"));
    2652 
    2653     mCallbacks.erase (it);
     2653        return setError(E_INVALIDARG,
     2654            tr("The given callback handler is not registered"));
     2655
     2656    mCallbacks.erase(it);
    26542657    return S_OK;
    26552658}
     
    26882691        {
    26892692            AssertMsgReturn(port < 2 && port >= 0, ("%d\n", port), E_INVALIDARG);
    2690             AssertMsgReturn(device < 2 && device >= 0, ("%d\n", device),  E_INVALIDARG);
     2693            AssertMsgReturn(device < 2 && device >= 0, ("%d\n", device), E_INVALIDARG);
    26912694            uLun = 2 * port + device;
    26922695            return S_OK;
     
    27332736    AssertComRC(rc);
    27342737    ComPtr<IStorageController> ctrl;
    2735     for (size_t i = 0; i < ctrls.size(); i++)
     2738    for (size_t i = 0; i < ctrls.size(); ++i)
    27362739    {
    27372740        Bstr ctrlName;
     
    28152818    if (!location.isEmpty())
    28162819        return setError(E_FAIL,
    2817                         tr("Could not mount the media/drive '%s' (%Rrc)"), location.raw(), vrc);
     2820            tr("Could not mount the media/drive '%s' (%Rrc)"),
     2821            location.raw(), vrc);
    28182822
    28192823    return setError(E_FAIL,
    2820                     tr("Could not unmount the currently mounted media/drive (%Rrc)"), vrc);
     2824        tr("Could not unmount the currently mounted media/drive (%Rrc)"),
     2825        vrc);
    28212826}
    28222827
     
    28432848 * @todo the error handling in this method needs to be improved seriously - what if mounting fails...
    28442849 */
    2845 DECLCALLBACK(int) Console::changeDrive (Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun,
    2846                                         const char *pszPath, bool fPassthrough)
    2847 {
    2848 /// @todo FIXME - this isn't called right now
    2849     LogFlowFunc (("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u pszPath=%p:{%s} fPassthrough=%d\n",
    2850                   pThis, pszDevice, pszDevice, uInstance, uLun, pszPath, pszPath, fPassthrough));
     2850DECLCALLBACK(int) Console::changeDrive(Console *pThis, const char *pszDevice, unsigned uInstance, unsigned uLun,
     2851                                       const char *pszPath, bool fPassthrough)
     2852{
     2853/// @todo change this to use the same code as in ConsoleImpl2.cpp
     2854    LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u pszPath=%p:{%s} fPassthrough=%d\n",
     2855                 pThis, pszDevice, pszDevice, uInstance, uLun, pszPath, pszPath, fPassthrough));
    28512856
    28522857    AssertReturn(pThis, VERR_INVALID_PARAMETER);
    28532858
    28542859    AutoCaller autoCaller(pThis);
    2855     AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
     2860    AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
    28562861
    28572862    /* protect mpVM */
    2858     AutoVMCaller autoVMCaller (pThis);
     2863    AutoVMCaller autoVMCaller(pThis);
    28592864    CheckComRCReturnRC(autoVMCaller.rc());
    28602865
     
    28682873     */
    28692874    bool fResume;
    2870     VMSTATE enmVMState = VMR3GetState (pVM);
     2875    VMSTATE enmVMState = VMR3GetState(pVM);
    28712876    switch (enmVMState)
    28722877    {
     
    28742879        case VMSTATE_RUNNING:
    28752880        {
    2876             LogFlowFunc (("Suspending the VM...\n"));
     2881            LogFlowFunc(("Suspending the VM...\n"));
    28772882            /* disable the callback to prevent Console-level state change */
    28782883            pThis->mVMStateChangeCallbackDisabled = true;
    2879             int rc = VMR3Suspend (pVM);
     2884            int rc = VMR3Suspend(pVM);
    28802885            pThis->mVMStateChangeCallbackDisabled = false;
    2881             AssertRCReturn (rc, rc);
     2886            AssertRCReturn(rc, rc);
    28822887            fResume = true;
    28832888            break;
     
    28912896
    28922897        default:
    2893             AssertMsgFailedReturn (("enmVMState=%d\n", enmVMState), VERR_ACCESS_DENIED);
     2898            AssertMsgFailedReturn(("enmVMState=%d\n", enmVMState), VERR_ACCESS_DENIED);
    28942899    }
    28952900
     
    29132918         * Unmount existing media / detach host drive.
    29142919         */
    2915         PPDMIMOUNT  pIMount = NULL;
    2916         PPDMIBASE   pBase;
    2917         rc = PDMR3QueryLun (pVM, pszDevice, uInstance, uLun, &pBase);
    2918         if (VBOX_FAILURE (rc))
     2920        PPDMIMOUNT pIMount = NULL;
     2921        PPDMIBASE pBase;
     2922        rc = PDMR3QueryLun(pVM, pszDevice, uInstance, uLun, &pBase);
     2923        if (RT_FAILURE(rc))
    29192924        {
    29202925            if (rc == VERR_PDM_LUN_NOT_FOUND)
    29212926                rc = VINF_SUCCESS;
    2922             AssertRC (rc);
     2927            AssertRC(rc);
    29232928        }
    29242929        else
    29252930        {
    2926             pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface (pBase, PDMINTERFACE_MOUNT);
    2927             AssertBreakStmt (pIMount, rc = VERR_INVALID_POINTER);
     2931            pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_MOUNT);
     2932            AssertBreakStmt(pIMount, rc = VERR_INVALID_POINTER);
    29282933
    29292934            /*
    29302935             * Unmount the media.
    29312936             */
    2932             rc = pIMount->pfnUnmount (pIMount, false);
     2937            rc = pIMount->pfnUnmount(pIMount, false);
    29332938            if (rc == VERR_PDM_MEDIA_NOT_MOUNTED)
    29342939                rc = VINF_SUCCESS;
    29352940        }
    29362941
    2937         if (VBOX_FAILURE (rc))
     2942        if (RT_FAILURE(rc))
    29382943        {
    29392944            rcRet = rc;
     
    29442949         * Construct a new driver configuration.
    29452950         */
    2946         PCFGMNODE pInst = CFGMR3GetChildF (CFGMR3GetRoot (pVM), "Devices/%s/%d/", pszDevice, uInstance);
    2947         AssertRelease (pInst);
     2951        PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%d/", pszDevice, uInstance);
     2952        AssertRelease(pInst);
    29482953        /* nuke anything which might have been left behind. */
    2949         CFGMR3RemoveNode (CFGMR3GetChildF (pInst, "LUN#%d", uLun));
    2950 
    2951 #define RC_CHECK()  do { if (VBOX_FAILURE (rc)) { AssertReleaseRC (rc); break; } } while (0)
     2954        CFGMR3RemoveNode(CFGMR3GetChildF(pInst, "LUN#%d", uLun));
     2955
     2956#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertReleaseRC(rc); break; } } while (0)
    29522957
    29532958        /* create a new block driver config */
    29542959        PCFGMNODE pLunL0;
    2955         rc = CFGMR3InsertNodeF (pInst, &pLunL0, "LUN#%d", uLun);    RC_CHECK();
    2956         rc = CFGMR3InsertString (pLunL0, "Driver",      "Block");   RC_CHECK();
     2960        rc = CFGMR3InsertNodeF(pInst, &pLunL0, "LUN#%d", uLun);     RC_CHECK();
     2961        rc = CFGMR3InsertString(pLunL0, "Driver",       "Block");   RC_CHECK();
    29572962        PCFGMNODE pCfg;
    2958         rc = CFGMR3InsertNode (pLunL0,   "Config",      &pCfg);     RC_CHECK();
    2959         rc = CFGMR3InsertString (pCfg,   "Type",        !strcmp (pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK();
    2960         rc = CFGMR3InsertInteger (pCfg,  "Mountable",   1);         RC_CHECK();
     2963        rc = CFGMR3InsertNode(pLunL0,   "Config",       &pCfg);     RC_CHECK();
     2964        rc = CFGMR3InsertString(pCfg,   "Type",         !strcmp(pszDevice, "i82078") ? "Floppy 1.44" : "DVD"); RC_CHECK();
     2965        rc = CFGMR3InsertInteger(pCfg,  "Mountable",    1);         RC_CHECK();
    29612966
    29622967        /*
    29632968         * Attach the driver.
    29642969         */
    2965         rc = PDMR3DeviceAttach (pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, &pBase); RC_CHECK();
    2966         pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface (pBase, PDMINTERFACE_MOUNT);
     2970        rc = PDMR3DeviceAttach(pVM, pszDevice, uInstance, uLun, PDM_TACH_FLAGS_NOT_HOT_PLUG, &pBase); RC_CHECK();
     2971        pIMount = (PPDMIMOUNT) pBase->pfnQueryInterface(pBase, PDMINTERFACE_MOUNT);
    29672972        if (!pIMount)
    29682973        {
     
    29762981        if (pszPath && *pszPath)
    29772982        {
    2978             rc = pIMount->pfnMount (pIMount, pszPath, strcmp (pszDevice, "i82078") ? "MediaISO" : "RawImage");
     2983            rc = pIMount->pfnMount(pIMount, pszPath, strcmp(pszDevice, "i82078") ? "MediaISO" : "RawImage");
    29792984        }
    29802985
    29812986#undef RC_CHECK
    29822987
    2983         if (VBOX_FAILURE (rc) && VBOX_SUCCESS (rcRet))
     2988        if (RT_FAILURE(rc) && RT_SUCCESS(rcRet))
    29842989            rcRet = rc;
    29852990
     
    29983003    if (fResume)
    29993004    {
    3000         LogFlowFunc (("Resuming the VM...\n"));
     3005        LogFlowFunc(("Resuming the VM...\n"));
    30013006        /* disable the callback to prevent Console-level state change */
    30023007        pThis->mVMStateChangeCallbackDisabled = true;
    3003         rc = VMR3Resume (pVM);
     3008        rc = VMR3Resume(pVM);
    30043009        pThis->mVMStateChangeCallbackDisabled = false;
    3005         AssertRC (rc);
    3006         if (VBOX_FAILURE (rc))
     3010        AssertRC(rc);
     3011        if (RT_FAILURE(rc))
    30073012        {
    30083013            /* too bad, we failed. try to sync the console state with the VMM state */
    3009             vmstateChangeCallback (pVM, VMSTATE_SUSPENDED, enmVMState, pThis);
     3014            vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pThis);
    30103015        }
    30113016        /// @todo (r=dmik) if we failed with drive mount, then the VMR3Resume
    3012         //  error (if any) will be hidden from the caller. For proper reporting
    3013         //  of such multiple errors to the caller we need to enhance the
    3014         //  IVirtualBoxError interface. For now, give the first error the higher
    3015         //  priority.
    3016         if (VBOX_SUCCESS (rcRet))
     3017        // error (if any) will be hidden from the caller. For proper reporting
     3018        // of such multiple errors to the caller we need to enhance the
     3019        // IVirtualBoxError interface. For now, give the first error the higher
     3020        // priority.
     3021        if (RT_SUCCESS(rcRet))
    30173022            rcRet = rc;
    30183023    }
    30193024
    3020     LogFlowFunc (("Returning %Rrc\n", rcRet));
     3025    LogFlowFunc(("Returning %Rrc\n", rcRet));
    30213026    return rcRet;
    30223027}
     
    30243029
    30253030/**
    3026  *  Called by IInternalSessionControl::OnNetworkAdapterChange().
    3027  *
    3028  *  @note Locks this object for writing.
     3031 * Called by IInternalSessionControl::OnNetworkAdapterChange().
     3032 *
     3033 * @note Locks this object for writing.
    30293034 */
    3030 HRESULT Console::onNetworkAdapterChange (INetworkAdapter *aNetworkAdapter, BOOL changeAdapter)
     3035HRESULT Console::onNetworkAdapterChange(INetworkAdapter *aNetworkAdapter, BOOL changeAdapter)
    30313036{
    30323037    LogFlowThisFunc(("\n"));
     
    30423047
    30433048    /* protect mpVM */
    3044     AutoVMCaller autoVMCaller (this);
     3049    AutoVMCaller autoVMCaller(this);
    30453050    CheckComRCReturnRC(autoVMCaller.rc());
    30463051
    30473052    /* Get the properties we need from the adapter */
    30483053    BOOL fCableConnected, fTraceEnabled;
    3049     HRESULT rc = aNetworkAdapter->COMGETTER(CableConnected) (&fCableConnected);
     3054    HRESULT rc = aNetworkAdapter->COMGETTER(CableConnected)(&fCableConnected);
    30503055    AssertComRC(rc);
    30513056    if (SUCCEEDED(rc))
    30523057    {
    3053         rc = aNetworkAdapter->COMGETTER(TraceEnabled) (&fTraceEnabled);
     3058        rc = aNetworkAdapter->COMGETTER(TraceEnabled)(&fTraceEnabled);
    30543059        AssertComRC(rc);
    30553060    }
     
    30573062    {
    30583063        ULONG ulInstance;
    3059         rc = aNetworkAdapter->COMGETTER(Slot) (&ulInstance);
    3060         AssertComRC (rc);
     3064        rc = aNetworkAdapter->COMGETTER(Slot)(&ulInstance);
     3065        AssertComRC(rc);
    30613066        if (SUCCEEDED(rc))
    30623067        {
     
    30843089#endif /* VBOX_WITH_VIRTIO */
    30853090#endif
    3086             int vrc = PDMR3QueryDeviceLun (mpVM, pszAdapterName,
    3087                                            (unsigned) ulInstance, 0, &pBase);
    3088             ComAssertRC (vrc);
    3089             if (VBOX_SUCCESS(vrc))
     3091            int vrc = PDMR3QueryDeviceLun(mpVM, pszAdapterName,
     3092                                          (unsigned) ulInstance, 0, &pBase);
     3093            ComAssertRC(vrc);
     3094            if (RT_SUCCESS(vrc))
    30903095            {
    30913096                Assert(pBase);
     
    30943099                if (pINetCfg)
    30953100                {
    3096                     Log (("Console::onNetworkAdapterChange: setting link state to %d\n",
     3101                    Log(("Console::onNetworkAdapterChange: setting link state to %d\n",
    30973102                          fCableConnected));
    3098                     vrc = pINetCfg->pfnSetLinkState (pINetCfg,
    3099                                                      fCableConnected ? PDMNETWORKLINKSTATE_UP
    3100                                                                      : PDMNETWORKLINKSTATE_DOWN);
     3103                    vrc = pINetCfg->pfnSetLinkState(pINetCfg,
     3104                                                    fCableConnected ? PDMNETWORKLINKSTATE_UP
     3105                                                                    : PDMNETWORKLINKSTATE_DOWN);
    31013106                    ComAssertRC(vrc);
    31023107                }
     
    31113116                        if (fTraceEnabled && fCableConnected && pINetCfg)
    31123117                        {
    3113                             vrc = pINetCfg->pfnSetLinkState (pINetCfg, PDMNETWORKLINKSTATE_DOWN);
     3118                            vrc = pINetCfg->pfnSetLinkState(pINetCfg, PDMNETWORKLINKSTATE_DOWN);
    31143119                            ComAssertRC(vrc);
    31153120                        }
     
    31193124                        if (fTraceEnabled && fCableConnected && pINetCfg)
    31203125                        {
    3121                             vrc = pINetCfg->pfnSetLinkState (pINetCfg, PDMNETWORKLINKSTATE_UP);
     3126                            vrc = pINetCfg->pfnSetLinkState(pINetCfg, PDMNETWORKLINKSTATE_UP);
    31223127                            ComAssertRC(vrc);
    31233128                        }
     
    31273132            }
    31283133
    3129             if (VBOX_FAILURE (vrc))
     3134            if (RT_FAILURE(vrc))
    31303135                rc = E_FAIL;
    31313136        }
     
    31373142        CallbackList::iterator it = mCallbacks.begin();
    31383143        while (it != mCallbacks.end())
    3139             (*it++)->OnNetworkAdapterChange (aNetworkAdapter);
     3144            (*it++)->OnNetworkAdapterChange(aNetworkAdapter);
    31403145    }
    31413146
     
    31583163 * @note Locks this object for writing.
    31593164 */
    3160 HRESULT Console::doNetworkAdapterChange (const char *pszDevice,
    3161                                          unsigned uInstance,
    3162                                          unsigned uLun,
    3163                                          INetworkAdapter *aNetworkAdapter)
     3165HRESULT Console::doNetworkAdapterChange(const char *pszDevice,
     3166                                        unsigned uInstance,
     3167                                        unsigned uLun,
     3168                                        INetworkAdapter *aNetworkAdapter)
    31643169{
    31653170    LogFlowThisFunc(("pszDevice=%p:{%s} uInstance=%u uLun=%u aNetworkAdapter=%p\n",
     
    31733178
    31743179    /* protect mpVM */
    3175     AutoVMCaller autoVMCaller (this);
     3180    AutoVMCaller autoVMCaller(this);
    31763181    CheckComRCReturnRC(autoVMCaller.rc());
    31773182
     
    31823187     */
    31833188    PVMREQ pReq;
    3184     int vrc = VMR3ReqCall (mpVM, 0 /*idDstCpu*/, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
    3185                            (PFNRT) Console::changeNetworkAttachment, 5,
    3186                            this, pszDevice, uInstance, uLun, aNetworkAdapter);
     3189    int vrc = VMR3ReqCall(mpVM, 0 /*idDstCpu*/, &pReq, 0 /* no wait! */, VMREQFLAGS_VBOX_STATUS,
     3190                          (PFNRT) Console::changeNetworkAttachment, 5,
     3191                          this, pszDevice, uInstance, uLun, aNetworkAdapter);
    31873192
    31883193    /* leave the lock before waiting for a result (EMT will call us back!) */
    31893194    alock.leave();
    31903195
    3191     if (vrc == VERR_TIMEOUT || VBOX_SUCCESS (vrc))
    3192     {
    3193         vrc = VMR3ReqWait (pReq, RT_INDEFINITE_WAIT);
    3194         AssertRC (vrc);
    3195         if (VBOX_SUCCESS (vrc))
     3196    if (vrc == VERR_TIMEOUT || RT_SUCCESS(vrc))
     3197    {
     3198        vrc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);
     3199        AssertRC(vrc);
     3200        if (RT_SUCCESS(vrc))
    31963201            vrc = pReq->iStatus;
    31973202    }
    3198     VMR3ReqFree (pReq);
    3199 
    3200     if (VBOX_SUCCESS (vrc))
     3203    VMR3ReqFree(pReq);
     3204
     3205    if (RT_SUCCESS(vrc))
    32013206    {
    32023207        LogFlowThisFunc(("Returns S_OK\n"));
     
    32043209    }
    32053210
    3206     return setError (E_FAIL,
    3207         tr ("Could not change the network adaptor attachement type (%Rrc)"), vrc);
     3211    return setError(E_FAIL,
     3212        tr("Could not change the network adaptor attachement type (%Rrc)"),
     3213        vrc);
    32083214}
    32093215
     
    32233229 * @note Locks the Console object for writing.
    32243230 */
    3225 DECLCALLBACK(int) Console::changeNetworkAttachment (Console *pThis,
    3226                                                     const char *pszDevice,
    3227                                                     unsigned uInstance,
    3228                                                     unsigned uLun,
    3229                                                     INetworkAdapter *aNetworkAdapter)
    3230 {
    3231     LogFlowFunc (("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u aNetworkAdapter=%p\n",
    3232                   pThis, pszDevice, pszDevice, uInstance, uLun, aNetworkAdapter));
     3231DECLCALLBACK(int) Console::changeNetworkAttachment(Console *pThis,
     3232                                                   const char *pszDevice,
     3233                                                   unsigned uInstance,
     3234                                                   unsigned uLun,
     3235                                                   INetworkAdapter *aNetworkAdapter)
     3236{
     3237    LogFlowFunc(("pThis=%p pszDevice=%p:{%s} uInstance=%u uLun=%u aNetworkAdapter=%p\n",
     3238                 pThis, pszDevice, pszDevice, uInstance, uLun, aNetworkAdapter));
    32333239
    32343240    AssertReturn(pThis, VERR_INVALID_PARAMETER);
    32353241
    3236     AssertMsg (   (!strcmp (pszDevice, "pcnet") && uLun == 0 && uInstance < SchemaDefs::NetworkAdapterCount)
    3237                || (!strcmp (pszDevice, "e1000") && uLun == 0 && uInstance < SchemaDefs::NetworkAdapterCount),
     3242    AssertMsg(   (!strcmp(pszDevice, "pcnet") && uLun == 0 && uInstance < SchemaDefs::NetworkAdapterCount)
     3243               || (!strcmp(pszDevice, "e1000") && uLun == 0 && uInstance < SchemaDefs::NetworkAdapterCount),
    32383244               ("pszDevice=%s uLun=%d uInstance=%d\n", pszDevice, uLun, uInstance));
    32393245    Log(("pszDevice=%s uLun=%d uInstance=%d\n", pszDevice, uLun, uInstance));
    32403246
    32413247    AutoCaller autoCaller(pThis);
    3242     AssertComRCReturn (autoCaller.rc(), VERR_ACCESS_DENIED);
     3248    AssertComRCReturn(autoCaller.rc(), VERR_ACCESS_DENIED);
    32433249
    32443250    /* protect mpVM */
    3245     AutoVMCaller autoVMCaller (pThis);
     3251    AutoVMCaller autoVMCaller(pThis);
    32463252    CheckComRCReturnRC(autoVMCaller.rc());
    32473253
     
    32553261     */
    32563262    bool fResume;
    3257     VMSTATE enmVMState = VMR3GetState (pVM);
     3263    VMSTATE enmVMState = VMR3GetState(pVM);
    32583264    switch (enmVMState)
    32593265    {
     
    32613267        case VMSTATE_RUNNING:
    32623268        {
    3263             LogFlowFunc (("Suspending the VM...\n"));
     3269            LogFlowFunc(("Suspending the VM...\n"));
    32643270            /* disable the callback to prevent Console-level state change */
    32653271            pThis->mVMStateChangeCallbackDisabled = true;
    3266             int rc = VMR3Suspend (pVM);
     3272            int rc = VMR3Suspend(pVM);
    32673273            pThis->mVMStateChangeCallbackDisabled = false;
    3268             AssertRCReturn (rc, rc);
     3274            AssertRCReturn(rc, rc);
    32693275            fResume = true;
    32703276            break;
     
    32783284
    32793285        default:
    3280             AssertMsgFailedReturn (("enmVMState=%d\n", enmVMState), VERR_ACCESS_DENIED);
     3286            AssertMsgFailedReturn(("enmVMState=%d\n", enmVMState), VERR_ACCESS_DENIED);
    32813287    }
    32823288
     
    32863292    PCFGMNODE pCfg = NULL;          /* /Devices/Dev/.../Config/ */
    32873293    PCFGMNODE pLunL0 = NULL;        /* /Devices/Dev/0/LUN#0/ */
    3288     PCFGMNODE pInst = CFGMR3GetChildF (CFGMR3GetRoot (pVM), "Devices/%s/%d/", pszDevice, uInstance);
    3289     AssertRelease (pInst);
     3294    PCFGMNODE pInst = CFGMR3GetChildF(CFGMR3GetRoot(pVM), "Devices/%s/%d/", pszDevice, uInstance);
     3295    AssertRelease(pInst);
    32903296
    32913297    rcRet = configNetwork(pThis, pszDevice, uInstance, uLun, aNetworkAdapter, pCfg, pLunL0, pInst, true);
     
    32963302    if (fResume)
    32973303    {
    3298         LogFlowFunc (("Resuming the VM...\n"));
     3304        LogFlowFunc(("Resuming the VM...\n"));
    32993305        /* disable the callback to prevent Console-level state change */
    33003306        pThis->mVMStateChangeCallbackDisabled = true;
    3301         rc = VMR3Resume (pVM);
     3307        rc = VMR3Resume(pVM);
    33023308        pThis->mVMStateChangeCallbackDisabled = false;
    3303         AssertRC (rc);
    3304         if (VBOX_FAILURE (rc))
     3309        AssertRC(rc);
     3310        if (RT_FAILURE(rc))
    33053311        {
    33063312            /* too bad, we failed. try to sync the console state with the VMM state */
    3307             vmstateChangeCallback (pVM, VMSTATE_SUSPENDED, enmVMState, pThis);
     3313            vmstateChangeCallback(pVM, VMSTATE_SUSPENDED, enmVMState, pThis);
    33083314        }
    33093315        /// @todo (r=dmik) if we failed with drive mount, then the VMR3Resume
    3310         //  error (if any) will be hidden from the caller. For proper reporting
    3311         //  of such multiple errors to the caller we need to enhance the
    3312         //  IVirtualBoxError interface. For now, give the first error the higher
    3313         //  priority.
    3314         if (VBOX_SUCCESS (rcRet))
     3316        // error (if any) will be hidden from the caller. For proper reporting
     3317        // of such multiple errors to the caller we need to enhance the
     3318        // IVirtualBoxError interface. For now, give the first error the higher
     3319        // priority.
     3320        if (RT_SUCCESS(rcRet))
    33153321            rcRet = rc;
    33163322    }
    33173323
    3318     LogFlowFunc (("Returning %Rrc\n", rcRet));
     3324    LogFlowFunc(("Returning %Rrc\n", rcRet));
    33193325    return rcRet;
    33203326}
     
    33233329
    33243330/**
    3325  *  Called by IInternalSessionControl::OnSerialPortChange().
    3326  *
    3327  *  @note Locks this object for writing.
     3331 * Called by IInternalSessionControl::OnSerialPortChange().
     3332 *
     3333 * @note Locks this object for writing.
    33283334 */
    3329 HRESULT Console::onSerialPortChange (ISerialPort *aSerialPort)
     3335HRESULT Console::onSerialPortChange(ISerialPort *aSerialPort)
    33303336{
    33313337    LogFlowThisFunc(("\n"));
     
    33433349
    33443350    /* protect mpVM */
    3345     AutoVMCaller autoVMCaller (this);
     3351    AutoVMCaller autoVMCaller(this);
    33463352    CheckComRCReturnRC(autoVMCaller.rc());
    33473353
     
    33533359        CallbackList::iterator it = mCallbacks.begin();
    33543360        while (it != mCallbacks.end())
    3355             (*it++)->OnSerialPortChange (aSerialPort);
     3361            (*it++)->OnSerialPortChange(aSerialPort);
    33563362    }
    33573363
     
    33613367
    33623368/**
    3363  *  Called by IInternalSessionControl::OnParallelPortChange().
    3364  *
    3365  *  @note Locks this object for writing.
     3369 * Called by IInternalSessionControl::OnParallelPortChange().
     3370 *
     3371 * @note Locks this object for writing.
    33663372 */
    3367 HRESULT Console::onParallelPortChange (IParallelPort *aParallelPort)
     3373HRESULT Console::onParallelPortChange(IParallelPort *aParallelPort)
    33683374{
    33693375    LogFlowThisFunc(("\n"));
     
    33813387
    33823388    /* protect mpVM */
    3383     AutoVMCaller autoVMCaller (this);
     3389    AutoVMCaller autoVMCaller(this);
    33843390    CheckComRCReturnRC(autoVMCaller.rc());
    33853391
     
    33913397        CallbackList::iterator it = mCallbacks.begin();
    33923398        while (it != mCallbacks.end())
    3393             (*it++)->OnParallelPortChange (aParallelPort);
     3399            (*it++)->OnParallelPortChange(aParallelPort);
    33943400    }
    33953401
     
    33993405
    34003406/**
    3401  *  Called by IInternalSessionControl::OnStorageControllerChange().
    3402  *
    3403  *  @note Locks this object for writing.
     3407 * Called by IInternalSessionControl::OnStorageControllerChange().
     3408 *
     3409 * @note Locks this object for writing.
    34043410 */
    3405 HRESULT Console::onStorageControllerChange ()
     3411HRESULT Console::onStorageControllerChange()
    34063412{
    34073413    LogFlowThisFunc(("\n"));
     
    34193425
    34203426    /* protect mpVM */
    3421     AutoVMCaller autoVMCaller (this);
     3427    AutoVMCaller autoVMCaller(this);
    34223428    CheckComRCReturnRC(autoVMCaller.rc());
    34233429
     
    34293435        CallbackList::iterator it = mCallbacks.begin();
    34303436        while (it != mCallbacks.end())
    3431             (*it++)->OnStorageControllerChange ();
     3437            (*it++)->OnStorageControllerChange();
    34323438    }
    34333439
     
    34373443
    34383444/**
    3439  *  Called by IInternalSessionControl::OnMediumChange().
    3440  *
    3441  *  @note Locks this object for writing.
     3445 * Called by IInternalSessionControl::OnMediumChange().
     3446 *
     3447 * @note Locks this object for writing.
    34423448 */
    3443 HRESULT Console::onMediumChange (IMediumAttachment *aMediumAttachment)
     3449HRESULT Console::onMediumChange(IMediumAttachment *aMediumAttachment)
    34443450{
    34453451    LogFlowThisFunc(("\n"));
     
    34573463
    34583464    /* protect mpVM */
    3459     AutoVMCaller autoVMCaller (this);
     3465    AutoVMCaller autoVMCaller(this);
    34603466    CheckComRCReturnRC(autoVMCaller.rc());
    34613467
     
    34673473        CallbackList::iterator it = mCallbacks.begin();
    34683474        while (it != mCallbacks.end())
    3469             (*it++)->OnMediumChange (aMediumAttachment);
     3475            (*it++)->OnMediumChange(aMediumAttachment);
    34703476    }
    34713477
     
    34753481
    34763482/**
    3477  *  Called by IInternalSessionControl::OnVRDPServerChange().
    3478  *
    3479  *  @note Locks this object for writing.
     3483 * Called by IInternalSessionControl::OnVRDPServerChange().
     3484 *
     3485 * @note Locks this object for writing.
    34803486 */
    34813487HRESULT Console::onVRDPServerChange()
     
    34923498        BOOL vrdpEnabled = FALSE;
    34933499
    3494         rc = mVRDPServer->COMGETTER(Enabled) (&vrdpEnabled);
    3495         ComAssertComRCRetRC (rc);
     3500        rc = mVRDPServer->COMGETTER(Enabled)(&vrdpEnabled);
     3501        ComAssertComRCRetRC(rc);
    34963502
    34973503        /* VRDP server may call this Console object back from other threads (VRDP INPUT or OUTPUT). */
     
    35033509            // However if a server was started and this notification was called,
    35043510            // we have to restart the server.
    3505             mConsoleVRDPServer->Stop ();
    3506 
    3507             if (RT_FAILURE(mConsoleVRDPServer->Launch ()))
     3511            mConsoleVRDPServer->Stop();
     3512
     3513            if (RT_FAILURE(mConsoleVRDPServer->Launch()))
    35083514            {
    35093515                rc = E_FAIL;
     
    35113517            else
    35123518            {
    3513                 mConsoleVRDPServer->EnableConnections ();
     3519                mConsoleVRDPServer->EnableConnections();
    35143520            }
    35153521        }
    35163522        else
    35173523        {
    3518             mConsoleVRDPServer->Stop ();
     3524            mConsoleVRDPServer->Stop();
    35193525        }
    35203526
     
    35343540
    35353541/**
    3536  *  Called by IInternalSessionControl::OnUSBControllerChange().
    3537  *
    3538  *  @note Locks this object for writing.
     3542 * Called by IInternalSessionControl::OnUSBControllerChange().
     3543 *
     3544 * @note Locks this object for writing.
    35393545 */
    35403546HRESULT Console::onUSBControllerChange()
     
    35543560
    35553561/// @todo (dmik)
    3556 //  check for the Enabled state and disable virtual USB controller??
    3557 //  Anyway, if we want to query the machine's USB Controller we need to cache
    3558 //  it to mUSBController in #init() (as it is done with mDVDDrive).
     3562// check for the Enabled state and disable virtual USB controller??
     3563// Anyway, if we want to query the machine's USB Controller we need to cache
     3564// it to mUSBController in #init() (as it is done with mDVDDrive).
    35593565//
    3560 //  bird: While the VM supports hot-plugging, I doubt any guest can handle it at this time... :-)
     3566// bird: While the VM supports hot-plugging, I doubt any guest can handle it at this time... :-)
    35613567//
    35623568//    /* protect mpVM */
    3563 //    AutoVMCaller autoVMCaller (this);
     3569//    AutoVMCaller autoVMCaller(this);
    35643570//    CheckComRCReturnRC(autoVMCaller.rc());
    35653571
     
    35763582
    35773583/**
    3578  *  Called by IInternalSessionControl::OnSharedFolderChange().
    3579  *
    3580  *  @note Locks this object for writing.
     3584 * Called by IInternalSessionControl::OnSharedFolderChange().
     3585 *
     3586 * @note Locks this object for writing.
    35813587 */
    3582 HRESULT Console::onSharedFolderChange (BOOL aGlobal)
     3588HRESULT Console::onSharedFolderChange(BOOL aGlobal)
    35833589{
    35843590    LogFlowThisFunc(("aGlobal=%RTbool\n", aGlobal));
     
    35893595    AutoWriteLock alock(this);
    35903596
    3591     HRESULT rc = fetchSharedFolders (aGlobal);
     3597    HRESULT rc = fetchSharedFolders(aGlobal);
    35923598
    35933599    /* notify console callbacks on success */
     
    35963602        CallbackList::iterator it = mCallbacks.begin();
    35973603        while (it != mCallbacks.end())
    3598             (*it++)->OnSharedFolderChange (aGlobal ? (Scope_T) Scope_Global
    3599                                                    : (Scope_T) Scope_Machine);
     3604            (*it++)->OnSharedFolderChange(aGlobal ? (Scope_T)Scope_Global
     3605                                                  : (Scope_T)Scope_Machine);
    36003606    }
    36013607
     
    36043610
    36053611/**
    3606  *  Called by IInternalSessionControl::OnUSBDeviceAttach() or locally by
    3607  *  processRemoteUSBDevices() after IInternalMachineControl::RunUSBDeviceFilters()
    3608  *  returns TRUE for a given remote USB device.
    3609  *
    3610  *  @return S_OK if the device was attached to the VM.
    3611  *  @return failure if not attached.
    3612  *
    3613  *  @param aDevice
    3614  *      The device in question.
    3615  *  @param aMaskedIfs
    3616  *      The interfaces to hide from the guest.
    3617  *
    3618  *  @note Locks this object for writing.
     3612 * Called by IInternalSessionControl::OnUSBDeviceAttach() or locally by
     3613 * processRemoteUSBDevices() after IInternalMachineControl::RunUSBDeviceFilters()
     3614 * returns TRUE for a given remote USB device.
     3615 *
     3616 * @return S_OK if the device was attached to the VM.
     3617 * @return failure if not attached.
     3618 *
     3619 * @param aDevice
     3620 *     The device in question.
     3621 * @param aMaskedIfs
     3622 *     The interfaces to hide from the guest.
     3623 *
     3624 * @note Locks this object for writing.
    36193625 */
    3620 HRESULT Console::onUSBDeviceAttach (IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs)
     3626HRESULT Console::onUSBDeviceAttach(IUSBDevice *aDevice, IVirtualBoxErrorInfo *aError, ULONG aMaskedIfs)
    36213627{
    36223628#ifdef VBOX_WITH_USB
     
    36243630
    36253631    AutoCaller autoCaller(this);
    3626     ComAssertComRCRetRC (autoCaller.rc());
     3632    ComAssertComRCRetRC(autoCaller.rc());
    36273633
    36283634    AutoWriteLock alock(this);
    36293635
    36303636    /* protect mpVM (we don't need error info, since it's a callback) */
    3631     AutoVMCallerQuiet autoVMCaller (this);
    3632     if (FAILED (autoVMCaller.rc()))
     3637    AutoVMCallerQuiet autoVMCaller(this);
     3638    if (FAILED(autoVMCaller.rc()))
    36333639    {
    36343640        /* The VM may be no more operational when this message arrives
     
    36433649    {
    36443650        /* notify callbacks about the error */
    3645         onUSBDeviceStateChange (aDevice, true /* aAttached */, aError);
     3651        onUSBDeviceStateChange(aDevice, true /* aAttached */, aError);
    36463652        return S_OK;
    36473653    }
    36483654
    36493655    /* Don't proceed unless there's at least one USB hub. */
    3650     if (!PDMR3USBHasHub (mpVM))
     3656    if (!PDMR3USBHasHub(mpVM))
    36513657    {
    36523658        LogFlowThisFunc(("Attach request ignored (no USB controller).\n"));
     
    36543660    }
    36553661
    3656     HRESULT rc = attachUSBDevice (aDevice, aMaskedIfs);
    3657     if (FAILED (rc))
     3662    HRESULT rc = attachUSBDevice(aDevice, aMaskedIfs);
     3663    if (FAILED(rc))
    36583664    {
    36593665        /* take the current error info */
     
    36613667        /* the error must be a VirtualBoxErrorInfo instance */
    36623668        ComPtr<IVirtualBoxErrorInfo> error = eik.takeError();
    3663         Assert (!error.isNull());
     3669        Assert(!error.isNull());
    36643670        if (!error.isNull())
    36653671        {
    36663672            /* notify callbacks about the error */
    3667             onUSBDeviceStateChange (aDevice, true /* aAttached */, error);
     3673            onUSBDeviceStateChange(aDevice, true /* aAttached */, error);
    36683674        }
    36693675    }
     
    36773683
    36783684/**
    3679  *  Called by IInternalSessionControl::OnUSBDeviceDetach() and locally by
    3680  *  processRemoteUSBDevices().
    3681  *
    3682  *  @note Locks this object for writing.
     3685 * Called by IInternalSessionControl::OnUSBDeviceDetach() and locally by
     3686 * processRemoteUSBDevices().
     3687 *
     3688 * @note Locks this object for writing.
    36833689 */
    3684 HRESULT Console::onUSBDeviceDetach (IN_BSTR aId,
    3685                                     IVirtualBoxErrorInfo *aError)
     3690HRESULT Console::onUSBDeviceDetach(IN_BSTR aId,
     3691                                   IVirtualBoxErrorInfo *aError)
    36863692{
    36873693#ifdef VBOX_WITH_USB
    3688     Guid Uuid (aId);
     3694    Guid Uuid(aId);
    36893695    LogFlowThisFunc(("aId={%RTuuid} aError=%p\n", Uuid.raw(), aError));
    36903696
     
    37183724         * failure in this case. */
    37193725
    3720         AutoVMCallerQuiet autoVMCaller (this);
    3721         if (FAILED (autoVMCaller.rc()))
     3726        AutoVMCallerQuiet autoVMCaller(this);
     3727        if (FAILED(autoVMCaller.rc()))
    37223728        {
    37233729            LogFlowThisFunc(("Detach request ignored (mMachineState=%d).\n",
     
    37273733
    37283734        /* the device must be in the list otherwise */
    3729         AssertFailedReturn (E_FAIL);
     3735        AssertFailedReturn(E_FAIL);
    37303736    }
    37313737
     
    37333739    {
    37343740        /* notify callback about an error */
    3735         onUSBDeviceStateChange (device, false /* aAttached */, aError);
     3741        onUSBDeviceStateChange(device, false /* aAttached */, aError);
    37363742        return S_OK;
    37373743    }
    37383744
    3739     HRESULT rc = detachUSBDevice (it);
    3740 
    3741     if (FAILED (rc))
     3745    HRESULT rc = detachUSBDevice(it);
     3746
     3747    if (FAILED(rc))
    37423748    {
    37433749        /* take the current error info */
     
    37453751        /* the error must be a VirtualBoxErrorInfo instance */
    37463752        ComPtr<IVirtualBoxErrorInfo> error = eik.takeError();
    3747         Assert (!error.isNull());
     3753        Assert(!error.isNull());
    37483754        if (!error.isNull())
    37493755        {
    37503756            /* notify callbacks about the error */
    3751             onUSBDeviceStateChange (device, false /* aAttached */, error);
     3757            onUSBDeviceStateChange(device, false /* aAttached */, error);
    37523758        }
    37533759    }
     
    37633769 * @note Temporarily locks this object for writing.
    37643770 */
    3765 HRESULT Console::getGuestProperty (IN_BSTR aName, BSTR *aValue,
    3766                                    ULONG64 *aTimestamp, BSTR *aFlags)
    3767 {
    3768 #if !defined (VBOX_WITH_GUEST_PROPS)
     3771HRESULT Console::getGuestProperty(IN_BSTR aName, BSTR *aValue,
     3772                                  ULONG64 *aTimestamp, BSTR *aFlags)
     3773{
     3774#ifndef VBOX_WITH_GUEST_PROPS
    37693775    ReturnComNotImplemented();
    37703776#else
    3771     if (!VALID_PTR (aName))
     3777    if (!VALID_PTR(aName))
    37723778        return E_INVALIDARG;
    3773     if (!VALID_PTR (aValue))
     3779    if (!VALID_PTR(aValue))
    37743780        return E_POINTER;
    3775     if ((aTimestamp != NULL) && !VALID_PTR (aTimestamp))
     3781    if ((aTimestamp != NULL) && !VALID_PTR(aTimestamp))
    37763782        return E_POINTER;
    3777     if ((aFlags != NULL) && !VALID_PTR (aFlags))
     3783    if ((aFlags != NULL) && !VALID_PTR(aFlags))
    37783784        return E_POINTER;
    37793785
     
    37823788
    37833789    /* protect mpVM (if not NULL) */
    3784     AutoVMCallerWeak autoVMCaller (this);
     3790    AutoVMCallerWeak autoVMCaller(this);
    37853791    CheckComRCReturnRC(autoVMCaller.rc());
    37863792
     
    38043810        parm[1].u.pointer.addr = pszBuffer;
    38053811        parm[1].u.pointer.size = sizeof(pszBuffer);
    3806         int vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", GET_PROP_HOST,
     3812        int vrc = mVMMDev->hgcmHostCall("VBoxGuestPropSvc", GET_PROP_HOST,
    38073813                                        4, &parm[0]);
    38083814        /* The returned string should never be able to be greater than our buffer */
    3809         AssertLogRel (vrc != VERR_BUFFER_OVERFLOW);
    3810         AssertLogRel (RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type);
     3815        AssertLogRel(vrc != VERR_BUFFER_OVERFLOW);
     3816        AssertLogRel(RT_FAILURE(vrc) || VBOX_HGCM_SVC_PARM_64BIT == parm[2].type);
    38113817        if (RT_SUCCESS(vrc) || (VERR_NOT_FOUND == vrc))
    38123818        {
     
    38263832        }
    38273833        else
    3828             rc = setError (E_UNEXPECTED,
    3829                 tr ("The service call failed with the error %Rrc"), vrc);
     3834            rc = setError(E_UNEXPECTED,
     3835                tr("The service call failed with the error %Rrc"),
     3836                vrc);
    38303837    }
    38313838    catch(std::bad_alloc & /*e*/)
     
    38343841    }
    38353842    return rc;
    3836 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */
     3843#endif /* VBOX_WITH_GUEST_PROPS */
    38373844}
    38383845
     
    38403847 * @note Temporarily locks this object for writing.
    38413848 */
    3842 HRESULT Console::setGuestProperty (IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags)
    3843 {
    3844 #if !defined (VBOX_WITH_GUEST_PROPS)
     3849HRESULT Console::setGuestProperty(IN_BSTR aName, IN_BSTR aValue, IN_BSTR aFlags)
     3850{
     3851#ifndef VBOX_WITH_GUEST_PROPS
    38453852    ReturnComNotImplemented();
    38463853#else
    3847     if (!VALID_PTR (aName))
     3854    if (!VALID_PTR(aName))
    38483855        return E_INVALIDARG;
    3849     if ((aValue != NULL) && !VALID_PTR (aValue))
     3856    if ((aValue != NULL) && !VALID_PTR(aValue))
    38503857        return E_INVALIDARG;
    3851     if ((aFlags != NULL) && !VALID_PTR (aFlags))
     3858    if ((aFlags != NULL) && !VALID_PTR(aFlags))
    38523859        return E_INVALIDARG;
    38533860
     
    38563863
    38573864    /* protect mpVM (if not NULL) */
    3858     AutoVMCallerWeak autoVMCaller (this);
     3865    AutoVMCallerWeak autoVMCaller(this);
    38593866    CheckComRCReturnRC(autoVMCaller.rc());
    38603867
     
    38903897    }
    38913898    if ((aValue != NULL) && (aFlags != NULL))
    3892         vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", SET_PROP_HOST,
    3893                                      3, &parm[0]);
     3899        vrc = mVMMDev->hgcmHostCall("VBoxGuestPropSvc", SET_PROP_HOST,
     3900                                    3, &parm[0]);
    38943901    else if (aValue != NULL)
    3895         vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", SET_PROP_VALUE_HOST,
    3896                                      2, &parm[0]);
     3902        vrc = mVMMDev->hgcmHostCall("VBoxGuestPropSvc", SET_PROP_VALUE_HOST,
     3903                                    2, &parm[0]);
    38973904    else
    3898         vrc = mVMMDev->hgcmHostCall ("VBoxGuestPropSvc", DEL_PROP_HOST,
    3899                                      1, &parm[0]);
     3905        vrc = mVMMDev->hgcmHostCall("VBoxGuestPropSvc", DEL_PROP_HOST,
     3906                                    1, &parm[0]);
    39003907    if (RT_SUCCESS(vrc))
    39013908        rc = S_OK;
    39023909    else
    3903         rc = setError (E_UNEXPECTED,
    3904             tr ("The service call failed with the error %Rrc"), vrc);
     3910        rc = setError(E_UNEXPECTED,
     3911            tr("The service call failed with the error %Rrc"),
     3912            vrc);
    39053913    return rc;
    3906 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */
     3914#endif /* VBOX_WITH_GUEST_PROPS */
    39073915}
    39083916
     
    39113919 * @note Temporarily locks this object for writing.
    39123920 */
    3913 HRESULT Console::enumerateGuestProperties (IN_BSTR aPatterns,
    3914                                            ComSafeArrayOut(BSTR, aNames),
    3915                                            ComSafeArrayOut(BSTR, aValues),
    3916                                            ComSafeArrayOut(ULONG64, aTimestamps),
    3917                                            ComSafeArrayOut(BSTR, aFlags))
    3918 {
    3919 #if !defined (VBOX_WITH_GUEST_PROPS)
     3921HRESULT Console::enumerateGuestProperties(IN_BSTR aPatterns,
     3922                                          ComSafeArrayOut(BSTR, aNames),
     3923                                          ComSafeArrayOut(BSTR, aValues),
     3924                                          ComSafeArrayOut(ULONG64, aTimestamps),
     3925                                          ComSafeArrayOut(BSTR, aFlags))
     3926{
     3927#ifndef VBOX_WITH_GUEST_PROPS
    39203928    ReturnComNotImplemented();
    39213929#else
    3922     if (!VALID_PTR (aPatterns) && (aPatterns != NULL))
     3930    if (!VALID_PTR(aPatterns) && (aPatterns != NULL))
    39233931        return E_POINTER;
    39243932    if (ComSafeArrayOutIsNull(aNames))
     
    39353943
    39363944    /* protect mpVM (if not NULL) */
    3937     AutoVMCallerWeak autoVMCaller (this);
     3945    AutoVMCallerWeak autoVMCaller(this);
    39383946    CheckComRCReturnRC(autoVMCaller.rc());
    39393947
     
    39413949     * autoVMCaller, so there is no need to hold a lock of this */
    39423950
    3943     return doEnumerateGuestProperties (aPatterns, ComSafeArrayOutArg(aNames),
    3944                                        ComSafeArrayOutArg(aValues),
    3945                                        ComSafeArrayOutArg(aTimestamps),
    3946                                        ComSafeArrayOutArg(aFlags));
    3947 #endif /* else !defined (VBOX_WITH_GUEST_PROPS) */
     3951    return doEnumerateGuestProperties(aPatterns, ComSafeArrayOutArg(aNames),
     3952                                      ComSafeArrayOutArg(aValues),
     3953                                      ComSafeArrayOutArg(aTimestamps),
     3954                                      ComSafeArrayOutArg(aFlags));
     3955#endif /* VBOX_WITH_GUEST_PROPS */
    39483956}
    39493957
    39503958/**
    3951  *  Gets called by Session::UpdateMachineState()
    3952  *  (IInternalSessionControl::updateMachineState()).
    3953  *
    3954  *  Must be called only in certain cases (see the implementation).
    3955  *
    3956  *  @note Locks this object for writing.
     3959 * Gets called by Session::UpdateMachineState()
     3960 * (IInternalSessionControl::updateMachineState()).
     3961 *
     3962 * Must be called only in certain cases (see the implementation).
     3963 *
     3964 * @note Locks this object for writing.
    39573965 */
    3958 HRESULT Console::updateMachineState (MachineState_T aMachineState)
     3966HRESULT Console::updateMachineState(MachineState_T aMachineState)
    39593967{
    39603968    AutoCaller autoCaller(this);
     
    39673975                  E_FAIL);
    39683976
    3969     return setMachineStateLocally (aMachineState);
     3977    return setMachineStateLocally(aMachineState);
    39703978}
    39713979
    39723980/**
    3973  *  @note Locks this object for writing.
     3981 * @note Locks this object for writing.
    39743982 */
    39753983void Console::onMousePointerShapeChange(bool fVisible, bool fAlpha,
     
    39803988#if 0
    39813989    LogFlowThisFuncEnter();
    3982     LogFlowThisFunc(("fVisible=%d, fAlpha=%d, xHot = %d, yHot = %d, width=%d, "
    3983                       "height=%d, shape=%p\n",
     3990    LogFlowThisFunc(("fVisible=%d, fAlpha=%d, xHot = %d, yHot = %d, width=%d, height=%d, shape=%p\n",
    39843991                      fVisible, fAlpha, xHot, yHot, width, height, pShape));
    39853992#endif
    39863993
    39873994    AutoCaller autoCaller(this);
    3988     AssertComRCReturnVoid (autoCaller.rc());
     3995    AssertComRCReturnVoid(autoCaller.rc());
    39893996
    39903997    /* We need a write lock because we alter the cached callback data */
     
    40134020        if (mCallbackData.mpsc.shape != NULL && mCallbackData.mpsc.shapeSize != cb)
    40144021        {
    4015             RTMemFree (mCallbackData.mpsc.shape);
     4022            RTMemFree(mCallbackData.mpsc.shape);
    40164023            mCallbackData.mpsc.shape = NULL;
    40174024        }
    40184025        if (mCallbackData.mpsc.shape == NULL)
    40194026        {
    4020             mCallbackData.mpsc.shape = (BYTE *) RTMemAllocZ (cb);
    4021             AssertReturnVoid (mCallbackData.mpsc.shape);
     4027            mCallbackData.mpsc.shape = (BYTE *) RTMemAllocZ(cb);
     4028            AssertReturnVoid(mCallbackData.mpsc.shape);
    40224029        }
    40234030        mCallbackData.mpsc.shapeSize = cb;
    4024         memcpy (mCallbackData.mpsc.shape, pShape, cb);
     4031        memcpy(mCallbackData.mpsc.shape, pShape, cb);
    40254032    }
    40264033    else
    40274034    {
    40284035        if (wasValid && mCallbackData.mpsc.shape != NULL)
    4029             RTMemFree (mCallbackData.mpsc.shape);
     4036            RTMemFree(mCallbackData.mpsc.shape);
    40304037        mCallbackData.mpsc.shape = NULL;
    40314038        mCallbackData.mpsc.shapeSize = 0;
     
    40364043    CallbackList::iterator it = mCallbacks.begin();
    40374044    while (it != mCallbacks.end())
    4038         (*it++)->OnMousePointerShapeChange (fVisible, fAlpha, xHot, yHot,
    4039                                             width, height, (BYTE *) pShape);
     4045        (*it++)->OnMousePointerShapeChange(fVisible, fAlpha, xHot, yHot,
     4046                                           width, height, (BYTE *) pShape);
    40404047
    40414048#if 0
     
    40454052
    40464053/**
    4047  *  @note Locks this object for writing.
     4054 * @note Locks this object for writing.
    40484055 */
    4049 void Console::onMouseCapabilityChange (BOOL supportsAbsolute, BOOL needsHostCursor)
     4056void Console::onMouseCapabilityChange(BOOL supportsAbsolute, BOOL needsHostCursor)
    40504057{
    40514058    LogFlowThisFunc(("supportsAbsolute=%d needsHostCursor=%d\n",
     
    40534060
    40544061    AutoCaller autoCaller(this);
    4055     AssertComRCReturnVoid (autoCaller.rc());
     4062    AssertComRCReturnVoid(autoCaller.rc());
    40564063
    40574064    /* We need a write lock because we alter the cached callback data */
     
    40674074    {
    40684075        Log2(("Console::onMouseCapabilityChange: calling %p\n", (void*)*it));
    4069         (*it++)->OnMouseCapabilityChange (supportsAbsolute, needsHostCursor);
     4076        (*it++)->OnMouseCapabilityChange(supportsAbsolute, needsHostCursor);
    40704077    }
    40714078}
    40724079
    40734080/**
    4074  *  @note Locks this object for reading.
     4081 * @note Locks this object for reading.
    40754082 */
    4076 void Console::onStateChange (MachineState_T machineState)
     4083void Console::onStateChange(MachineState_T machineState)
    40774084{
    40784085    AutoCaller autoCaller(this);
    4079     AssertComRCReturnVoid (autoCaller.rc());
     4086    AssertComRCReturnVoid(autoCaller.rc());
    40804087
    40814088    AutoReadLock alock(this);
     
    40834090    CallbackList::iterator it = mCallbacks.begin();
    40844091    while (it != mCallbacks.end())
    4085         (*it++)->OnStateChange (machineState);
     4092        (*it++)->OnStateChange(machineState);
    40864093}
    40874094
    40884095/**
    4089  *  @note Locks this object for reading.
     4096 * @note Locks this object for reading.
    40904097 */
    40914098void Console::onAdditionsStateChange()
    40924099{
    40934100    AutoCaller autoCaller(this);
    4094     AssertComRCReturnVoid (autoCaller.rc());
     4101    AssertComRCReturnVoid(autoCaller.rc());
    40954102
    40964103    AutoReadLock alock(this);
     
    41024109
    41034110/**
    4104  *  @note Locks this object for reading.
     4111 * @note Locks this object for reading.
    41054112 */
    41064113void Console::onAdditionsOutdated()
    41074114{
    41084115    AutoCaller autoCaller(this);
    4109     AssertComRCReturnVoid (autoCaller.rc());
     4116    AssertComRCReturnVoid(autoCaller.rc());
    41104117
    41114118    AutoReadLock alock(this);
    41124119
    41134120    /** @todo Use the On-Screen Display feature to report the fact.
    4114      *  The user should be told to install additions that are
    4115      *  provided with the current VBox build:
    4116      *  VBOX_VERSION_MAJOR.VBOX_VERSION_MINOR.VBOX_VERSION_BUILD
     4121     * The user should be told to install additions that are
     4122     * provided with the current VBox build:
     4123     * VBOX_VERSION_MAJOR.VBOX_VERSION_MINOR.VBOX_VERSION_BUILD
    41174124     */
    41184125}
    41194126
    41204127/**
    4121  *  @note Locks this object for writing.
     4128 * @note Locks this object for writing.
    41224129 */
    41234130void Console::onKeyboardLedsChange(bool fNumLock, bool fCapsLock, bool fScrollLock)
    41244131{
    41254132    AutoCaller autoCaller(this);
    4126     AssertComRCReturnVoid (autoCaller.rc());
     4133    AssertComRCReturnVoid(autoCaller.rc());
    41274134
    41284135    /* We need a write lock because we alter the cached callback data */
     
    41414148
    41424149/**
    4143  *  @note Locks this object for reading.
     4150 * @note Locks this object for reading.
    41444151 */
    4145 void Console::onUSBDeviceStateChange (IUSBDevice *aDevice, bool aAttached,
    4146                                       IVirtualBoxErrorInfo *aError)
     4152void Console::onUSBDeviceStateChange(IUSBDevice *aDevice, bool aAttached,
     4153                                     IVirtualBoxErrorInfo *aError)
    41474154{
    41484155    AutoCaller autoCaller(this);
    4149     AssertComRCReturnVoid (autoCaller.rc());
     4156    AssertComRCReturnVoid(autoCaller.rc());
    41504157
    41514158    AutoReadLock alock(this);
     
    41534160    CallbackList::iterator it = mCallbacks.begin();
    41544161    while (it != mCallbacks.end())
    4155         (*it++)->OnUSBDeviceStateChange (aDevice, aAttached, aError);
     4162        (*it++)->OnUSBDeviceStateChange(aDevice, aAttached, aError);
    41564163}
    41574164
    41584165/**
    4159  *  @note Locks this object for reading.
     4166 * @note Locks this object for reading.
    41604167 */
    4161 void Console::onRuntimeError (BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage)
     4168void Console::onRuntimeError(BOOL aFatal, IN_BSTR aErrorID, IN_BSTR aMessage)
    41624169{
    41634170    AutoCaller autoCaller(this);
    4164     AssertComRCReturnVoid (autoCaller.rc());
     4171    AssertComRCReturnVoid(autoCaller.rc());
    41654172
    41664173    AutoReadLock alock(this);
     
    41684175    CallbackList::iterator it = mCallbacks.begin();
    41694176    while (it != mCallbacks.end())
    4170         (*it++)->OnRuntimeError (aFatal, aErrorID, aMessage);
     4177        (*it++)->OnRuntimeError(aFatal, aErrorID, aMessage);
    41714178}
    41724179
    41734180/**
    4174  *  @note Locks this object for reading.
     4181 * @note Locks this object for reading.
    41754182 */
    4176 HRESULT Console::onShowWindow (BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId)
     4183HRESULT Console::onShowWindow(BOOL aCheck, BOOL *aCanShow, ULONG64 *aWinId)
    41774184{
    41784185    AssertReturn(aCanShow, E_POINTER);
     
    41954202        {
    41964203            BOOL canShow = FALSE;
    4197             rc = (*it++)->OnCanShowWindow (&canShow);
    4198             AssertComRC (rc);
    4199             if (FAILED (rc) || !canShow)
     4204            rc = (*it++)->OnCanShowWindow(&canShow);
     4205            AssertComRC(rc);
     4206            if (FAILED(rc) || !canShow)
    42004207                return rc;
    42014208        }
     
    42074214        {
    42084215            ULONG64 winId = 0;
    4209             rc = (*it++)->OnShowWindow (&winId);
    4210             AssertComRC (rc);
    4211             if (FAILED (rc))
     4216            rc = (*it++)->OnShowWindow(&winId);
     4217            AssertComRC(rc);
     4218            if (FAILED(rc))
    42124219                return rc;
    42134220            /* only one callback may return non-null winId */
    4214             Assert (*aWinId == 0 || winId == 0);
     4221            Assert(*aWinId == 0 || winId == 0);
    42154222            if (*aWinId == 0)
    42164223                *aWinId = winId;
     
    42254232
    42264233/**
    4227  *  Increases the usage counter of the mpVM pointer. Guarantees that
    4228  *  VMR3Destroy() will not be called on it at least until releaseVMCaller()
    4229  *  is called.
    4230  *
    4231  *  If this method returns a failure, the caller is not allowed to use mpVM
    4232  *  and may return the failed result code to the upper level. This method sets
    4233  *  the extended error info on failure if \a aQuiet is false.
    4234  *
    4235  *  Setting \a aQuiet to true is useful for methods that don't want to return
    4236  *  the failed result code to the caller when this method fails (e.g. need to
    4237  *  silently check for the mpVM availability).
    4238  *
    4239  *  When mpVM is NULL but \a aAllowNullVM is true, a corresponding error will be
    4240  *  returned instead of asserting. Having it false is intended as a sanity check
    4241  *  for methods that have checked mMachineState and expect mpVM *NOT* to be NULL.
    4242  *
    4243  *  @param aQuiet       true to suppress setting error info
    4244  *  @param aAllowNullVM true to accept mpVM being NULL and return a failure
    4245  *                      (otherwise this method will assert if mpVM is NULL)
    4246  *
    4247  *  @note Locks this object for writing.
     4234 * Increases the usage counter of the mpVM pointer. Guarantees that
     4235 * VMR3Destroy() will not be called on it at least until releaseVMCaller()
     4236 * is called.
     4237 *
     4238 * If this method returns a failure, the caller is not allowed to use mpVM
     4239 * and may return the failed result code to the upper level. This method sets
     4240 * the extended error info on failure if \a aQuiet is false.
     4241 *
     4242 * Setting \a aQuiet to true is useful for methods that don't want to return
     4243 * the failed result code to the caller when this method fails (e.g. need to
     4244 * silently check for the mpVM availability).
     4245 *
     4246 * When mpVM is NULL but \a aAllowNullVM is true, a corresponding error will be
     4247 * returned instead of asserting. Having it false is intended as a sanity check
     4248 * for methods that have checked mMachineState and expect mpVM *NOT* to be NULL.
     4249 *
     4250 * @param aQuiet       true to suppress setting error info
     4251 * @param aAllowNullVM true to accept mpVM being NULL and return a failure
     4252 *                     (otherwise this method will assert if mpVM is NULL)
     4253 *
     4254 * @note Locks this object for writing.
    42484255 */
    4249 HRESULT Console::addVMCaller (bool aQuiet /* = false */,
    4250                               bool aAllowNullVM /* = false */)
    4251 {
    4252     AutoCaller  autoCaller (this);
     4256HRESULT Console::addVMCaller(bool aQuiet /* = false */,
     4257                             bool aAllowNullVM /* = false */)
     4258{
     4259    AutoCaller autoCaller(this);
    42534260    AssertComRCReturnRC(autoCaller.rc());
    42544261
     
    42584265    {
    42594266        /* powerDown() is waiting for all callers to finish */
    4260         return aQuiet ? E_ACCESSDENIED : setError (E_ACCESSDENIED,
    4261             tr ("Virtual machine is being powered down"));
     4267        return aQuiet ? E_ACCESSDENIED : setError(E_ACCESSDENIED,
     4268            tr("Virtual machine is being powered down"));
    42624269    }
    42634270
    42644271    if (mpVM == NULL)
    42654272    {
    4266         Assert (aAllowNullVM == true);
     4273        Assert(aAllowNullVM == true);
    42674274
    42684275        /* The machine is not powered up */
    4269         return aQuiet ? E_ACCESSDENIED : setError (E_ACCESSDENIED,
    4270             tr ("Virtual machine is not powered up"));
     4276        return aQuiet ? E_ACCESSDENIED : setError(E_ACCESSDENIED,
     4277            tr("Virtual machine is not powered up"));
    42714278    }
    42724279
     
    42774284
    42784285/**
    4279  *  Decreases the usage counter of the mpVM pointer. Must always complete
    4280  *  the addVMCaller() call after the mpVM pointer is no more necessary.
    4281  *
    4282  *  @note Locks this object for writing.
     4286 * Decreases the usage counter of the mpVM pointer. Must always complete
     4287 * the addVMCaller() call after the mpVM pointer is no more necessary.
     4288 *
     4289 * @note Locks this object for writing.
    42834290 */
    42844291void Console::releaseVMCaller()
    42854292{
    4286     AutoCaller  autoCaller (this);
    4287     AssertComRCReturnVoid (autoCaller.rc());
     4293    AutoCaller autoCaller(this);
     4294    AssertComRCReturnVoid(autoCaller.rc());
    42884295
    42894296    AutoWriteLock alock(this);
    42904297
    4291     AssertReturnVoid (mpVM != NULL);
    4292 
    4293     Assert (mVMCallers > 0);
    4294     -- mVMCallers;
     4298    AssertReturnVoid(mpVM != NULL);
     4299
     4300    Assert(mVMCallers > 0);
     4301    --mVMCallers;
    42954302
    42964303    if (mVMCallers == 0 && mVMDestroying)
    42974304    {
    42984305        /* inform powerDown() there are no more callers */
    4299         RTSemEventSignal (mVMZeroCallersSem);
     4306        RTSemEventSignal(mVMZeroCallersSem);
    43004307    }
    43014308}
     
    43074314 * Note that the logic must be in sync with Machine::DeleteSettings().
    43084315 */
    4309 HRESULT Console::consoleInitReleaseLog (const ComPtr<IMachine> aMachine)
     4316HRESULT Console::consoleInitReleaseLog(const ComPtr<IMachine> aMachine)
    43104317{
    43114318    HRESULT hrc = S_OK;
    43124319
    43134320    Bstr logFolder;
    4314     hrc = aMachine->COMGETTER(LogFolder) (logFolder.asOutParam());
     4321    hrc = aMachine->COMGETTER(LogFolder)(logFolder.asOutParam());
    43154322    CheckComRCReturnRC(hrc);
    43164323
     
    43504357            Utf8Str oldName, newName;
    43514358
    4352             for (unsigned int j = 0; j < RT_ELEMENTS (files); ++ j)
     4359            for (unsigned int j = 0; j < RT_ELEMENTS(files); ++ j)
    43534360            {
    43544361                if (i > 0)
    4355                     oldName = Utf8StrFmt ("%s.%d", files [j]->raw(), i);
     4362                    oldName = Utf8StrFmt("%s.%d", files[j]->raw(), i);
    43564363                else
    4357                     oldName = *files [j];
    4358                 newName = Utf8StrFmt ("%s.%d", files [j]->raw(), i + 1);
     4364                    oldName = *files[j];
     4365                newName = Utf8StrFmt("%s.%d", files[j]->raw(), i + 1);
    43594366                /* If the old file doesn't exist, delete the new file (if it
    43604367                 * exists) to provide correct rotation even if the sequence is
     
    43704377    static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
    43714378    RTUINT fFlags = RTLOGFLAGS_PREFIX_TIME_PROG;
    4372 #if defined (RT_OS_WINDOWS) || defined (RT_OS_OS2)
     4379#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
    43734380    fFlags |= RTLOGFLAGS_USECRLF;
    43744381#endif
     
    44264433    }
    44274434    else
    4428         hrc = setError (E_FAIL,
    4429                         tr ("Failed to open release log (%s, %Rrc)"), szError, vrc);
     4435        hrc = setError(E_FAIL,
     4436            tr("Failed to open release log (%s, %Rrc)"),
     4437            szError, vrc);
    44304438
    44314439    return hrc;
     
    44424450 * @todo move down to powerDown();
    44434451 */
    4444 HRESULT Console::powerUp (IProgress **aProgress, bool aPaused)
     4452HRESULT Console::powerUp(IProgress **aProgress, bool aPaused)
    44454453{
    44464454    if (aProgress == NULL)
     
    44554463    AutoWriteLock alock(this);
    44564464
    4457     if (Global::IsOnlineOrTransient (mMachineState))
     4465    if (Global::IsOnlineOrTransient(mMachineState))
    44584466        return setError(VBOX_E_INVALID_VM_STATE,
    4459             tr ("Virtual machine is already running or busy "
    4460                 "(machine state: %d)"), mMachineState);
     4467            tr("Virtual machine is already running or busy (machine state: %d)"),
     4468            mMachineState);
    44614469
    44624470    HRESULT rc = S_OK;
     
    44664474    {
    44674475        ComPtr<INetworkAdapter> adapter;
    4468         mMachine->GetNetworkAdapter (slot, adapter.asOutParam());
     4476        mMachine->GetNetworkAdapter(slot, adapter.asOutParam());
    44694477        BOOL enabled = FALSE;
    4470         adapter->COMGETTER(Enabled) (&enabled);
     4478        adapter->COMGETTER(Enabled)(&enabled);
    44714479        if (!enabled)
    44724480            continue;
     
    44844492                if (!hostif)
    44854493                {
    4486                     return setError (VBOX_E_HOST_ERROR,
    4487                         tr ("VM cannot start because host interface networking "
    4488                             "requires a host interface name to be set"));
     4494                    return setError(VBOX_E_HOST_ERROR,
     4495                        tr("VM cannot start because host interface networking requires a host interface name to be set"));
    44894496                }
    44904497                ComPtr<IVirtualBox> virtualBox;
     
    44954502                if (!SUCCEEDED(host->FindHostNetworkInterfaceByName(hostif, hostInterface.asOutParam())))
    44964503                {
    4497                     return setError (VBOX_E_HOST_ERROR,
    4498                         tr ("VM cannot start because the host interface '%ls' "
    4499                             "does not exist"),
     4504                    return setError(VBOX_E_HOST_ERROR,
     4505                        tr("VM cannot start because the host interface '%ls' does not exist"),
    45004506                        hostif.raw());
    45014507                }
     
    45184524        for (SharedFolderDataMap::const_iterator it = mGlobalSharedFolders.begin();
    45194525             it != mGlobalSharedFolders.end(); ++ it)
    4520             sharedFolders [it->first] = it->second;
     4526            sharedFolders[it->first] = it->second;
    45214527
    45224528        /* second, insert machine folders */
    45234529        for (SharedFolderDataMap::const_iterator it = mMachineSharedFolders.begin();
    45244530             it != mMachineSharedFolders.end(); ++ it)
    4525             sharedFolders [it->first] = it->second;
     4531            sharedFolders[it->first] = it->second;
    45264532
    45274533        /* third, insert console folders */
    45284534        for (SharedFolderMap::const_iterator it = mSharedFolders.begin();
    45294535             it != mSharedFolders.end(); ++ it)
    4530             sharedFolders [it->first] = SharedFolderData(it->second->hostPath(), it->second->writable());
     4536            sharedFolders[it->first] = SharedFolderData(it->second->hostPath(), it->second->writable());
    45314537    }
    45324538
     
    45384544    if (mMachineState == MachineState_Saved)
    45394545    {
    4540         rc = mMachine->COMGETTER(StateFilePath) (savedStateFile.asOutParam());
     4546        rc = mMachine->COMGETTER(StateFilePath)(savedStateFile.asOutParam());
    45414547        CheckComRCReturnRC(rc);
    4542         ComAssertRet (!!savedStateFile, E_FAIL);
     4548        ComAssertRet(!!savedStateFile, E_FAIL);
    45434549        int vrc = SSMR3ValidateFile(Utf8Str(savedStateFile).c_str(), false /* fChecksumIt */);
    4544         if (VBOX_FAILURE(vrc))
     4550        if (RT_FAILURE(vrc))
    45454551            return setError(VBOX_E_FILE_ERROR,
    4546                             tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). "
    4547                                "Discard the saved state prior to starting the VM"),
     4552                            tr("VM cannot start because the saved state file '%ls' is invalid (%Rrc). Discard the saved state prior to starting the VM"),
    45484553                            savedStateFile.raw(), vrc);
    45494554    }
     
    45544559    Bstr progressDesc;
    45554560    if (mMachineState == MachineState_Saved)
    4556         progressDesc = tr ("Restoring virtual machine");
     4561        progressDesc = tr("Restoring virtual machine");
    45574562    else
    4558         progressDesc = tr ("Starting virtual machine");
    4559     rc = powerupProgress->init (static_cast <IConsole *> (this),
    4560                                 progressDesc, FALSE /* aCancelable */);
     4563        progressDesc = tr("Starting virtual machine");
     4564    rc = powerupProgress->init(static_cast<IConsole *>(this),
     4565                               progressDesc, FALSE /* aCancelable */);
    45614566    CheckComRCReturnRC(rc);
    45624567
     
    45644569     * asynchronously */
    45654570
    4566     std::auto_ptr <VMPowerUpTask> task (new VMPowerUpTask (this, powerupProgress));
    4567     ComAssertComRCRetRC (task->rc());
     4571    std::auto_ptr<VMPowerUpTask> task(new VMPowerUpTask(this, powerupProgress));
     4572    ComAssertComRCRetRC(task->rc());
    45684573
    45694574    task->mSetVMErrorCallback = setVMErrorCallback;
     
    45774582    {
    45784583        com::SafeIfaceArray<IMediumAttachment> atts;
    4579         rc = mMachine->COMGETTER(MediumAttachments) (ComSafeArrayAsOutParam(atts));
     4584        rc = mMachine->COMGETTER(MediumAttachments)(ComSafeArrayAsOutParam(atts));
    45804585        CheckComRCReturnRC(rc);
    45814586
     
    46294634            ComObjPtr<CombinedProgress> progress;
    46304635            progress.createObject();
    4631             VMPowerUpTask::ProgressList progresses (task->hardDiskProgresses);
    4632             progresses.push_back (ComPtr<IProgress> (powerupProgress));
    4633             rc = progress->init (static_cast <IConsole *> (this),
    4634                                  progressDesc, progresses.begin(),
    4635                                  progresses.end());
     4636            VMPowerUpTask::ProgressList progresses(task->hardDiskProgresses);
     4637            progresses.push_back(ComPtr<IProgress> (powerupProgress));
     4638            rc = progress->init(static_cast<IConsole *>(this),
     4639                                progressDesc, progresses.begin(),
     4640                                progresses.end());
    46364641            AssertComRCReturnRC(rc);
    46374642            progress.queryInterfaceTo(aProgress);
     
    46394644    }
    46404645
    4641     int vrc = RTThreadCreate (NULL, Console::powerUpThread, (void *) task.get(),
    4642                               0, RTTHREADTYPE_MAIN_WORKER, 0, "VMPowerUp");
    4643 
    4644     ComAssertMsgRCRet (vrc, ("Could not create VMPowerUp thread (%Rrc)", vrc),
    4645                        E_FAIL);
     4646    int vrc = RTThreadCreate(NULL, Console::powerUpThread, (void *) task.get(),
     4647                             0, RTTHREADTYPE_MAIN_WORKER, 0, "VMPowerUp");
     4648
     4649    ComAssertMsgRCRet(vrc, ("Could not create VMPowerUp thread (%Rrc)", vrc),
     4650                      E_FAIL);
    46464651
    46474652    /* task is now owned by powerUpThread(), so release it */
     
    46534658
    46544659    if (mMachineState == MachineState_Saved)
    4655         setMachineState (MachineState_Restoring);
     4660        setMachineState(MachineState_Restoring);
    46564661    else
    4657         setMachineState (MachineState_Starting);
     4662        setMachineState(MachineState_Starting);
    46584663
    46594664    LogFlowThisFunc(("mMachineState=%d\n", mMachineState));
     
    46904695 *       release(). Otherwise it will deadlock.
    46914696 */
    4692 HRESULT Console::powerDown (Progress *aProgress /*= NULL*/)
     4697HRESULT Console::powerDown(Progress *aProgress /*= NULL*/)
    46934698{
    46944699    LogFlowThisFuncEnter();
     
    47094714
    47104715    /* sanity */
    4711     Assert (mVMDestroying == false);
    4712 
    4713     Assert (mpVM != NULL);
    4714 
    4715     AssertMsg (mMachineState == MachineState_Running ||
    4716                mMachineState == MachineState_Paused ||
    4717                mMachineState == MachineState_Stuck ||
    4718                mMachineState == MachineState_Saving ||
    4719                mMachineState == MachineState_Starting ||
    4720                mMachineState == MachineState_Restoring ||
    4721                mMachineState == MachineState_Stopping,
    4722                ("Invalid machine state: %d\n", mMachineState));
    4723 
    4724     LogRel (("Console::powerDown(): A request to power off the VM has been "
    4725              "issued (mMachineState=%d, InUninit=%d)\n",
     4716    Assert(mVMDestroying == false);
     4717
     4718    Assert(mpVM != NULL);
     4719
     4720    AssertMsg(mMachineState == MachineState_Running ||
     4721              mMachineState == MachineState_Paused ||
     4722              mMachineState == MachineState_Stuck ||
     4723              mMachineState == MachineState_Saving ||
     4724              mMachineState == MachineState_Starting ||
     4725              mMachineState == MachineState_Restoring ||
     4726              mMachineState == MachineState_Stopping,
     4727              ("Invalid machine state: %d\n", mMachineState));
     4728
     4729    LogRel(("Console::powerDown(): A request to power off the VM has been issued (mMachineState=%d, InUninit=%d)\n",
    47264730             mMachineState, autoCaller.state() == InUninit));
    47274731
     
    47444748        mMachineState != MachineState_Restoring &&
    47454749        mMachineState != MachineState_Stopping)
    4746         setMachineState (MachineState_Stopping);
     4750        setMachineState(MachineState_Stopping);
    47474751
    47484752    /* ----------------------------------------------------------------------
     
    47834787        rc = E_OUTOFMEMORY;
    47844788    else
    4785         rc = doEnumerateGuestProperties (Bstr (""), ComSafeArrayAsOutParam (namesOut),
    4786                                         ComSafeArrayAsOutParam (valuesOut),
    4787                                         ComSafeArrayAsOutParam (timestampsOut),
    4788                                         ComSafeArrayAsOutParam (flagsOut));
     4789        rc = doEnumerateGuestProperties(Bstr(""), ComSafeArrayAsOutParam(namesOut),
     4790                                        ComSafeArrayAsOutParam(valuesOut),
     4791                                        ComSafeArrayAsOutParam(timestampsOut),
     4792                                        ComSafeArrayAsOutParam(flagsOut));
    47894793    if (SUCCEEDED(rc))
    47904794    {
     
    47984802            {
    47994803                uint32_t fFlags;
    4800                 guestProp::validateFlags (Utf8Str(flagsOut[i]).raw(), &fFlags);
     4804                guestProp::validateFlags(Utf8Str(flagsOut[i]).raw(), &fFlags);
    48014805                if (   !( fFlags & guestProp::TRANSIENT)
    48024806                    || (mMachineState == MachineState_Saving)
     
    48094813                }
    48104814            }
    4811             com::SafeArray<BSTR> namesIn (names);
    4812             com::SafeArray<BSTR> valuesIn (values);
    4813             com::SafeArray<ULONG64> timestampsIn (timestamps);
    4814             com::SafeArray<BSTR> flagsIn (flags);
     4815            com::SafeArray<BSTR> namesIn(names);
     4816            com::SafeArray<BSTR> valuesIn(values);
     4817            com::SafeArray<ULONG64> timestampsIn(timestamps);
     4818            com::SafeArray<BSTR> flagsIn(flags);
    48154819            if (   namesIn.isNull()
    48164820                || valuesIn.isNull()
     
    48214825            /* PushGuestProperties() calls DiscardSettings(), which calls us back */
    48224826            alock.leave();
    4823             mControl->PushGuestProperties (ComSafeArrayAsInParam (namesIn),
    4824                                           ComSafeArrayAsInParam (valuesIn),
    4825                                           ComSafeArrayAsInParam (timestampsIn),
    4826                                           ComSafeArrayAsInParam (flagsIn));
     4827            mControl->PushGuestProperties(ComSafeArrayAsInParam(namesIn),
     4828                                          ComSafeArrayAsInParam(valuesIn),
     4829                                          ComSafeArrayAsInParam(timestampsIn),
     4830                                          ComSafeArrayAsInParam(flagsIn));
    48274831            alock.enter();
    48284832        }
     
    48484852        alock.leave();
    48494853
    4850         mVMMDev->hgcmShutdown ();
     4854        mVMMDev->hgcmShutdown();
    48514855
    48524856        alock.enter();
     
    48724876        /* lazy creation */
    48734877        if (mVMZeroCallersSem == NIL_RTSEMEVENT)
    4874             RTSemEventCreate (&mVMZeroCallersSem);
     4878            RTSemEventCreate(&mVMZeroCallersSem);
    48754879
    48764880        LogFlowThisFunc(("Waiting for mpVM callers (%d) to drop to zero...\n",
     
    48794883        alock.leave();
    48804884
    4881         RTSemEventWait (mVMZeroCallersSem, RT_INDEFINITE_WAIT);
     4885        RTSemEventWait(mVMZeroCallersSem, RT_INDEFINITE_WAIT);
    48824886
    48834887        alock.enter();
     
    48984902        alock.leave();
    48994903
    4900         vrc = VMR3PowerOff (mpVM);
     4904        vrc = VMR3PowerOff(mpVM);
    49014905
    49024906        /* Note that VMR3PowerOff() may fail here (invalid VMSTATE) if the
     
    49214925    /* If we are called from Console::uninit(), then try to destroy the VM even
    49224926     * on failure (this will most likely fail too, but what to do?..) */
    4923     if (VBOX_SUCCESS (vrc) || autoCaller.state() == InUninit)
     4927    if (RT_SUCCESS(vrc) || autoCaller.state() == InUninit)
    49244928    {
    49254929        /* If the machine has an USB comtroller, release all USB devices
     
    49284932        {
    49294933            PPDMIBASE pBase;
    4930             int vrc = PDMR3QueryLun (mpVM, "usb-ohci", 0, 0, &pBase);
    4931             if (VBOX_SUCCESS (vrc))
     4934            int vrc = PDMR3QueryLun(mpVM, "usb-ohci", 0, 0, &pBase);
     4935            if (RT_SUCCESS(vrc))
    49324936            {
    49334937                fHasUSBController = true;
    4934                 detachAllUSBDevices (false /* aDone */);
     4938                detachAllUSBDevices(false /* aDone */);
    49354939            }
    49364940        }
     
    49524956        alock.leave();
    49534957
    4954         vrc = VMR3Destroy (pVM);
     4958        vrc = VMR3Destroy(pVM);
    49554959
    49564960        /* take the lock again */
     
    49614965            aProgress->SetCurrentOperationProgress(99 * (++ step) / StepCount );
    49624966
    4963         if (VBOX_SUCCESS (vrc))
     4967        if (RT_SUCCESS(vrc))
    49644968        {
    49654969            LogFlowThisFunc(("Machine has been destroyed (mMachineState=%d)\n",
     
    49774981            /* bad bad bad, but what to do? */
    49784982            mpVM = pVM;
    4979             rc = setError (VBOX_E_VM_ERROR,
    4980                 tr ("Could not destroy the machine.  (Error: %Rrc)"), vrc);
     4983            rc = setError(VBOX_E_VM_ERROR,
     4984                tr("Could not destroy the machine. (Error: %Rrc)"),
     4985                vrc);
    49814986        }
    49824987
    49834988        /* Complete the detaching of the USB devices. */
    49844989        if (fHasUSBController)
    4985             detachAllUSBDevices (true /* aDone */);
     4990            detachAllUSBDevices(true /* aDone */);
    49864991
    49874992        /* advance percent count */
     
    49914996    else
    49924997    {
    4993         rc = setError (VBOX_E_VM_ERROR,
    4994             tr ("Could not power off the machine.  (Error: %Rrc)"), vrc);
     4998        rc = setError(VBOX_E_VM_ERROR,
     4999            tr("Could not power off the machine. (Error: %Rrc)"),
     5000            vrc);
    49955001    }
    49965002
     
    50085014        {
    50095015            if (mCallbackData.mpsc.shape != NULL)
    5010                 RTMemFree (mCallbackData.mpsc.shape);
    5011         }
    5012         memset (&mCallbackData, 0, sizeof (mCallbackData));
     5016                RTMemFree(mCallbackData.mpsc.shape);
     5017        }
     5018        memset(&mCallbackData, 0, sizeof(mCallbackData));
    50135019    }
    50145020
    50155021    /* complete the progress */
    50165022    if (aProgress)
    5017         aProgress->notifyComplete (rc);
     5023        aProgress->notifyComplete(rc);
    50185024
    50195025    LogFlowThisFuncLeave();
     
    50225028
    50235029/**
    5024  *  @note Locks this object for writing.
     5030 * @note Locks this object for writing.
    50255031 */
    5026 HRESULT Console::setMachineState (MachineState_T aMachineState,
     5032HRESULT Console::setMachineState(MachineState_T aMachineState,
    50275033                                  bool aUpdateServer /* = true */)
    50285034{
     
    50475053        //      necessary??)
    50485054        LogFlowThisFunc(("Doing onStateChange()...\n"));
    5049         onStateChange (aMachineState);
     5055        onStateChange(aMachineState);
    50505056        LogFlowThisFunc(("Done onStateChange()\n"));
    50515057
     
    50545060            /* Server notification MUST be done from under the lock; otherwise
    50555061             * the machine state here and on the server might go out of sync
    5056              * whihc can lead to various unexpected results (like the machine
     5062             * which can lead to various unexpected results (like the machine
    50575063             * state being >= MachineState_Running on the server, while the
    50585064             * session state is already SessionState_Closed at the same time
     
    50665072             */
    50675073            LogFlowThisFunc(("Doing mControl->UpdateState()...\n"));
    5068             rc = mControl->UpdateState (aMachineState);
     5074            rc = mControl->UpdateState(aMachineState);
    50695075            LogFlowThisFunc(("mControl->UpdateState()=%08X\n", rc));
    50705076        }
     
    50755081
    50765082/**
    5077  *  Searches for a shared folder with the given logical name
    5078  *  in the collection of shared folders.
    5079  *
    5080  *  @param aName            logical name of the shared folder
    5081  *  @param aSharedFolder    where to return the found object
    5082  *  @param aSetError        whether to set the error info if the folder is
    5083  *                          not found
    5084  *  @return
    5085  *      S_OK when found or E_INVALIDARG when not found
    5086  *
    5087  *  @note The caller must lock this object for writing.
     5083 * Searches for a shared folder with the given logical name
     5084 * in the collection of shared folders.
     5085 *
     5086 * @param aName            logical name of the shared folder
     5087 * @param aSharedFolder    where to return the found object
     5088 * @param aSetError        whether to set the error info if the folder is
     5089 *                         not found
     5090 * @return
     5091 *     S_OK when found or E_INVALIDARG when not found
     5092 *
     5093 * @note The caller must lock this object for writing.
    50885094 */
    5089 HRESULT Console::findSharedFolder (CBSTR aName,
    5090                                    ComObjPtr<SharedFolder> &aSharedFolder,
    5091                                    bool aSetError /* = false */)
     5095HRESULT Console::findSharedFolder(CBSTR aName,
     5096                                  ComObjPtr<SharedFolder> &aSharedFolder,
     5097                                  bool aSetError /* = false */)
    50925098{
    50935099    /* sanity check */
    50945100    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
    50955101
    5096     SharedFolderMap::const_iterator it = mSharedFolders.find (aName);
     5102    SharedFolderMap::const_iterator it = mSharedFolders.find(aName);
    50975103    if (it != mSharedFolders.end())
    50985104    {
     
    51025108
    51035109    if (aSetError)
    5104         setError (VBOX_E_FILE_ERROR,
    5105                   tr ("Could not find a shared folder named '%ls'."), aName);
     5110        setError(VBOX_E_FILE_ERROR,
     5111            tr("Could not find a shared folder named '%ls'."),
     5112            aName);
    51065113
    51075114    return VBOX_E_FILE_ERROR;
     
    51095116
    51105117/**
    5111  *  Fetches the list of global or machine shared folders from the server.
    5112  *
    5113  *  @param aGlobal true to fetch global folders.
    5114  *
    5115  *  @note The caller must lock this object for writing.
     5118 * Fetches the list of global or machine shared folders from the server.
     5119 *
     5120 * @param aGlobal true to fetch global folders.
     5121 *
     5122 * @note The caller must lock this object for writing.
    51165123 */
    5117 HRESULT Console::fetchSharedFolders (BOOL aGlobal)
     5124HRESULT Console::fetchSharedFolders(BOOL aGlobal)
    51185125{
    51195126    /* sanity check */
    5120     AssertReturn(AutoCaller (this).state() == InInit ||
    5121                   isWriteLockOnCurrentThread(), E_FAIL);
     5127    AssertReturn(AutoCaller(this).state() == InInit ||
     5128                 isWriteLockOnCurrentThread(), E_FAIL);
    51225129
    51235130    /* protect mpVM (if not NULL) */
    5124     AutoVMCallerQuietWeak autoVMCaller (this);
     5131    AutoVMCallerQuietWeak autoVMCaller(this);
    51255132
    51265133    HRESULT rc = S_OK;
     
    51415148
    51425149        SafeIfaceArray<ISharedFolder> folders;
    5143         rc = mMachine->COMGETTER(SharedFolders) (ComSafeArrayAsOutParam(folders));
     5150        rc = mMachine->COMGETTER(SharedFolders)(ComSafeArrayAsOutParam(folders));
    51445151        AssertComRCReturnRC(rc);
    51455152
     
    51525159            BOOL writable;
    51535160
    5154             rc = folder->COMGETTER(Name) (name.asOutParam());
    5155             CheckComRCBreakRC (rc);
    5156             rc = folder->COMGETTER(HostPath) (hostPath.asOutParam());
    5157             CheckComRCBreakRC (rc);
    5158             rc = folder->COMGETTER(Writable) (&writable);
    5159 
    5160             mMachineSharedFolders.insert (std::make_pair (name, SharedFolderData (hostPath, writable)));
     5161            rc = folder->COMGETTER(Name)(name.asOutParam());
     5162            CheckComRCBreakRC(rc);
     5163            rc = folder->COMGETTER(HostPath)(hostPath.asOutParam());
     5164            CheckComRCBreakRC(rc);
     5165            rc = folder->COMGETTER(Writable)(&writable);
     5166
     5167            mMachineSharedFolders.insert(std::make_pair(name, SharedFolderData(hostPath, writable)));
    51615168
    51625169            /* send changes to HGCM if the VM is running */
     
    51645171            if (online)
    51655172            {
    5166                 SharedFolderDataMap::iterator it = oldFolders.find (name);
     5173                SharedFolderDataMap::iterator it = oldFolders.find(name);
    51675174                if (it == oldFolders.end() || it->second.mHostPath != hostPath)
    51685175                {
    51695176                    /* a new machine folder is added or
    51705177                     * the existing machine folder is changed */
    5171                     if (mSharedFolders.find (name) != mSharedFolders.end())
     5178                    if (mSharedFolders.find(name) != mSharedFolders.end())
    51725179                        ; /* the console folder exists, nothing to do */
    51735180                    else
     
    51765183                         * or the global folder if any (when new) */
    51775184                        if (it != oldFolders.end() ||
    5178                             mGlobalSharedFolders.find (name) !=
     5185                            mGlobalSharedFolders.find(name) !=
    51795186                                mGlobalSharedFolders.end())
    5180                             rc = removeSharedFolder (name);
     5187                            rc = removeSharedFolder(name);
    51815188                        /* create the new machine folder */
    5182                         rc = createSharedFolder (name, SharedFolderData (hostPath, writable));
     5189                        rc = createSharedFolder(name, SharedFolderData(hostPath, writable));
    51835190                    }
    51845191                }
    51855192                /* forget the processed (or identical) folder */
    51865193                if (it != oldFolders.end())
    5187                     oldFolders.erase (it);
     5194                    oldFolders.erase(it);
    51885195
    51895196                rc = S_OK;
     
    52005207                 it != oldFolders.end(); ++ it)
    52015208            {
    5202                 if (mSharedFolders.find (it->first) != mSharedFolders.end())
     5209                if (mSharedFolders.find(it->first) != mSharedFolders.end())
    52035210                    ; /* the console folder exists, nothing to do */
    52045211                else
    52055212                {
    52065213                    /* remove the outdated machine folder */
    5207                     rc = removeSharedFolder (it->first);
     5214                    rc = removeSharedFolder(it->first);
    52085215                    /* create the global folder if there is any */
    52095216                    SharedFolderDataMap::const_iterator git =
    5210                         mGlobalSharedFolders.find (it->first);
     5217                        mGlobalSharedFolders.find(it->first);
    52115218                    if (git != mGlobalSharedFolders.end())
    5212                         rc = createSharedFolder (git->first, git->second);
     5219                        rc = createSharedFolder(git->first, git->second);
    52135220                }
    52145221            }
     
    52225229
    52235230/**
    5224  *  Searches for a shared folder with the given name in the list of machine
    5225  *  shared folders and then in the list of the global shared folders.
    5226  *
    5227  *  @param aName    Name of the folder to search for.
    5228  *  @param aIt      Where to store the pointer to the found folder.
    5229  *  @return         @c true if the folder was found and @c false otherwise.
    5230  *
    5231  *  @note The caller must lock this object for reading.
     5231 * Searches for a shared folder with the given name in the list of machine
     5232 * shared folders and then in the list of the global shared folders.
     5233 *
     5234 * @param aName    Name of the folder to search for.
     5235 * @param aIt      Where to store the pointer to the found folder.
     5236 * @return         @c true if the folder was found and @c false otherwise.
     5237 *
     5238 * @note The caller must lock this object for reading.
    52325239 */
    5233 bool Console::findOtherSharedFolder (IN_BSTR aName,
    5234                                      SharedFolderDataMap::const_iterator &aIt)
     5240bool Console::findOtherSharedFolder(IN_BSTR aName,
     5241                                    SharedFolderDataMap::const_iterator &aIt)
    52355242{
    52365243    /* sanity check */
     
    52385245
    52395246    /* first, search machine folders */
    5240     aIt = mMachineSharedFolders.find (aName);
     5247    aIt = mMachineSharedFolders.find(aName);
    52415248    if (aIt != mMachineSharedFolders.end())
    52425249        return true;
    52435250
    52445251    /* second, search machine folders */
    5245     aIt = mGlobalSharedFolders.find (aName);
     5252    aIt = mGlobalSharedFolders.find(aName);
    52465253    if (aIt != mGlobalSharedFolders.end())
    52475254        return true;
     
    52515258
    52525259/**
    5253  *  Calls the HGCM service to add a shared folder definition.
    5254  *
    5255  *  @param aName        Shared folder name.
    5256  *  @param aHostPath    Shared folder path.
    5257  *
    5258  *  @note Must be called from under AutoVMCaller and when mpVM != NULL!
    5259  *  @note Doesn't lock anything.
     5260 * Calls the HGCM service to add a shared folder definition.
     5261 *
     5262 * @param aName        Shared folder name.
     5263 * @param aHostPath    Shared folder path.
     5264 *
     5265 * @note Must be called from under AutoVMCaller and when mpVM != NULL!
     5266 * @note Doesn't lock anything.
    52605267 */
    5261 HRESULT Console::createSharedFolder (CBSTR aName, SharedFolderData aData)
    5262 {
    5263     ComAssertRet (aName && *aName, E_FAIL);
    5264     ComAssertRet (aData.mHostPath, E_FAIL);
     5268HRESULT Console::createSharedFolder(CBSTR aName, SharedFolderData aData)
     5269{
     5270    ComAssertRet(aName && *aName, E_FAIL);
     5271    ComAssertRet(aData.mHostPath, E_FAIL);
    52655272
    52665273    /* sanity checks */
     
    52685275    AssertReturn(mVMMDev->isShFlActive(), E_FAIL);
    52695276
    5270     VBOXHGCMSVCPARM  parms[SHFL_CPARMS_ADD_MAPPING];
    5271     SHFLSTRING      *pFolderName, *pMapName;
    5272     size_t           cbString;
    5273 
    5274     Log (("Adding shared folder '%ls' -> '%ls'\n", aName, aData.mHostPath.raw()));
    5275 
    5276     cbString = (RTUtf16Len (aData.mHostPath) + 1) * sizeof (RTUTF16);
     5277    VBOXHGCMSVCPARM parms[SHFL_CPARMS_ADD_MAPPING];
     5278    SHFLSTRING *pFolderName, *pMapName;
     5279    size_t cbString;
     5280
     5281    Log(("Adding shared folder '%ls' -> '%ls'\n", aName, aData.mHostPath.raw()));
     5282
     5283    cbString = (RTUtf16Len(aData.mHostPath) + 1) * sizeof(RTUTF16);
    52775284    if (cbString >= UINT16_MAX)
    5278         return setError (E_INVALIDARG, tr ("The name is too long"));
    5279     pFolderName = (SHFLSTRING *) RTMemAllocZ (sizeof (SHFLSTRING) + cbString);
    5280     Assert (pFolderName);
    5281     memcpy (pFolderName->String.ucs2, aData.mHostPath, cbString);
     5285        return setError(E_INVALIDARG, tr("The name is too long"));
     5286    pFolderName = (SHFLSTRING *) RTMemAllocZ(sizeof(SHFLSTRING) + cbString);
     5287    Assert(pFolderName);
     5288    memcpy(pFolderName->String.ucs2, aData.mHostPath, cbString);
    52825289
    52835290    pFolderName->u16Size   = (uint16_t)cbString;
     
    52865293    parms[0].type = VBOX_HGCM_SVC_PARM_PTR;
    52875294    parms[0].u.pointer.addr = pFolderName;
    5288     parms[0].u.pointer.size = sizeof (SHFLSTRING) + (uint16_t)cbString;
    5289 
    5290     cbString = (RTUtf16Len (aName) + 1) * sizeof (RTUTF16);
     5295    parms[0].u.pointer.size = sizeof(SHFLSTRING) + (uint16_t)cbString;
     5296
     5297    cbString = (RTUtf16Len(aName) + 1) * sizeof(RTUTF16);
    52915298    if (cbString >= UINT16_MAX)
    52925299    {
    5293         RTMemFree (pFolderName);
    5294         return setError (E_INVALIDARG, tr ("The host path is too long"));
    5295     }
    5296     pMapName = (SHFLSTRING *) RTMemAllocZ (sizeof(SHFLSTRING) + cbString);
    5297     Assert (pMapName);
    5298     memcpy (pMapName->String.ucs2, aName, cbString);
     5300        RTMemFree(pFolderName);
     5301        return setError(E_INVALIDARG, tr("The host path is too long"));
     5302    }
     5303    pMapName = (SHFLSTRING *) RTMemAllocZ(sizeof(SHFLSTRING) + cbString);
     5304    Assert(pMapName);
     5305    memcpy(pMapName->String.ucs2, aName, cbString);
    52995306
    53005307    pMapName->u16Size   = (uint16_t)cbString;
    5301     pMapName->u16Length = (uint16_t)cbString - sizeof (RTUTF16);
     5308    pMapName->u16Length = (uint16_t)cbString - sizeof(RTUTF16);
    53025309
    53035310    parms[1].type = VBOX_HGCM_SVC_PARM_PTR;
    53045311    parms[1].u.pointer.addr = pMapName;
    5305     parms[1].u.pointer.size = sizeof (SHFLSTRING) + (uint16_t)cbString;
     5312    parms[1].u.pointer.size = sizeof(SHFLSTRING) + (uint16_t)cbString;
    53065313
    53075314    parms[2].type = VBOX_HGCM_SVC_PARM_32BIT;
    53085315    parms[2].u.uint32 = aData.mWritable;
    53095316
    5310     int vrc = mVMMDev->hgcmHostCall ("VBoxSharedFolders",
    5311                                      SHFL_FN_ADD_MAPPING,
    5312                                      SHFL_CPARMS_ADD_MAPPING, &parms[0]);
    5313     RTMemFree (pFolderName);
    5314     RTMemFree (pMapName);
    5315 
    5316     if (VBOX_FAILURE (vrc))
    5317         return setError (E_FAIL,
    5318                          tr ("Could not create a shared folder '%ls' "
    5319                              "mapped to '%ls' (%Rrc)"),
    5320                          aName, aData.mHostPath.raw(), vrc);
     5317    int vrc = mVMMDev->hgcmHostCall("VBoxSharedFolders",
     5318                                    SHFL_FN_ADD_MAPPING,
     5319                                    SHFL_CPARMS_ADD_MAPPING, &parms[0]);
     5320    RTMemFree(pFolderName);
     5321    RTMemFree(pMapName);
     5322
     5323    if (RT_FAILURE(vrc))
     5324        return setError(E_FAIL,
     5325            tr("Could not create a shared folder '%ls' mapped to '%ls' (%Rrc)"),
     5326            aName, aData.mHostPath.raw(), vrc);
    53215327
    53225328    return S_OK;
     
    53245330
    53255331/**
    5326  *  Calls the HGCM service to remove the shared folder definition.
    5327  *
    5328  *  @param aName        Shared folder name.
    5329  *
    5330  *  @note Must be called from under AutoVMCaller and when mpVM != NULL!
    5331  *  @note Doesn't lock anything.
     5332 * Calls the HGCM service to remove the shared folder definition.
     5333 *
     5334 * @param aName        Shared folder name.
     5335 *
     5336 * @note Must be called from under AutoVMCaller and when mpVM != NULL!
     5337 * @note Doesn't lock anything.
    53325338 */
    5333 HRESULT Console::removeSharedFolder (CBSTR aName)
    5334 {
    5335     ComAssertRet (aName && *aName, E_FAIL);
     5339HRESULT Console::removeSharedFolder(CBSTR aName)
     5340{
     5341    ComAssertRet(aName && *aName, E_FAIL);
    53365342
    53375343    /* sanity checks */
     
    53395345    AssertReturn(mVMMDev->isShFlActive(), E_FAIL);
    53405346
    5341     VBOXHGCMSVCPARM  parms;
    5342     SHFLSTRING      *pMapName;
    5343     size_t           cbString;
    5344 
    5345     Log (("Removing shared folder '%ls'\n", aName));
    5346 
    5347     cbString = (RTUtf16Len (aName) + 1) * sizeof (RTUTF16);
     5347    VBOXHGCMSVCPARM parms;
     5348    SHFLSTRING *pMapName;
     5349    size_t cbString;
     5350
     5351    Log(("Removing shared folder '%ls'\n", aName));
     5352
     5353    cbString = (RTUtf16Len(aName) + 1) * sizeof(RTUTF16);
    53485354    if (cbString >= UINT16_MAX)
    5349         return setError (E_INVALIDARG, tr ("The name is too long"));
    5350     pMapName = (SHFLSTRING *) RTMemAllocZ (sizeof (SHFLSTRING) + cbString);
    5351     Assert (pMapName);
    5352     memcpy (pMapName->String.ucs2, aName, cbString);
     5355        return setError(E_INVALIDARG, tr("The name is too long"));
     5356    pMapName = (SHFLSTRING *) RTMemAllocZ(sizeof(SHFLSTRING) + cbString);
     5357    Assert(pMapName);
     5358    memcpy(pMapName->String.ucs2, aName, cbString);
    53535359
    53545360    pMapName->u16Size   = (uint16_t)cbString;
    5355     pMapName->u16Length = (uint16_t)cbString - sizeof (RTUTF16);
     5361    pMapName->u16Length = (uint16_t)cbString - sizeof(RTUTF16);
    53565362
    53575363    parms.type = VBOX_HGCM_SVC_PARM_PTR;
    53585364    parms.u.pointer.addr = pMapName;
    5359     parms.u.pointer.size = sizeof (SHFLSTRING) + (uint16_t)cbString;
    5360 
    5361     int vrc = mVMMDev->hgcmHostCall ("VBoxSharedFolders",
    5362                                      SHFL_FN_REMOVE_MAPPING,
    5363                                      1, &parms);
     5365    parms.u.pointer.size = sizeof(SHFLSTRING) + (uint16_t)cbString;
     5366
     5367    int vrc = mVMMDev->hgcmHostCall("VBoxSharedFolders",
     5368                                    SHFL_FN_REMOVE_MAPPING,
     5369                                    1, &parms);
    53645370    RTMemFree(pMapName);
    5365     if (VBOX_FAILURE (vrc))
    5366         return setError (E_FAIL,
    5367                          tr ("Could not remove the shared folder '%ls' (%Rrc)"),
    5368                          aName, vrc);
     5371    if (RT_FAILURE(vrc))
     5372        return setError(E_FAIL,
     5373                        tr("Could not remove the shared folder '%ls' (%Rrc)"),
     5374                        aName, vrc);
    53695375
    53705376    return S_OK;
     
    53725378
    53735379/**
    5374  *  VM state callback function. Called by the VMM
    5375  *  using its state machine states.
    5376  *
    5377  *  Primarily used to handle VM initiated power off, suspend and state saving,
    5378  *  but also for doing termination completed work (VMSTATE_TERMINATE).
    5379  *
    5380  *  In general this function is called in the context of the EMT.
    5381  *
    5382  *  @param   aVM         The VM handle.
    5383  *  @param   aState      The new state.
    5384  *  @param   aOldState   The old state.
    5385  *  @param   aUser       The user argument (pointer to the Console object).
    5386  *
    5387  *  @note Locks the Console object for writing.
     5380 * VM state callback function. Called by the VMM
     5381 * using its state machine states.
     5382 *
     5383 * Primarily used to handle VM initiated power off, suspend and state saving,
     5384 * but also for doing termination completed work (VMSTATE_TERMINATE).
     5385 *
     5386 * In general this function is called in the context of the EMT.
     5387 *
     5388 * @param   aVM         The VM handle.
     5389 * @param   aState      The new state.
     5390 * @param   aOldState   The old state.
     5391 * @param   aUser       The user argument (pointer to the Console object).
     5392 *
     5393 * @note Locks the Console object for writing.
    53885394 */
    53895395DECLCALLBACK(void) Console::vmstateChangeCallback(PVM aVM,
     
    53955401                 aOldState, aState, aVM));
    53965402
    5397     Console *that = static_cast<Console *> (aUser);
     5403    Console *that = static_cast<Console *>(aUser);
    53985404    AssertReturnVoid(that);
    53995405
     
    55515557                /* Change the machine state from Starting, Restoring or Paused
    55525558                 * to Running */
    5553                 Assert (   (   (   that->mMachineState == MachineState_Starting
    5554                                 || that->mMachineState == MachineState_Paused)
    5555                             && aOldState == VMSTATE_POWERING_ON)
    5556                         || (   (   that->mMachineState == MachineState_Restoring
    5557                                 || that->mMachineState == MachineState_Paused)
    5558                             && aOldState == VMSTATE_RESUMING));
    5559 
    5560                 that->setMachineState (MachineState_Running);
     5559                Assert(   (   (   that->mMachineState == MachineState_Starting
     5560                               || that->mMachineState == MachineState_Paused)
     5561                           && aOldState == VMSTATE_POWERING_ON)
     5562                       || (   (   that->mMachineState == MachineState_Restoring
     5563                               || that->mMachineState == MachineState_Paused)
     5564                           && aOldState == VMSTATE_RESUMING));
     5565
     5566                that->setMachineState(MachineState_Running);
    55615567            }
    55625568
     
    55905596
    55915597            /* Guru are only for running VMs */
    5592             Assert(Global::IsOnline (that->mMachineState));
     5598            Assert(Global::IsOnline(that->mMachineState));
    55935599
    55945600            that->setMachineState(MachineState_Stuck);
     
    56045610
    56055611/**
    5606  *  Sends a request to VMM to attach the given host device.
    5607  *  After this method succeeds, the attached device will appear in the
    5608  *  mUSBDevices collection.
    5609  *
    5610  *  @param aHostDevice  device to attach
    5611  *
    5612  *  @note Synchronously calls EMT.
    5613  *  @note Must be called from under this object's lock.
     5612 * Sends a request to VMM to attach the given host device.
     5613 * After this method succeeds, the attached device will appear in the
     5614 * mUSBDevices collection.
     5615 *
     5616 * @param aHostDevice  device to attach
     5617 *
     5618 * @note Synchronously calls EMT.
     5619 * @note Must be called from under this object's lock.
    56145620 */
    5615 HRESULT Console::attachUSBDevice (IUSBDevice *aHostDevice, ULONG aMaskedIfs)
     5621HRESULT Console::attachUSBDevice(IUSBDevice *aHostDevice, ULONG aMaskedIfs)
    56165622{
    56175623    AssertReturn(aHostDevice, E_FAIL);
     
    56245630
    56255631    /*
    5626      *  Get the address and the Uuid, and call the pfnCreateProxyDevice roothub
    5627      *  method in EMT (using usbAttachCallback()).
     5632     * Get the address and the Uuid, and call the pfnCreateProxyDevice roothub
     5633     * method in EMT (using usbAttachCallback()).
    56285634     */
    56295635    Bstr BstrAddress;
    5630     hrc = aHostDevice->COMGETTER (Address) (BstrAddress.asOutParam());
    5631     ComAssertComRCRetRC (hrc);
    5632 
    5633     Utf8Str Address (BstrAddress);
     5636    hrc = aHostDevice->COMGETTER(Address)(BstrAddress.asOutParam());
     5637    ComAssertComRCRetRC(hrc);
     5638
     5639    Utf8Str Address(BstrAddress);
    56345640
    56355641    Bstr id;
    5636     hrc = aHostDevice->COMGETTER (Id) (id.asOutParam());
    5637     ComAssertComRCRetRC (hrc);
     5642    hrc = aHostDevice->COMGETTER(Id)(id.asOutParam());
     5643    ComAssertComRCRetRC(hrc);
    56385644    Guid uuid(id);
    56395645
    56405646    BOOL fRemote = FALSE;
    5641     hrc = aHostDevice->COMGETTER (Remote) (&fRemote);
    5642     ComAssertComRCRetRC (hrc);
     5647    hrc = aHostDevice->COMGETTER(Remote)(&fRemote);
     5648    ComAssertComRCRetRC(hrc);
    56435649
    56445650    /* protect mpVM */
    5645     AutoVMCaller autoVMCaller (this);
     5651    AutoVMCaller autoVMCaller(this);
    56465652    CheckComRCReturnRC(autoVMCaller.rc());
    56475653
     
    56535659
    56545660/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
    5655     int vrc = VMR3ReqCallWait (mpVM, VMCPUID_ANY,
    5656                                (PFNRT) usbAttachCallback, 6, this, aHostDevice, uuid.ptr(), fRemote, Address.raw(), aMaskedIfs);
     5661    int vrc = VMR3ReqCallWait(mpVM, VMCPUID_ANY,
     5662                              (PFNRT) usbAttachCallback, 6, this, aHostDevice, uuid.ptr(), fRemote, Address.raw(), aMaskedIfs);
    56575663
    56585664    /* restore the lock */
     
    56615667    /* hrc is S_OK here */
    56625668
    5663     if (VBOX_FAILURE (vrc))
     5669    if (RT_FAILURE(vrc))
    56645670    {
    56655671        LogWarningThisFunc(("Failed to create proxy device for '%s' {%RTuuid} (%Rrc)\n",
     
    56695675        {
    56705676            case VERR_VUSB_NO_PORTS:
    5671                 hrc = setError (E_FAIL,
    5672                     tr ("Failed to attach the USB device. (No available ports on the USB controller)."));
     5677                hrc = setError(E_FAIL,
     5678                    tr("Failed to attach the USB device. (No available ports on the USB controller)."));
    56735679                break;
    56745680            case VERR_VUSB_USBFS_PERMISSION:
    5675                 hrc = setError (E_FAIL,
    5676                     tr ("Not permitted to open the USB device, check usbfs options"));
     5681                hrc = setError(E_FAIL,
     5682                    tr("Not permitted to open the USB device, check usbfs options"));
    56775683                break;
    56785684            default:
    5679                 hrc = setError (E_FAIL,
    5680                     tr ("Failed to create a proxy device for the USB device.  (Error: %Rrc)"), vrc);
     5685                hrc = setError(E_FAIL,
     5686                    tr("Failed to create a proxy device for the USB device. (Error: %Rrc)"),
     5687                    vrc);
    56815688                break;
    56825689        }
     
    56875694
    56885695/**
    5689  *  USB device attach callback used by AttachUSBDevice().
    5690  *  Note that AttachUSBDevice() doesn't return until this callback is executed,
    5691  *  so we don't use AutoCaller and don't care about reference counters of
    5692  *  interface pointers passed in.
    5693  *
    5694  *  @thread EMT
    5695  *  @note Locks the console object for writing.
     5696 * USB device attach callback used by AttachUSBDevice().
     5697 * Note that AttachUSBDevice() doesn't return until this callback is executed,
     5698 * so we don't use AutoCaller and don't care about reference counters of
     5699 * interface pointers passed in.
     5700 *
     5701 * @thread EMT
     5702 * @note Locks the console object for writing.
    56965703 */
    56975704//static
    56985705DECLCALLBACK(int)
    5699 Console::usbAttachCallback (Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote, const char *aAddress, ULONG aMaskedIfs)
     5706Console::usbAttachCallback(Console *that, IUSBDevice *aHostDevice, PCRTUUID aUuid, bool aRemote, const char *aAddress, ULONG aMaskedIfs)
    57005707{
    57015708    LogFlowFuncEnter();
    5702     LogFlowFunc (("that={%p}\n", that));
     5709    LogFlowFunc(("that={%p}\n", that));
    57035710
    57045711    AssertReturn(that && aUuid, VERR_INVALID_PARAMETER);
     
    57075714    if (aRemote)
    57085715    {
    5709         RemoteUSBDevice *pRemoteUSBDevice = static_cast <RemoteUSBDevice *> (aHostDevice);
    5710         Guid guid (*aUuid);
    5711 
    5712         pvRemoteBackend = that->consoleVRDPServer ()->USBBackendRequestPointer (pRemoteUSBDevice->clientId (), &guid);
     5716        RemoteUSBDevice *pRemoteUSBDevice = static_cast<RemoteUSBDevice *>(aHostDevice);
     5717        Guid guid(*aUuid);
     5718
     5719        pvRemoteBackend = that->consoleVRDPServer()->USBBackendRequestPointer(pRemoteUSBDevice->clientId(), &guid);
    57135720        if (!pvRemoteBackend)
    5714             return VERR_INVALID_PARAMETER;  /* The clientId is invalid then. */
     5721            return VERR_INVALID_PARAMETER; /* The clientId is invalid then. */
    57155722    }
    57165723
     
    57205727    Assert(portVersion == 1 || portVersion == 2);
    57215728
    5722     int vrc = PDMR3USBCreateProxyDevice (that->mpVM, aUuid, aRemote, aAddress, pvRemoteBackend,
    5723                                          portVersion == 1 ? VUSB_STDVER_11 : VUSB_STDVER_20, aMaskedIfs);
    5724     if (VBOX_SUCCESS (vrc))
     5729    int vrc = PDMR3USBCreateProxyDevice(that->mpVM, aUuid, aRemote, aAddress, pvRemoteBackend,
     5730                                        portVersion == 1 ? VUSB_STDVER_11 : VUSB_STDVER_20, aMaskedIfs);
     5731    if (RT_SUCCESS(vrc))
    57255732    {
    57265733        /* Create a OUSBDevice and add it to the device list */
    57275734        ComObjPtr<OUSBDevice> device;
    57285735        device.createObject();
    5729         HRESULT hrc = device->init (aHostDevice);
    5730         AssertComRC (hrc);
     5736        HRESULT hrc = device->init(aHostDevice);
     5737        AssertComRC(hrc);
    57315738
    57325739        AutoWriteLock alock(that);
    5733         that->mUSBDevices.push_back (device);
    5734         LogFlowFunc (("Attached device {%RTuuid}\n", device->id().raw()));
     5740        that->mUSBDevices.push_back(device);
     5741        LogFlowFunc(("Attached device {%RTuuid}\n", device->id().raw()));
    57355742
    57365743        /* notify callbacks */
    5737         that->onUSBDeviceStateChange (device, true /* aAttached */, NULL);
    5738     }
    5739 
    5740     LogFlowFunc (("vrc=%Rrc\n", vrc));
     5744        that->onUSBDeviceStateChange(device, true /* aAttached */, NULL);
     5745    }
     5746
     5747    LogFlowFunc(("vrc=%Rrc\n", vrc));
    57415748    LogFlowFuncLeave();
    57425749    return vrc;
     
    57445751
    57455752/**
    5746  *  Sends a request to VMM to detach the given host device.  After this method
    5747  *  succeeds, the detached device will disappear from the mUSBDevices
    5748  *  collection.
    5749  *
    5750  *  @param aIt  Iterator pointing to the device to detach.
    5751  *
    5752  *  @note Synchronously calls EMT.
    5753  *  @note Must be called from under this object's lock.
     5753 * Sends a request to VMM to detach the given host device.  After this method
     5754 * succeeds, the detached device will disappear from the mUSBDevices
     5755 * collection.
     5756 *
     5757 * @param aIt  Iterator pointing to the device to detach.
     5758 *
     5759 * @note Synchronously calls EMT.
     5760 * @note Must be called from under this object's lock.
    57545761 */
    5755 HRESULT Console::detachUSBDevice (USBDeviceList::iterator &aIt)
     5762HRESULT Console::detachUSBDevice(USBDeviceList::iterator &aIt)
    57565763{
    57575764    AssertReturn(isWriteLockOnCurrentThread(), E_FAIL);
     
    57615768
    57625769    /* protect mpVM */
    5763     AutoVMCaller autoVMCaller (this);
     5770    AutoVMCaller autoVMCaller(this);
    57645771    CheckComRCReturnRC(autoVMCaller.rc());
    57655772
    57665773    /* if the device is attached, then there must at least one USB hub. */
    5767     AssertReturn(PDMR3USBHasHub (mpVM), E_FAIL);
     5774    AssertReturn(PDMR3USBHasHub(mpVM), E_FAIL);
    57685775
    57695776    LogFlowThisFunc(("Detaching USB proxy device {%RTuuid}...\n",
     
    57745781
    57755782/** @todo just do everything here and only wrap the PDMR3Usb call. That'll offload some notification stuff from the EMT thread. */
    5776     int vrc = VMR3ReqCallWait (mpVM, VMCPUID_ANY,
    5777                                (PFNRT) usbDetachCallback, 4, this, &aIt, (*aIt)->id().raw());
    5778     ComAssertRCRet (vrc, E_FAIL);
     5783    int vrc = VMR3ReqCallWait(mpVM, VMCPUID_ANY,
     5784                              (PFNRT) usbDetachCallback, 4, this, &aIt, (*aIt)->id().raw());
     5785    ComAssertRCRet(vrc, E_FAIL);
    57795786
    57805787    return S_OK;
     
    57825789
    57835790/**
    5784  *  USB device detach callback used by DetachUSBDevice().
    5785  *  Note that DetachUSBDevice() doesn't return until this callback is executed,
    5786  *  so we don't use AutoCaller and don't care about reference counters of
    5787  *  interface pointers passed in.
    5788  *
    5789  *  @thread EMT
    5790  *  @note Locks the console object for writing.
     5791 * USB device detach callback used by DetachUSBDevice().
     5792 * Note that DetachUSBDevice() doesn't return until this callback is executed,
     5793 * so we don't use AutoCaller and don't care about reference counters of
     5794 * interface pointers passed in.
     5795 *
     5796 * @thread EMT
     5797 * @note Locks the console object for writing.
    57915798 */
    57925799//static
    57935800DECLCALLBACK(int)
    5794 Console::usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid)
     5801Console::usbDetachCallback(Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid)
    57955802{
    57965803    LogFlowFuncEnter();
    5797     LogFlowFunc (("that={%p}\n", that));
     5804    LogFlowFunc(("that={%p}\n", that));
    57985805
    57995806    AssertReturn(that && aUuid, VERR_INVALID_PARAMETER);
     
    58065813    BOOL fRemote = FALSE;
    58075814
    5808     HRESULT hrc2 = (**aIt)->COMGETTER (Remote) (&fRemote);
    5809     ComAssertComRC (hrc2);
     5815    HRESULT hrc2 = (**aIt)->COMGETTER(Remote)(&fRemote);
     5816    ComAssertComRC(hrc2);
    58105817
    58115818    if (fRemote)
    58125819    {
    5813         Guid guid (*aUuid);
    5814         that->consoleVRDPServer ()->USBBackendReleasePointer (&guid);
    5815     }
    5816 
    5817     int vrc = PDMR3USBDetachDevice (that->mpVM, aUuid);
    5818 
    5819     if (VBOX_SUCCESS (vrc))
     5820        Guid guid(*aUuid);
     5821        that->consoleVRDPServer()->USBBackendReleasePointer(&guid);
     5822    }
     5823
     5824    int vrc = PDMR3USBDetachDevice(that->mpVM, aUuid);
     5825
     5826    if (RT_SUCCESS(vrc))
    58205827    {
    58215828        AutoWriteLock alock(that);
    58225829
    58235830        /* Remove the device from the collection */
    5824         that->mUSBDevices.erase (*aIt);
    5825         LogFlowFunc (("Detached device {%RTuuid}\n", device->id().raw()));
     5831        that->mUSBDevices.erase(*aIt);
     5832        LogFlowFunc(("Detached device {%RTuuid}\n", device->id().raw()));
    58265833
    58275834        /* notify callbacks */
    5828         that->onUSBDeviceStateChange (device, false /* aAttached */, NULL);
    5829     }
    5830 
    5831     LogFlowFunc (("vrc=%Rrc\n", vrc));
     5835        that->onUSBDeviceStateChange(device, false /* aAttached */, NULL);
     5836    }
     5837
     5838    LogFlowFunc(("vrc=%Rrc\n", vrc));
    58325839    LogFlowFuncLeave();
    58335840    return vrc;
     
    58385845
    58395846/**
    5840  *  Helper function to handle host interface device creation and attachment.
    5841  *
    5842  *  @param   networkAdapter the network adapter which attachment should be reset
    5843  *  @return  COM status code
    5844  *
    5845  *  @note The caller must lock this object for writing.
    5846  *
    5847  *  @todo Move this back into the driver!
     5847 * Helper function to handle host interface device creation and attachment.
     5848 *
     5849 * @param   networkAdapter the network adapter which attachment should be reset
     5850 * @return  COM status code
     5851 *
     5852 * @note The caller must lock this object for writing.
     5853 *
     5854 * @todo Move this back into the driver!
    58485855 */
    58495856HRESULT Console::attachToTapInterface(INetworkAdapter *networkAdapter)
     
    58725879    int rcVBox = RTFileOpen(&maTapFD[slot], "/dev/net/tun",
    58735880                            RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE | RTFILE_O_INHERIT);
    5874     if (VBOX_SUCCESS(rcVBox))
     5881    if (RT_SUCCESS(rcVBox))
    58755882    {
    58765883        /*
     
    58835890        rc = networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
    58845891        if (FAILED(rc))
    5885             tapDeviceName.setNull();  /* Is this necessary? */
     5892            tapDeviceName.setNull(); /* Is this necessary? */
    58865893        if (tapDeviceName.isEmpty())
    58875894        {
    58885895            LogRel(("No TAP device name was supplied.\n"));
    5889             rc = setError(E_FAIL, tr ("No TAP device name was supplied for the host networking interface"));
     5896            rc = setError(E_FAIL, tr("No TAP device name was supplied for the host networking interface"));
    58905897        }
    58915898
     
    59035910            {
    59045911                LogRel(("Failed to open the host network interface %ls\n", tapDeviceName.raw()));
    5905                 rc = setError(E_FAIL, tr ("Failed to open the host network interface %ls"),
    5906                               tapDeviceName.raw());
     5912                rc = setError(E_FAIL,
     5913                    tr("Failed to open the host network interface %ls"),
     5914                    tapDeviceName.raw());
    59075915            }
    59085916        }
     
    59295937                LogRel(("Configuration error: Failed to configure /dev/net/tun non blocking. Error: %s\n", strerror(iErr)));
    59305938                rcVBox = VERR_HOSTIF_BLOCKING;
    5931                 rc = setError(E_FAIL, tr ("could not set up the host networking device for non blocking access: %s"),
    5932                                           strerror(errno));
     5939                rc = setError(E_FAIL,
     5940                    tr("could not set up the host networking device for non blocking access: %s"),
     5941                    strerror(errno));
    59335942            }
    59345943        }
     
    59445953                break;
    59455954            default:
    5946                 rc = setError(E_FAIL, tr ("Could not set up the host networking device: %Rrc"), rcVBox);
     5955                rc = setError(E_FAIL,
     5956                    tr("Could not set up the host networking device: %Rrc"),
     5957                    rcVBox);
    59475958                break;
    59485959        }
     
    59575968    rc = networkAdapter->COMGETTER(HostInterface)(tapDeviceName.asOutParam());
    59585969    if (FAILED(rc))
    5959         tapDeviceName.setNull();  /* Is this necessary? */
     5970        tapDeviceName.setNull(); /* Is this necessary? */
    59605971    if (tapDeviceName.isEmpty())
    59615972    {
    59625973        LogRel(("No TAP device name was supplied.\n"));
    5963         rc = setError(E_FAIL, tr ("No TAP device name was supplied for the host networking interface"));
     5974        rc = setError(E_FAIL, tr("No TAP device name was supplied for the host networking interface"));
    59645975    }
    59655976    char szTapdev[1024] = "/dev/";
     
    59845995                break;
    59855996            default:
    5986                 rc = setError(E_FAIL, tr ("Failed to open the host network interface %ls"),
    5987                       tapDeviceName.raw());
     5997                rc = setError(E_FAIL,
     5998                    tr("Failed to open the host network interface %ls"),
     5999                    tapDeviceName.raw());
    59886000                break;
    59896001        }
     
    59936005# endif
    59946006    /* in case of failure, cleanup. */
    5995     if (VBOX_FAILURE(rcVBox) && SUCCEEDED(rc))
     6007    if (RT_FAILURE(rcVBox) && SUCCEEDED(rc))
    59966008    {
    59976009        LogRel(("General failure attaching to host interface\n"));
    5998         rc = setError(E_FAIL, tr ("General failure attaching to host interface"));
     6010        rc = setError(E_FAIL,
     6011            tr("General failure attaching to host interface"));
    59996012    }
    60006013    LogFlowThisFunc(("rc=%d\n", rc));
     
    60046017
    60056018/**
    6006  *  Helper function to handle detachment from a host interface
    6007  *
    6008  *  @param   networkAdapter the network adapter which attachment should be reset
    6009  *  @return  COM status code
    6010  *
    6011  *  @note The caller must lock this object for writing.
    6012  *
    6013  *  @todo Move this back into the driver!
     6019 * Helper function to handle detachment from a host interface
     6020 *
     6021 * @param   networkAdapter the network adapter which attachment should be reset
     6022 * @return  COM status code
     6023 *
     6024 * @note The caller must lock this object for writing.
     6025 *
     6026 * @todo Move this back into the driver!
    60146027 */
    60156028HRESULT Console::detachFromTapInterface(INetworkAdapter *networkAdapter)
     
    60436056        {
    60446057            /* If the name is empty, this is a dynamic TAP device, so close it now,
    6045                so that the termination script can remove the interface.  Otherwise we still
     6058               so that the termination script can remove the interface. Otherwise we still
    60466059               need the FD to pass to the termination script. */
    60476060            isStatic = false;
     
    60686081
    60696082/**
    6070  *  Called at power down to terminate host interface networking.
    6071  *
    6072  *  @note The caller must lock this object for writing.
     6083 * Called at power down to terminate host interface networking.
     6084 *
     6085 * @note The caller must lock this object for writing.
    60736086 */
    60746087HRESULT Console::powerDownHostInterfaces()
     
    60876100        ComPtr<INetworkAdapter> networkAdapter;
    60886101        rc = mMachine->GetNetworkAdapter(slot, networkAdapter.asOutParam());
    6089         CheckComRCBreakRC (rc);
     6102        CheckComRCBreakRC(rc);
    60906103
    60916104        BOOL enabled = FALSE;
    6092         networkAdapter->COMGETTER(Enabled) (&enabled);
     6105        networkAdapter->COMGETTER(Enabled)(&enabled);
    60936106        if (!enabled)
    60946107            continue;
     
    61116124
    61126125/**
    6113  *  Process callback handler for VMR3Load and VMR3Save.
    6114  *
    6115  *  @param   pVM         The VM handle.
    6116  *  @param   uPercent    Completetion precentage (0-100).
    6117  *  @param   pvUser      Pointer to the VMProgressTask structure.
    6118  *  @return  VINF_SUCCESS.
     6126 * Process callback handler for VMR3Load and VMR3Save.
     6127 *
     6128 * @param   pVM         The VM handle.
     6129 * @param   uPercent    Completetion precentage (0-100).
     6130 * @param   pvUser      Pointer to the VMProgressTask structure.
     6131 * @return  VINF_SUCCESS.
    61196132 */
    61206133/*static*/
    61216134DECLCALLBACK(int) Console::stateProgressCallback(PVM pVM, unsigned uPercent, void *pvUser)
    61226135{
    6123     VMProgressTask *task = static_cast<VMProgressTask *> (pvUser);
     6136    VMProgressTask *task = static_cast<VMProgressTask *>(pvUser);
    61246137    AssertReturn(task, VERR_INVALID_PARAMETER);
    61256138
     
    61466159 *       safe.
    61476160 */
    6148 /* static */ DECLCALLBACK (void)
    6149 Console::setVMErrorCallback (PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
    6150                              const char *pszFormat, va_list args)
    6151 {
    6152     VMProgressTask *task = static_cast <VMProgressTask *> (pvUser);
    6153     AssertReturnVoid (task);
     6161/* static */ DECLCALLBACK(void)
     6162Console::setVMErrorCallback(PVM pVM, void *pvUser, int rc, RT_SRC_POS_DECL,
     6163                            const char *pszFormat, va_list args)
     6164{
     6165    VMProgressTask *task = static_cast<VMProgressTask *>(pvUser);
     6166    AssertReturnVoid(task);
    61546167
    61556168    /* we ignore RT_SRC_POS_DECL arguments to avoid confusion of end-users */
    61566169    va_list va2;
    6157     va_copy (va2, args); /* Have to make a copy here or GCC will break. */
     6170    va_copy(va2, args); /* Have to make a copy here or GCC will break. */
    61586171
    61596172    /* append to the existing error message if any */
    61606173    if (task->mErrorMsg.length())
    6161         task->mErrorMsg = Utf8StrFmt ("%s.\n%N (%Rrc)", task->mErrorMsg.raw(),
    6162                                       pszFormat, &va2, rc, rc);
     6174        task->mErrorMsg = Utf8StrFmt("%s.\n%N (%Rrc)", task->mErrorMsg.raw(),
     6175                                     pszFormat, &va2, rc, rc);
    61636176    else
    6164         task->mErrorMsg = Utf8StrFmt ("%N (%Rrc)",
    6165                                       pszFormat, &va2, rc, rc);
     6177        task->mErrorMsg = Utf8StrFmt("%N (%Rrc)",
     6178                                     pszFormat, &va2, rc, rc);
    61666179
    61676180    va_end (va2);
     
    61816194 */
    61826195/* static */ DECLCALLBACK(void)
    6183 Console::setVMRuntimeErrorCallback (PVM pVM, void *pvUser, uint32_t fFlags,
    6184                                     const char *pszErrorId,
    6185                                     const char *pszFormat, va_list va)
     6196Console::setVMRuntimeErrorCallback(PVM pVM, void *pvUser, uint32_t fFlags,
     6197                                   const char *pszErrorId,
     6198                                   const char *pszFormat, va_list va)
    61866199{
    61876200    bool const fFatal = !!(fFlags & VMSETRTERR_FLAGS_FATAL);
    61886201    LogFlowFuncEnter();
    61896202
    6190     Console *that = static_cast <Console *> (pvUser);
    6191     AssertReturnVoid (that);
    6192 
    6193     Utf8Str message = Utf8StrFmtVA (pszFormat, va);
    6194 
    6195     LogRel (("Console: VM runtime error: fatal=%RTbool, "
    6196              "errorID=%s message=\"%s\"\n",
     6203    Console *that = static_cast<Console *>(pvUser);
     6204    AssertReturnVoid(that);
     6205
     6206    Utf8Str message = Utf8StrFmtVA(pszFormat, va);
     6207
     6208    LogRel(("Console: VM runtime error: fatal=%RTbool, errorID=%s message=\"%s\"\n",
    61976209             fFatal, pszErrorId, message.raw()));
    61986210
    6199     that->onRuntimeError (BOOL (fFatal), Bstr (pszErrorId), Bstr (message));
     6211    that->onRuntimeError(BOOL(fFatal), Bstr(pszErrorId), Bstr(message));
    62006212
    62016213    LogFlowFuncLeave();
     
    62036215
    62046216/**
    6205  *  Captures USB devices that match filters of the VM.
    6206  *  Called at VM startup.
    6207  *
    6208  *  @param   pVM     The VM handle.
    6209  *
    6210  *  @note The caller must lock this object for writing.
     6217 * Captures USB devices that match filters of the VM.
     6218 * Called at VM startup.
     6219 *
     6220 * @param   pVM     The VM handle.
     6221 *
     6222 * @note The caller must lock this object for writing.
    62116223 */
    6212 HRESULT Console::captureUSBDevices (PVM pVM)
     6224HRESULT Console::captureUSBDevices(PVM pVM)
    62136225{
    62146226    LogFlowThisFunc(("\n"));
    62156227
    62166228    /* sanity check */
    6217     ComAssertRet (isWriteLockOnCurrentThread(), E_FAIL);
     6229    ComAssertRet(isWriteLockOnCurrentThread(), E_FAIL);
    62186230
    62196231    /* If the machine has an USB controller, ask the USB proxy service to
    62206232     * capture devices */
    62216233    PPDMIBASE pBase;
    6222     int vrc = PDMR3QueryLun (pVM, "usb-ohci", 0, 0, &pBase);
    6223     if (VBOX_SUCCESS (vrc))
     6234    int vrc = PDMR3QueryLun(pVM, "usb-ohci", 0, 0, &pBase);
     6235    if (RT_SUCCESS(vrc))
    62246236    {
    62256237        /* leave the lock before calling Host in VBoxSVC since Host may call
     
    62306242
    62316243        HRESULT hrc = mControl->AutoCaptureUSBDevices();
    6232         ComAssertComRCRetRC (hrc);
     6244        ComAssertComRCRetRC(hrc);
    62336245    }
    62346246    else if (   vrc == VERR_PDM_DEVICE_NOT_FOUND
     
    62366248        vrc = VINF_SUCCESS;
    62376249    else
    6238         AssertRC (vrc);
    6239 
    6240     return VBOX_SUCCESS (vrc) ? S_OK : E_FAIL;
     6250        AssertRC(vrc);
     6251
     6252    return RT_SUCCESS(vrc) ? S_OK : E_FAIL;
    62416253}
    62426254
    62436255
    62446256/**
    6245  *  Detach all USB device which are attached to the VM for the
    6246  *  purpose of clean up and such like.
    6247  *
    6248  *  @note The caller must lock this object for writing.
     6257 * Detach all USB device which are attached to the VM for the
     6258 * purpose of clean up and such like.
     6259 *
     6260 * @note The caller must lock this object for writing.
    62496261 */
    6250 void Console::detachAllUSBDevices (bool aDone)
     6262void Console::detachAllUSBDevices(bool aDone)
    62516263{
    62526264    LogFlowThisFunc(("aDone=%RTbool\n", aDone));
    62536265
    62546266    /* sanity check */
    6255     AssertReturnVoid (isWriteLockOnCurrentThread());
     6267    AssertReturnVoid(isWriteLockOnCurrentThread());
    62566268
    62576269    mUSBDevices.clear();
     
    62636275    alock.leave();
    62646276
    6265     mControl->DetachAllUSBDevices (aDone);
     6277    mControl->DetachAllUSBDevices(aDone);
    62666278}
    62676279
    62686280/**
    6269  *  @note Locks this object for writing.
     6281 * @note Locks this object for writing.
    62706282 */
    6271 void Console::processRemoteUSBDevices (uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList)
     6283void Console::processRemoteUSBDevices(uint32_t u32ClientId, VRDPUSBDEVICEDESC *pDevList, uint32_t cbDevList)
    62726284{
    62736285    LogFlowThisFuncEnter();
     
    62786290    {
    62796291        /* Console has been already uninitialized, deny request */
    6280         AssertMsgFailed (("Temporary assertion to prove that it happens, "
    6281                           "please report to dmik\n"));
     6292        AssertMsgFailed(("Console is already uninitialized\n"));
    62826293        LogFlowThisFunc(("Console is already uninitialized\n"));
    62836294        LogFlowThisFuncLeave();
     
    62936304    while (it != mRemoteUSBDevices.end())
    62946305    {
    6295         (*it)->dirty (true);
     6306        (*it)->dirty(true);
    62966307        ++ it;
    62976308    }
     
    63176328        while (it != mRemoteUSBDevices.end())
    63186329        {
    6319             if ((*it)->devId () == e->id
    6320                 && (*it)->clientId () == u32ClientId)
     6330            if ((*it)->devId() == e->id
     6331                && (*it)->clientId() == u32ClientId)
    63216332            {
    63226333               /* The device is already in the list. */
    6323                (*it)->dirty (false);
     6334               (*it)->dirty(false);
    63246335               fNewDevice = false;
    63256336               break;
     
    63326343        {
    63336344            LogRel(("Remote USB: ++++ Vendor %04X. Product %04X. Name = [%s].\n",
    6334                         e->idVendor, e->idProduct, e->oProduct? (char *)e + e->oProduct: ""
    6335                     ));
     6345                    e->idVendor, e->idProduct, e->oProduct? (char *)e + e->oProduct: ""));
    63366346
    63376347            /* Create the device object and add the new device to list. */
    63386348            ComObjPtr<RemoteUSBDevice> device;
    63396349            device.createObject();
    6340             device->init (u32ClientId, e);
    6341 
    6342             mRemoteUSBDevices.push_back (device);
     6350            device->init(u32ClientId, e);
     6351
     6352            mRemoteUSBDevices.push_back(device);
    63436353
    63446354            /* Check if the device is ok for current USB filters. */
     
    63486358            HRESULT hrc = mControl->RunUSBDeviceFilters(device, &fMatched, &fMaskedIfs);
    63496359
    6350             AssertComRC (hrc);
     6360            AssertComRC(hrc);
    63516361
    63526362            LogFlowThisFunc(("USB filters return %d %#x\n", fMatched, fMaskedIfs));
     
    63546364            if (fMatched)
    63556365            {
    6356                 hrc = onUSBDeviceAttach (device, NULL, fMaskedIfs);
     6366                hrc = onUSBDeviceAttach(device, NULL, fMaskedIfs);
    63576367
    63586368                /// @todo (r=dmik) warning reporting subsystem
     
    63616371                {
    63626372                    LogFlowThisFunc(("Device attached\n"));
    6363                     device->captured (true);
     6373                    device->captured(true);
    63646374                }
    63656375            }
     
    63886398        while (it != mRemoteUSBDevices.end())
    63896399        {
    6390             if ((*it)->dirty ())
     6400            if ((*it)->dirty())
    63916401            {
    63926402                device = *it;
     
    64036413
    64046414        USHORT vendorId = 0;
    6405         device->COMGETTER(VendorId) (&vendorId);
     6415        device->COMGETTER(VendorId)(&vendorId);
    64066416
    64076417        USHORT productId = 0;
    6408         device->COMGETTER(ProductId) (&productId);
     6418        device->COMGETTER(ProductId)(&productId);
    64096419
    64106420        Bstr product;
    6411         device->COMGETTER(Product) (product.asOutParam());
     6421        device->COMGETTER(Product)(product.asOutParam());
    64126422
    64136423        LogRel(("Remote USB: ---- Vendor %04X. Product %04X. Name = [%ls].\n",
    6414                     vendorId, productId, product.raw ()
    6415                 ));
     6424                vendorId, productId, product.raw()));
    64166425
    64176426        /* Detach the device from VM. */
    6418         if (device->captured ())
     6427        if (device->captured())
    64196428        {
    64206429            Bstr uuid;
    6421             device->COMGETTER (Id) (uuid.asOutParam());
    6422             onUSBDeviceDetach (uuid, NULL);
     6430            device->COMGETTER(Id)(uuid.asOutParam());
     6431            onUSBDeviceDetach(uuid, NULL);
    64236432        }
    64246433
    64256434        /* And remove it from the list. */
    6426         mRemoteUSBDevices.erase (it);
     6435        mRemoteUSBDevices.erase(it);
    64276436    }
    64286437
     
    64316440
    64326441/**
    6433  *  Thread function which starts the VM (also from saved state) and
    6434  *  track progress.
    6435  *
    6436  *  @param   Thread      The thread id.
    6437  *  @param   pvUser      Pointer to a VMPowerUpTask structure.
    6438  *  @return  VINF_SUCCESS (ignored).
    6439  *
    6440  *  @note Locks the Console object for writing.
     6442 * Thread function which starts the VM (also from saved state) and
     6443 * track progress.
     6444 *
     6445 * @param   Thread      The thread id.
     6446 * @param   pvUser      Pointer to a VMPowerUpTask structure.
     6447 * @return  VINF_SUCCESS (ignored).
     6448 *
     6449 * @note Locks the Console object for writing.
    64416450 */
    64426451/*static*/
    6443 DECLCALLBACK (int) Console::powerUpThread (RTTHREAD Thread, void *pvUser)
     6452DECLCALLBACK(int) Console::powerUpThread(RTTHREAD Thread, void *pvUser)
    64446453{
    64456454    LogFlowFuncEnter();
    64466455
    6447     std::auto_ptr <VMPowerUpTask> task (static_cast <VMPowerUpTask *> (pvUser));
     6456    std::auto_ptr<VMPowerUpTask> task(static_cast<VMPowerUpTask *>(pvUser));
    64486457    AssertReturn(task.get(), VERR_INVALID_PARAMETER);
    64496458
     
    64546463    {
    64556464        /* initialize COM */
    6456         HRESULT hrc = CoInitializeEx (NULL,
    6457                                       COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
    6458                                       COINIT_SPEED_OVER_MEMORY);
    6459         LogFlowFunc (("CoInitializeEx()=%08X\n", hrc));
     6465        HRESULT hrc = CoInitializeEx(NULL,
     6466                                     COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE |
     6467                                     COINIT_SPEED_OVER_MEMORY);
     6468        LogFlowFunc(("CoInitializeEx()=%08X\n", hrc));
    64606469    }
    64616470#endif
     
    64796488
    64806489    /* sanity */
    6481     Assert (console->mpVM == NULL);
     6490    Assert(console->mpVM == NULL);
    64826491
    64836492    try
     
    64896498             it != task->hardDiskProgresses.end(); ++ it)
    64906499        {
    6491             HRESULT rc2 = (*it)->WaitForCompletion (-1);
    6492             AssertComRC (rc2);
     6500            HRESULT rc2 = (*it)->WaitForCompletion(-1);
     6501            AssertComRC(rc2);
    64936502        }
    64946503
     
    64976506         * by SessionMachine::setMachineState() when the VM is powered down. */
    64986507        rc = console->mControl->LockMedia();
    6499         CheckComRCThrowRC (rc);
     6508        CheckComRCThrowRC(rc);
    65006509
    65016510#ifdef VBOX_WITH_VRDP
     
    65056514         */
    65066515        ConsoleVRDPServer *server = console->consoleVRDPServer();
    6507         Assert (server);
    6508 
    6509         /// @todo (dmik)
    6510         //      does VRDP server call Console from the other thread?
    6511         //      Not sure, so leave the lock just in case
     6516        Assert(server);
     6517
     6518        /* Does VRDP server call Console from the other thread?
     6519         * Not sure (and can change), so leave the lock just in case.
     6520         */
    65126521        alock.leave();
    65136522        vrc = server->Launch();
     
    65186527            Utf8Str errMsg;
    65196528            ULONG port = 0;
    6520             console->mVRDPServer->COMGETTER(Port) (&port);
    6521             errMsg = Utf8StrFmt (tr ("VRDP server port %d is already in use"),
    6522                                  port);
    6523             LogRel (("Warning: failed to launch VRDP server (%Rrc): '%s'\n",
    6524                      vrc, errMsg.raw()));
    6525         }
    6526         else if (RT_FAILURE (vrc))
     6529            console->mVRDPServer->COMGETTER(Port)(&port);
     6530            errMsg = Utf8StrFmt(tr("VRDP server port %d is already in use"),
     6531                                port);
     6532            LogRel(("Warning: failed to launch VRDP server (%Rrc): '%s'\n",
     6533                    vrc, errMsg.raw()));
     6534        }
     6535        else if (RT_FAILURE(vrc))
    65276536        {
    65286537            Utf8Str errMsg;
     
    65316540                case VERR_FILE_NOT_FOUND:
    65326541                {
    6533                     errMsg = Utf8StrFmt (tr ("Could not load the VRDP library"));
     6542                    errMsg = Utf8StrFmt(tr("Could not load the VRDP library"));
    65346543                    break;
    65356544                }
    65366545                default:
    6537                     errMsg = Utf8StrFmt (tr ("Failed to launch VRDP server (%Rrc)"),
    6538                                          vrc);
     6546                    errMsg = Utf8StrFmt(tr("Failed to launch VRDP server (%Rrc)"),
     6547                                        vrc);
    65396548            }
    6540             LogRel (("Failed to launch VRDP server (%Rrc), error message: '%s'\n",
     6549            LogRel(("Failed to launch VRDP server (%Rrc), error message: '%s'\n",
    65416550                     vrc, errMsg.raw()));
    65426551            throw setError(E_FAIL, errMsg.c_str());
     
    65546563        PVM pVM;
    65556564        /*
    6556          *  leave the lock since EMT will call Console. It's safe because
    6557          *  mMachineState is either Starting or Restoring state here.
     6565         * leave the lock since EMT will call Console. It's safe because
     6566         * mMachineState is either Starting or Restoring state here.
    65586567         */
    65596568        alock.leave();
    65606569
    6561         vrc = VMR3Create (cCpus, task->mSetVMErrorCallback, task.get(),
    6562                           task->mConfigConstructor, static_cast <Console *> (console),
    6563                           &pVM);
     6570        vrc = VMR3Create(cCpus, task->mSetVMErrorCallback, task.get(),
     6571                         task->mConfigConstructor, static_cast<Console *>(console),
     6572                         &pVM);
    65646573
    65656574        alock.enter();
     
    65676576#ifdef VBOX_WITH_VRDP
    65686577        /* Enable client connections to the server. */
    6569         console->consoleVRDPServer()->EnableConnections ();
     6578        console->consoleVRDPServer()->EnableConnections();
    65706579#endif /* VBOX_WITH_VRDP */
    65716580
    6572         if (VBOX_SUCCESS (vrc))
     6581        if (RT_SUCCESS(vrc))
    65736582        {
    65746583            do
     
    65846593                AssertRCBreak(vrc);
    65856594
    6586                 vrc = static_cast <Console *>(console)->getDisplay()->registerSSM(pVM);
    6587                 AssertRC (vrc);
    6588                 if (VBOX_FAILURE (vrc))
     6595                vrc = static_cast<Console *>(console)->getDisplay()->registerSSM(pVM);
     6596                AssertRC(vrc);
     6597                if (RT_FAILURE(vrc))
    65896598                    break;
    65906599
     
    66036612                if (console->getVMMDev()->isShFlActive())
    66046613                {
    6605                     /// @todo (dmik)
    6606                     //      does the code below call Console from the other thread?
    6607                     //      Not sure, so leave the lock just in case
     6614                    /* Does the code below call Console from the other thread?
     6615                     * Not sure, so leave the lock just in case. */
    66086616                    alock.leave();
    66096617
     
    66136621                         ++ it)
    66146622                    {
    6615                         rc = console->createSharedFolder ((*it).first, (*it).second);
    6616                         CheckComRCBreakRC (rc);
     6623                        rc = console->createSharedFolder((*it).first, (*it).second);
     6624                        CheckComRCBreakRC(rc);
    66176625                    }
    66186626
     
    66206628                    alock.enter();
    66216629
    6622                     CheckComRCBreakRC (rc);
     6630                    CheckComRCBreakRC(rc);
    66236631                }
    66246632
     
    66266634                 * Capture USB devices.
    66276635                 */
    6628                 rc = console->captureUSBDevices (pVM);
    6629                 CheckComRCBreakRC (rc);
     6636                rc = console->captureUSBDevices(pVM);
     6637                CheckComRCBreakRC(rc);
    66306638
    66316639                /* leave the lock before a lengthy operation */
     
    66356643                if (task->mSavedStateFile.length())
    66366644                {
    6637                     LogFlowFunc (("Restoring saved state from '%s'...\n",
    6638                                   task->mSavedStateFile.raw()));
     6645                    LogFlowFunc(("Restoring saved state from '%s'...\n",
     6646                                 task->mSavedStateFile.raw()));
    66396647
    66406648                    vrc = VMR3Load(pVM,
     
    66436651                                   static_cast<VMProgressTask*>(task.get()));
    66446652
    6645                     if (VBOX_SUCCESS (vrc))
     6653                    if (RT_SUCCESS(vrc))
    66466654                    {
    66476655                        if (task->mStartPaused)
    66486656                            /* done */
    6649                             console->setMachineState (MachineState_Paused);
     6657                            console->setMachineState(MachineState_Paused);
    66506658                        else
    66516659                        {
    66526660                            /* Start/Resume the VM execution */
    6653                             vrc = VMR3Resume (pVM);
    6654                             AssertRC (vrc);
     6661                            vrc = VMR3Resume(pVM);
     6662                            AssertRC(vrc);
    66556663                        }
    66566664                    }
    66576665
    66586666                    /* Power off in case we failed loading or resuming the VM */
    6659                     if (VBOX_FAILURE (vrc))
     6667                    if (RT_FAILURE(vrc))
    66606668                    {
    6661                         int vrc2 = VMR3PowerOff (pVM);
    6662                         AssertRC (vrc2);
     6669                        int vrc2 = VMR3PowerOff(pVM);
     6670                        AssertRC(vrc2);
    66636671                    }
    66646672                }
    66656673                else if (task->mStartPaused)
    66666674                    /* done */
    6667                     console->setMachineState (MachineState_Paused);
     6675                    console->setMachineState(MachineState_Paused);
    66686676                else
    66696677                {
    66706678                    /* Power on the VM (i.e. start executing) */
    66716679                    vrc = VMR3PowerOn(pVM);
    6672                     AssertRC (vrc);
     6680                    AssertRC(vrc);
    66736681                }
    66746682
     
    66796687
    66806688            /* On failure, destroy the VM */
    6681             if (FAILED (rc) || VBOX_FAILURE (vrc))
     6689            if (FAILED(rc) || RT_FAILURE(vrc))
    66826690            {
    66836691                /* preserve existing error info */
     
    66876695                 * cleanup (VRDP, USB devices) */
    66886696                HRESULT rc2 = console->powerDown();
    6689                 AssertComRC (rc2);
     6697                AssertComRC(rc2);
    66906698            }
    66916699            else
     
    67106718        }
    67116719
    6712         if (SUCCEEDED(rc) && VBOX_FAILURE (vrc))
     6720        if (SUCCEEDED(rc) && RT_FAILURE(vrc))
    67136721        {
    67146722            /* If VMR3Create() or one of the other calls in this function fail,
     
    67246732                 * appropriate error message themselves.
    67256733                 */
    6726                 AssertMsgFailed (("Missing error message during powerup for "
    6727                                   "status code %Rrc\n", vrc));
    6728                 task->mErrorMsg = Utf8StrFmt (
    6729                     tr ("Failed to start VM execution (%Rrc)"), vrc);
     6734                AssertMsgFailed(("Missing error message during powerup for status code %Rrc\n", vrc));
     6735                task->mErrorMsg = Utf8StrFmt(tr("Failed to start VM execution (%Rrc)"),
     6736                                             vrc);
    67306737            }
    67316738
     
    67536760        ErrorInfoKeeper eik;
    67546761
    6755         Assert (console->mpVM == NULL);
    6756         vmstateChangeCallback (NULL, VMSTATE_TERMINATED, VMSTATE_CREATING,
    6757                                console);
     6762        Assert(console->mpVM == NULL);
     6763        vmstateChangeCallback(NULL, VMSTATE_TERMINATED, VMSTATE_CREATING,
     6764                              console);
    67586765    }
    67596766
     
    67696776    {
    67706777        /* Notify the progress object of the success */
    6771         task->mProgress->notifyComplete (S_OK);
     6778        task->mProgress->notifyComplete(S_OK);
    67726779    }
    67736780    else
    67746781    {
    67756782        /* The progress object will fetch the current error info */
    6776         task->mProgress->notifyComplete (rc);
    6777 
    6778         LogRel (("Power up failed (vrc=%Rrc, rc=%Rhrc (%#08X))\n", vrc, rc, rc));
     6783        task->mProgress->notifyComplete(rc);
     6784
     6785        LogRel(("Power up failed (vrc=%Rrc, rc=%Rhrc (%#08X))\n", vrc, rc, rc));
    67796786    }
    67806787
     
    67916798
    67926799/**
    6793  *  Reconfigures a VDI.
    6794  *
    6795  *  @param   pVM           The VM handle.
    6796  *  @param   lInstance     The instance of the controller.
    6797  *  @param   enmController The type of the controller.
    6798  *  @param   hda           The harddisk attachment.
    6799  *  @param   phrc          Where to store com error - only valid if we return VERR_GENERAL_FAILURE.
    6800  *  @return  VBox status code.
     6800 * Reconfigures a VDI.
     6801 *
     6802 * @param   pVM           The VM handle.
     6803 * @param   lInstance     The instance of the controller.
     6804 * @param   enmController The type of the controller.
     6805 * @param   hda           The harddisk attachment.
     6806 * @param   phrc          Where to store com error - only valid if we return VERR_GENERAL_FAILURE.
     6807 * @return  VBox status code.
    68016808 */
    68026809static DECLCALLBACK(int) reconfigureHardDisks(PVM pVM, ULONG lInstance,
     
    68056812                                              HRESULT *phrc)
    68066813{
    6807     LogFlowFunc (("pVM=%p hda=%p phrc=%p\n", pVM, hda, phrc));
     6814    LogFlowFunc(("pVM=%p hda=%p phrc=%p\n", pVM, hda, phrc));
    68086815
    68096816    int             rc;
     
    68116818    Bstr            bstr;
    68126819    *phrc = S_OK;
    6813 #define RC_CHECK()  do { if (VBOX_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); return rc; } } while (0)
     6820#define RC_CHECK() do { if (RT_FAILURE(rc)) { AssertMsgFailed(("rc=%Rrc\n", rc)); return rc; } } while (0)
    68146821#define H() do { if (FAILED(hrc)) { AssertMsgFailed(("hrc=%Rhrc (%#x)\n", hrc, hrc)); *phrc = hrc; return VERR_GENERAL_FAILURE; } } while (0)
    68156822
     
    69476954     */
    69486955    hrc = hardDisk->COMGETTER(Location)(bstr.asOutParam());                     H();
    6949     LogFlowFunc (("LUN#%d: leaf location '%ls'\n", iLUN, bstr.raw()));
     6956    LogFlowFunc(("LUN#%d: leaf location '%ls'\n", iLUN, bstr.raw()));
    69506957    rc = CFGMR3InsertString(pCfg, "Path", Utf8Str(bstr).c_str());                       RC_CHECK();
    69516958    hrc = hardDisk->COMGETTER(Format)(bstr.asOutParam());                       H();
    6952     LogFlowFunc (("LUN#%d: leaf format '%ls'\n", iLUN, bstr.raw()));
     6959    LogFlowFunc(("LUN#%d: leaf format '%ls'\n", iLUN, bstr.raw()));
    69536960    rc = CFGMR3InsertString(pCfg, "Format", Utf8Str(bstr).c_str());                     RC_CHECK();
    69546961
     
    69576964    SafeArray<BSTR> names;
    69586965    SafeArray<BSTR> values;
    6959     hrc = hardDisk->GetProperties (NULL,
    6960                                    ComSafeArrayAsOutParam (names),
    6961                                    ComSafeArrayAsOutParam (values));    H();
     6966    hrc = hardDisk->GetProperties(NULL,
     6967                                  ComSafeArrayAsOutParam(names),
     6968                                  ComSafeArrayAsOutParam(values));      H();
    69626969
    69636970    if (names.size() != 0)
    69646971    {
    69656972        PCFGMNODE pVDC;
    6966         rc = CFGMR3InsertNode (pCfg, "VDConfig", &pVDC);                RC_CHECK();
     6973        rc = CFGMR3InsertNode(pCfg, "VDConfig", &pVDC);                 RC_CHECK();
    69676974        for (size_t i = 0; i < names.size(); ++ i)
    69686975        {
    6969             if (values [i])
     6976            if (values[i])
    69706977            {
    69716978                Utf8Str name = names[i];
     
    69987005        SafeArray<BSTR> names;
    69997006        SafeArray<BSTR> values;
    7000         hrc = hardDisk->GetProperties (NULL,
    7001                                        ComSafeArrayAsOutParam (names),
    7002                                        ComSafeArrayAsOutParam (values));H();
     7007        hrc = hardDisk->GetProperties(NULL,
     7008                                      ComSafeArrayAsOutParam(names),
     7009                                      ComSafeArrayAsOutParam(values));  H();
    70037010
    70047011        if (names.size() != 0)
    70057012        {
    70067013            PCFGMNODE pVDC;
    7007             rc = CFGMR3InsertNode (pCur, "VDConfig", &pVDC);            RC_CHECK();
     7014            rc = CFGMR3InsertNode(pCur, "VDConfig", &pVDC);             RC_CHECK();
    70087015            for (size_t i = 0; i < names.size(); ++ i)
    70097016            {
    7010                 if (values [i])
     7017                if (values[i])
    70117018                {
    7012                     Utf8Str name = names [i];
    7013                     Utf8Str value = values [i];
    7014                     rc = CFGMR3InsertString (pVDC, name.c_str(), value.c_str());
     7019                    Utf8Str name = names[i];
     7020                    Utf8Str value = values[i];
     7021                    rc = CFGMR3InsertString(pVDC, name.c_str(), value.c_str());
    70157022                    if (    !(name.compare("HostIPStack"))
    70167023                        &&  !(value.compare("0")))
     
    70257032        if (!fHostIP)
    70267033        {
    7027             rc = CFGMR3InsertInteger (pCfg, "HostIPStack", 0);          RC_CHECK();
     7034            rc = CFGMR3InsertInteger(pCfg, "HostIPStack", 0);           RC_CHECK();
    70287035        }
    70297036
     
    70417048    rc = PDMR3DeviceAttach(pVM, pcszDevice, 0, iLUN, PDM_TACH_FLAGS_NOT_HOT_PLUG, NULL /*ppBase*/); RC_CHECK();
    70427049
    7043     LogFlowFunc (("Returns success\n"));
     7050    LogFlowFunc(("Returns success\n"));
    70447051    return rc;
    70457052}
     
    70777084    try
    70787085    {
    7079         /*  STEP 1 + 2:
    7080          *  request creating the diff images on the server and create the snapshot object
    7081          *  (this will set the machine state to Saving on the server to block
    7082          *  others from accessing this machine)
     7086        /* STEP 1 + 2:
     7087         * request creating the diff images on the server and create the snapshot object
     7088         * (this will set the machine state to Saving on the server to block
     7089         * others from accessing this machine)
    70837090         */
    70847091        rc = pTask->mConsole->mControl->BeginTakingSnapshot(that,
     
    70937100
    70947101        /*
    7095          *  state file is non-null only when the VM is paused
    7096          *  (i.e. creating a snapshot online)
     7102         * state file is non-null only when the VM is paused
     7103         * (i.e. creating a snapshot online)
    70977104         */
    70987105        ComAssertThrow(    (!pTask->bstrSavedStateFile.isNull() && pTask->fTakingSnapshotOnline)
     
    71187125                               Console::stateProgressCallback,
    71197126                               (void*)pTask);
    7120             if (VBOX_FAILURE(vrc))
     7127            if (RT_FAILURE(vrc))
    71217128                throw setError(E_FAIL,
    71227129                            tr("Failed to save the machine state to '%s' (%Rrc)"),
    7123                             strSavedStateFile.c_str(),
    7124                             vrc);
     7130                            strSavedStateFile.c_str(), vrc);
    71257131
    71267132            alock.enter();
     
    71557161
    71567162                rc = that->mMachine->GetStorageControllerByName(controllerName, controller.asOutParam());
    7157                 if (FAILED (rc)) throw rc;
     7163                if (FAILED(rc)) throw rc;
    71587164
    71597165                rc = controller->COMGETTER(ControllerType)(&enmController);
     
    71617167
    71627168                /*
    7163                 * don't leave the lock since reconfigureHardDisks isn't going
    7164                 * to access Console.
    7165                 */
     7169                 * don't leave the lock since reconfigureHardDisks isn't going
     7170                 * to access Console.
     7171                 */
    71667172                int vrc = VMR3ReqCallWait(that->mpVM,
    71677173                                          VMCPUID_ANY,
     
    71837189
    71847190        /*
    7185          *  finalize the requested snapshot object.
    7186          *  This will reset the machine state to the state it had right
    7187          *  before calling mControl->BeginTakingSnapshot().
     7191         * finalize the requested snapshot object.
     7192         * This will reset the machine state to the state it had right
     7193         * before calling mControl->BeginTakingSnapshot().
    71887194         */
    71897195        rc = that->mControl->EndTakingSnapshot(TRUE);        // success
     
    72187224
    72197225/**
    7220  *  Thread for executing the saved state operation.
    7221  *
    7222  *  @param   Thread      The thread handle.
    7223  *  @param   pvUser      Pointer to a VMSaveTask structure.
    7224  *  @return  VINF_SUCCESS (ignored).
    7225  *
    7226  *  @note Locks the Console object for writing.
     7226 * Thread for executing the saved state operation.
     7227 *
     7228 * @param   Thread      The thread handle.
     7229 * @param   pvUser      Pointer to a VMSaveTask structure.
     7230 * @return  VINF_SUCCESS (ignored).
     7231 *
     7232 * @note Locks the Console object for writing.
    72277233 */
    72287234/*static*/
    7229 DECLCALLBACK (int) Console::saveStateThread(RTTHREAD Thread, void *pvUser)
     7235DECLCALLBACK(int) Console::saveStateThread(RTTHREAD Thread, void *pvUser)
    72307236{
    72317237    LogFlowFuncEnter();
    72327238
    7233     std::auto_ptr<VMSaveTask> task (static_cast<VMSaveTask*>(pvUser));
     7239    std::auto_ptr<VMSaveTask> task(static_cast<VMSaveTask*>(pvUser));
    72347240    AssertReturn(task.get(), VERR_INVALID_PARAMETER);
    72357241
     
    72417247    HRESULT rc = S_OK;
    72427248
    7243     LogFlowFunc (("Saving the state to '%s'...\n", task->mSavedStateFile.raw()));
     7249    LogFlowFunc(("Saving the state to '%s'...\n", task->mSavedStateFile.raw()));
    72447250
    72457251    int vrc = VMR3Save(that->mpVM,
     
    72487254                       Console::stateProgressCallback,
    72497255                       static_cast<VMProgressTask*>(task.get()));
    7250     if (VBOX_FAILURE(vrc))
     7256    if (RT_FAILURE(vrc))
    72517257    {
    72527258        errMsg = Utf8StrFmt(Console::tr("Failed to save the machine state to '%s' (%Rrc)"),
     
    72567262
    72577263    /* lock the console once we're going to access it */
    7258     AutoWriteLock thatLock (that);
     7264    AutoWriteLock thatLock(that);
    72597265
    72607266    /*
    7261      *  finalize the requested save state procedure.
    7262      *  In case of success, the server will set the machine state to Saved;
    7263      *  in case of failure it will reset the it to the state it had right
    7264      *  before calling mControl->BeginSavingState().
     7267     * finalize the requested save state procedure.
     7268     * In case of success, the server will set the machine state to Saved;
     7269     * in case of failure it will reset the it to the state it had right
     7270     * before calling mControl->BeginSavingState().
    72657271     */
    7266     that->mControl->EndSavingState (SUCCEEDED(rc));
     7272    that->mControl->EndSavingState(SUCCEEDED(rc));
    72677273
    72687274    /* synchronize the state with the server */
     
    72707276    {
    72717277        /*
    7272          *  The machine has been successfully saved, so power it down
    7273          *  (vmstateChangeCallback() will set state to Saved on success).
    7274          *  Note: we release the task's VM caller, otherwise it will
    7275          *  deadlock.
     7278         * The machine has been successfully saved, so power it down
     7279         * (vmstateChangeCallback() will set state to Saved on success).
     7280         * Note: we release the task's VM caller, otherwise it will
     7281         * deadlock.
    72767282         */
    72777283        task->releaseVMCaller();
     
    72827288    /* notify the progress object about operation completion */
    72837289    if (SUCCEEDED(rc))
    7284         task->mProgress->notifyComplete (S_OK);
     7290        task->mProgress->notifyComplete(S_OK);
    72857291    else
    72867292    {
     
    72917297                                            errMsg.c_str());
    72927298        else
    7293             task->mProgress->notifyComplete (rc);
     7299            task->mProgress->notifyComplete(rc);
    72947300    }
    72957301
     
    72997305
    73007306/**
    7301  *  Thread for powering down the Console.
    7302  *
    7303  *  @param   Thread      The thread handle.
    7304  *  @param   pvUser      Pointer to the VMTask structure.
    7305  *  @return  VINF_SUCCESS (ignored).
    7306  *
    7307  *  @note Locks the Console object for writing.
     7307 * Thread for powering down the Console.
     7308 *
     7309 * @param   Thread      The thread handle.
     7310 * @param   pvUser      Pointer to the VMTask structure.
     7311 * @return  VINF_SUCCESS (ignored).
     7312 *
     7313 * @note Locks the Console object for writing.
    73087314 */
    73097315/*static*/
    7310 DECLCALLBACK (int) Console::powerDownThread(RTTHREAD Thread, void *pvUser)
     7316DECLCALLBACK(int) Console::powerDownThread(RTTHREAD Thread, void *pvUser)
    73117317{
    73127318    LogFlowFuncEnter();
    73137319
    7314     std::auto_ptr <VMProgressTask> task (static_cast <VMProgressTask *> (pvUser));
     7320    std::auto_ptr<VMProgressTask> task(static_cast<VMProgressTask *>(pvUser));
    73157321    AssertReturn(task.get(), VERR_INVALID_PARAMETER);
    73167322
     
    73237329
    73247330    /* wait until the method tat started us returns */
    7325     AutoWriteLock thatLock (that);
     7331    AutoWriteLock thatLock(that);
    73267332
    73277333    /* release VM caller to avoid the powerDown() deadlock */
    73287334    task->releaseVMCaller();
    73297335
    7330     that->powerDown (task->mProgress);
     7336    that->powerDown(task->mProgress);
    73317337
    73327338    LogFlowFuncLeave();
     
    73697375        PPDMLED pLed;
    73707376        int rc = pData->pLedPorts->pfnQueryStatusLed(pData->pLedPorts, iLUN, &pLed);
    7371         if (VBOX_FAILURE(rc))
     7377        if (RT_FAILURE(rc))
    73727378            pLed = NULL;
    73737379        ASMAtomicXchgPtr((void * volatile *)&pData->papLeds[iLUN - pData->iFirstLUN], pLed);
     
    74497455     */
    74507456    int rc = CFGMR3QueryPtr(pCfgHandle, "papLeds", (void **)&pData->papLeds);
    7451     if (VBOX_FAILURE(rc))
     7457    if (RT_FAILURE(rc))
    74527458    {
    74537459        AssertMsgFailed(("Configuration error: Failed to query the \"papLeds\" value! rc=%Rrc\n", rc));
     
    74587464    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    74597465        pData->iFirstLUN = 0;
    7460     else if (VBOX_FAILURE(rc))
     7466    else if (RT_FAILURE(rc))
    74617467    {
    74627468        AssertMsgFailed(("Configuration error: Failed to query the \"First\" value! rc=%Rrc\n", rc));
     
    74677473    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    74687474        pData->iLastLUN = 0;
    7469     else if (VBOX_FAILURE(rc))
     7475    else if (RT_FAILURE(rc))
    74707476    {
    74717477        AssertMsgFailed(("Configuration error: Failed to query the \"Last\" value! rc=%Rrc\n", rc));
     
    74897495    }
    74907496
    7491     for (unsigned i = pData->iFirstLUN; i <= pData->iLastLUN; i++)
     7497    for (unsigned i = pData->iFirstLUN; i <= pData->iLastLUN; ++i)
    74927498        Console::drvStatus_UnitChanged(&pData->ILedConnectors, i);
    74937499
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