VirtualBox

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


Ignore:
Timestamp:
May 27, 2019 10:22:15 AM (6 years ago)
Author:
vboxsync
Message:

Main: Cache the VBoxInternal2/TurnResetIntoPowerOff value so we don't have to release the console lock in Console::powerDown when it's not active, as this introduces a race condition wrt the VM state. It also avoid some IPC during power off, which is nice.

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

Legend:

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

    r78683 r78779  
    865865#endif
    866866
    867     bool i_isResetTurnedIntoPowerOff(void);
    868 
    869867    /** @name Disk encryption support
    870868     * @{ */
     
    941939    /** true if a USB controller is available (i.e. USB devices can be attached). */
    942940    bool mfVMHasUsbController : 1;
     941    /** Shadow of the VBoxInternal2/TurnResetIntoPowerOff extra data setting.
     942     * This is initialized by Console::i_configConstructorInner(). */
     943    bool mfTurnResetIntoPowerOff : 1;
    943944    /** true if the VM power off was caused by reset. */
    944945    bool mfPowerOffCausedByReset : 1;
  • trunk/src/VBox/Main/src-client/ConsoleImpl.cpp

    r78767 r78779  
    275275inline static const char *networkAdapterTypeToName(NetworkAdapterType_T adapterType);
    276276
    277 class VmEventListener {
     277class VmEventListener
     278{
    278279public:
    279280    VmEventListener()
     
    328329                    break;
    329330                mConsole->i_onNATRedirectRuleChange(ulSlot, fRemove, proto, hostIp.raw(), hostPort, guestIp.raw(), guestPort);
     331                break;
    330332            }
    331             break;
    332333
    333334            case VBoxEventType_OnHostNameResolutionConfigurationChange:
     
    398399    , mfSnapshotFolderDiskTypeShown(false)
    399400    , mfVMHasUsbController(false)
     401    , mfTurnResetIntoPowerOff(false)
    400402    , mfPowerOffCausedByReset(false)
    401403    , mpVmm2UserMethods(NULL)
     
    10801082
    10811083#endif /* VBOX_WITH_GUEST_PROPS */
    1082 
    1083 bool Console::i_isResetTurnedIntoPowerOff(void)
    1084 {
    1085     Bstr value;
    1086     HRESULT hrc = mMachine->GetExtraData(Bstr("VBoxInternal2/TurnResetIntoPowerOff").raw(),
    1087                                          value.asOutParam());
    1088     if (   hrc   == S_OK
    1089         && value == "1")
    1090         return true;
    1091     return false;
    1092 }
    10931084
    10941085#ifdef VBOX_WITH_EXTPACK
     
    21932184
    21942185#ifdef VBOX_WITH_GUEST_PROPS
    2195     alock.release(); /** @todo r=bird: This code introduces a race condition wrt to the state.  This must be done elsewhere! */
    2196 
    2197     if (i_isResetTurnedIntoPowerOff())
    2198     {
     2186    if (mfTurnResetIntoPowerOff)
     2187    {
     2188        alock.release(); /** @todo r=bird: This code introduces a race condition wrt to the state.  This must be done elsewhere! */
    21992189        mMachine->DeleteGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw());
    22002190        mMachine->SetGuestProperty(Bstr("/VirtualBox/HostInfo/VMPowerOffReason").raw(),
    22012191                                   Bstr("PowerOff").raw(), Bstr("RDONLYGUEST").raw());
    22022192        mMachine->SaveSettings();
    2203     }
    2204 
    2205     alock.acquire();
     2193        alock.acquire();
     2194    }
    22062195#endif
    22072196
     
    60526041    if (ptrVM.isOk())
    60536042    {
    6054         Bstr strKey(aKey);
    6055         Bstr strVal(aVal);
    6056 
    6057         if (strKey == "VBoxInternal2/TurnResetIntoPowerOff")
    6058         {
    6059             int vrc = VMR3SetPowerOffInsteadOfReset(ptrVM.rawUVM(), strVal == "1");
     6043        if (RTUtf16CmpAscii(aKey, "VBoxInternal2/TurnResetIntoPowerOff") == 0)
     6044        {
     6045            mfTurnResetIntoPowerOff = RTUtf16CmpAscii(aVal, "1") == 0;
     6046            int vrc = VMR3SetPowerOffInsteadOfReset(ptrVM.rawUVM(), mfTurnResetIntoPowerOff);
    60606047            AssertRC(vrc);
    60616048        }
     
    87918778        {
    87928779#ifdef VBOX_WITH_GUEST_PROPS
    8793             if (that->i_isResetTurnedIntoPowerOff())
     8780            if (that->mfTurnResetIntoPowerOff)
    87948781            {
    87958782                Bstr strPowerOffReason;
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r78725 r78779  
    12041204
    12051205        /* Reset overwrite. */
    1206         if (i_isResetTurnedIntoPowerOff())
     1206        mfTurnResetIntoPowerOff = GetExtraDataBoth(virtualBox, pMachine,
     1207                                                   "VBoxInternal2/TurnResetIntoPowerOff", &strTmp)->equals("1");
     1208        if (mfTurnResetIntoPowerOff)
    12071209            InsertConfigInteger(pRoot, "PowerOffInsteadOfReset", 1);
    12081210
Note: See TracChangeset for help on using the changeset viewer.

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