- Timestamp:
- Jan 24, 2014 1:46:27 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91800
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/HostPower.h
r50175 r50220 38 38 VirtualBox *mVirtualBox; 39 39 std::vector<ComPtr<IInternalSessionControl> > mSessionControls; 40 41 private:42 bool fSavestateOnBatteryLow;43 40 }; 44 41 -
trunk/src/VBox/Main/src-server/HostPower.cpp
r50216 r50220 53 53 case Reason_HostSuspend: 54 54 { 55 LogFunc((" SUSPEND\n"));55 LogFunc(("HOST SUSPEND\n")); 56 56 57 57 #ifdef VBOX_WITH_RESOURCE_USAGE_API … … 81 81 } 82 82 83 LogFunc(("Suspended %d VMs\n", mSessionControls.size())); 84 83 LogRel(("Host suspending: Paused %d VMs\n", mSessionControls.size())); 85 84 break; 86 85 } … … 88 87 case Reason_HostResume: 89 88 { 90 LogFunc((" RESUME\n"));89 LogFunc(("HOST RESUME\n")); 91 90 92 91 size_t resumed = 0; … … 106 105 } 107 106 108 Log Func(("Resumed %d VMs\n", resumed));107 LogRel(("Host resumed: Resumed %d VMs\n", resumed)); 109 108 110 109 #ifdef VBOX_WITH_RESOURCE_USAGE_API … … 117 116 118 117 mSessionControls.clear(); 119 120 118 break; 121 119 } … … 123 121 case Reason_HostBatteryLow: 124 122 { 123 LogFunc(("BATTERY LOW\n")); 124 125 125 Bstr value; 126 HRESULT hrc = mVirtualBox->GetExtraData(Bstr("VBoxInternal2/SavestateOnBatteryLow").raw(), 127 value.asOutParam()); 128 if ( SUCCEEDED(hrc) 129 && value != "0") 130 { 131 LogFunc(("BATTERY LOW -- savestate running VMs\n")); 132 133 mVirtualBox->getOpenedMachines(machines, &controls); 134 size_t saved = 0; 135 136 /* save running VMs */ 137 for (VirtualBox::InternalControlList::const_iterator it = controls.begin(); 138 it != controls.end(); 139 ++it) 126 rc = mVirtualBox->GetExtraData(Bstr("VBoxInternal2/SavestateOnBatteryLow").raw(), 127 value.asOutParam()); 128 int fGlobal = 0; 129 if (SUCCEEDED(rc)) 130 { 131 if (value != "0") 132 fGlobal = 1; 133 else if (value == "0") 134 fGlobal = -1; 135 } 136 137 mVirtualBox->getOpenedMachines(machines, &controls); 138 size_t saved = 0; 139 140 /* save running VMs */ 141 SessionMachinesList::const_iterator it2 = machines.begin(); 142 for (VirtualBox::InternalControlList::const_iterator it = controls.begin(); 143 it != controls.end() && it2 != machines.end(); 144 ++it, ++it2) 145 { 146 ComPtr<SessionMachine> pMachine = *it2; 147 rc = pMachine->GetExtraData(Bstr("VBoxInternal2/SavestateOnBatteryLow").raw(), 148 value.asOutParam()); 149 int fPerVM = 0; 150 if (SUCCEEDED(rc)) 151 { 152 /* per-VM overrides global */ 153 if (value != "0") 154 fPerVM = 2; 155 else if (value == "0") 156 fPerVM = -2; 157 } 158 159 /* default is true */ 160 if (fGlobal + fPerVM >= 0) 140 161 { 141 162 ComPtr<IInternalSessionControl> pControl = *it; … … 146 167 rc = pControl->SaveStateWithReason(Reason_HostBatteryLow, progress.asOutParam()); 147 168 if (FAILED(rc)) 169 { 170 LogRel(("SaveState '%s' failed with %Rhrc\n", pMachine->getName().c_str(), rc)); 148 171 continue; 172 } 149 173 150 174 /* Wait until the operation has been completed. */ … … 160 184 161 185 if (SUCCEEDED(rc)) 186 { 187 LogRel(("SaveState '%s' succeeded\n", pMachine->getName().c_str())); 162 188 ++saved; 189 } 163 190 } 164 LogFunc(("Saved %d VMs\n", saved)); 165 } 166 else 167 { 168 LogFunc(("BATTERY LOW -- no action\n")); 169 } 170 191 LogRel(("Battery Low: Saved %d VMs\n", saved)); 192 } 171 193 break; 172 194 }
Note:
See TracChangeset
for help on using the changeset viewer.