Changeset 41422 in vbox for trunk/src/VBox
- Timestamp:
- May 23, 2012 3:59:04 PM (13 years ago)
- Location:
- trunk/src/VBox/Frontends/VBoxBalloonCtrl
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxModAPIMonitor.cpp
r41361 r41422 458 458 if (g_vecAPIMonGroups.empty()) /* Not set by command line? */ 459 459 { 460 CHECK_ERROR_BREAK(g_pVirtualBox, GetExtraData(Bstr(" Watchdog/APIMonitor/Groups").raw(),460 CHECK_ERROR_BREAK(g_pVirtualBox, GetExtraData(Bstr("VBoxInternal2/Watchdog/APIMonitor/Groups").raw(), 461 461 strValue.asOutParam())); 462 462 if (!strValue.isEmpty()) … … 468 468 } 469 469 470 /* Host isolation timeout (in ms). */ 471 if (!g_ulAPIMonIslnTimeoutMS) /* Not set by command line? */ 472 { 473 CHECK_ERROR_BREAK(g_pVirtualBox, GetExtraData(Bstr("Watchdog/APIMonitor/IsolationTimeout").raw(), 474 strValue.asOutParam())); 475 if (!strValue.isEmpty()) 476 g_ulAPIMonIslnTimeoutMS = Utf8Str(strValue).toUInt32(); 477 } 478 if (!g_ulAPIMonIslnTimeoutMS) /* Still not set? Use a default. */ 479 { 480 serviceLogVerbose(("apimon: API monitor isolation timeout not given, defaulting to 30s\n")); 481 482 /* Default is 30 seconds timeout. */ 483 g_ulAPIMonIslnTimeoutMS = 30 * 1000; 484 } 485 486 /* Host isolation command response. */ 470 if (!g_ulAPIMonIslnTimeoutMS) 471 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 472 "VBoxInternal2/Watchdog/APIMonitor/IsolationTimeoutMS", NULL /* Per-machine */, 473 &g_ulAPIMonIslnTimeoutMS, 30 * 1000 /* Default is 30 seconds timeout. */); 474 g_ulAPIMonIslnTimeoutMS = RT_MIN(1000, g_ulAPIMonIslnTimeoutMS); 475 487 476 if (g_enmAPIMonIslnResp == APIMON_RESPONSE_NONE) /* Not set by command line? */ 488 477 { 489 CHECK_ERROR_BREAK(g_pVirtualBox, GetExtraData(Bstr("Watchdog/APIMonitor/IsolationResponse").raw(), 490 strValue.asOutParam())); 491 if (!strValue.isEmpty()) 478 Utf8Str strResp; 479 int rc2 = cfgGetValueStr(g_pVirtualBox, NULL /* Machine */, 480 "VBoxInternal2/Watchdog/APIMonitor/IsolationResponse", NULL /* Per-machine */, 481 strResp, "" /* Default value. */); 482 if (RT_SUCCESS(rc2)) 492 483 { 493 int rc2 = apimonResponseToEnum(Utf8Str(strValue).c_str(), &g_enmAPIMonIslnResp);484 rc2 = apimonResponseToEnum(strResp.c_str(), &g_enmAPIMonIslnResp); 494 485 if (RT_FAILURE(rc2)) 495 486 serviceLog("apimon: Warning: API monitor response string invalid (%ls), defaulting to no action\n", … … 498 489 } 499 490 500 /* Trigger timeout (in ms). */ 501 if (!g_ulAPIMonResponseTimeoutMS) /* Not set by command line? */ 502 { 503 CHECK_ERROR_BREAK(g_pVirtualBox, GetExtraData(Bstr("Watchdog/APIMonitor/ResponseTimeout").raw(), 504 strValue.asOutParam())); 505 if (!strValue.isEmpty()) 506 g_ulAPIMonResponseTimeoutMS = Utf8Str(strValue).toUInt32(); 507 } 508 if (!g_ulAPIMonResponseTimeoutMS) /* Still not set? Use a default. */ 509 { 510 serviceLogVerbose(("apimon: API monitor response timeout not given, defaulting to 30s\n")); 511 512 /* Default is 30 seconds timeout. */ 513 g_ulAPIMonResponseTimeoutMS = 30 * 1000; 514 } 491 if (!g_ulAPIMonResponseTimeoutMS) 492 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 493 "VBoxInternal2/Watchdog/APIMonitor/ResponseTimeoutMS", NULL /* Per-machine */, 494 &g_ulAPIMonResponseTimeoutMS, 30 * 1000 /* Default is 30 seconds timeout. */); 495 g_ulAPIMonResponseTimeoutMS = RT_MIN(5000, g_ulAPIMonResponseTimeoutMS); 515 496 516 497 #ifdef DEBUG -
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxModBallooning.cpp
r41360 r41422 55 55 }; 56 56 57 static unsigned long g_ulMemoryBalloonTimeoutMS = 30 * 1000; /* Default is 30 seconds timeout. */58 static unsigned long g_ulMemoryBalloonIncrementMB = 256;59 static unsigned long g_ulMemoryBalloonDecrementMB = 128;57 static unsigned long g_ulMemoryBalloonTimeoutMS = 0; 58 static unsigned long g_ulMemoryBalloonIncrementMB = 0; 59 static unsigned long g_ulMemoryBalloonDecrementMB = 0; 60 60 /** Global balloon limit is 0, so disabled. Can be overridden by a per-VM 61 61 * "VBoxInternal/Guest/BalloonSizeMax" value. */ 62 62 static unsigned long g_ulMemoryBalloonMaxMB = 0; 63 static unsigned long g_ulMemoryBalloonLowerLimitMB = 64;63 static unsigned long g_ulMemoryBalloonLowerLimitMB = 0; 64 64 65 65 /** The ballooning module's payload. */ … … 135 135 * By default (e.g. if none of above is set), ballooning is disabled. 136 136 */ 137 unsigned long ulBalloonMax = g_ulMemoryBalloonMaxMB; /* Use global limit as default. */ 138 if (!ulBalloonMax) /* Not set by command line? */ 139 { 140 /* Try per-VM approach. */ 141 Bstr strValue; 142 HRESULT rc = rptrMachine->GetExtraData(Bstr("VBoxInternal/Guest/BalloonSizeMax").raw(), 143 strValue.asOutParam()); 144 if ( SUCCEEDED(rc) 145 && !strValue.isEmpty()) 137 unsigned long ulBalloonMax = g_ulMemoryBalloonMaxMB; 138 if (!ulBalloonMax) 139 { 140 int rc = cfgGetValueULong(g_pVirtualBox, rptrMachine, 141 "VBoxInternal/Guest/BalloonSizeMax", "VBoxInternal/Guest/BalloonSizeMax", &ulBalloonMax, 0 /* Ballooning disabled */); 142 if (RT_FAILURE(rc)) 146 143 { 147 ulBalloonMax = Utf8Str(strValue).toUInt32(); 144 /* Try (new) VBoxWatch per-VM approach. */ 145 Bstr strValue; 146 HRESULT rc = rptrMachine->GetExtraData(Bstr("VBoxInternal2/Watchdog/BalloonCtrl/BalloonSizeMax").raw(), 147 strValue.asOutParam()); 148 if ( SUCCEEDED(rc) 149 && !strValue.isEmpty()) 150 { 151 ulBalloonMax = Utf8Str(strValue).toUInt32(); 152 } 148 153 } 149 154 } 150 if (!ulBalloonMax) /* Still not set by per-VM value? */ 151 { 152 /* Try global approach. */ 153 Bstr strValue; 154 HRESULT rc = g_pVirtualBox->GetExtraData(Bstr("VBoxInternal/Guest/BalloonSizeMax").raw(), 155 strValue.asOutParam()); 156 if ( SUCCEEDED(rc) 157 && !strValue.isEmpty()) 158 { 159 ulBalloonMax = Utf8Str(strValue).toUInt32(); 160 } 161 } 162 if (!ulBalloonMax) 163 { 164 /** @todo ("VBoxInternal2/Watchdog/BalloonCtrl/BalloonSizeMax") */ 165 } 155 166 156 return ulBalloonMax; 167 157 } … … 398 388 break; 399 389 400 /** @todo Add (legacy) "--inverval" setting! */ 401 /** @todo This option is a common moudle option! Put 390 /** @todo This option is a common module option! Put 402 391 * this into a utility function! */ 403 392 case GETOPTDEF_BALLOONCTRL_TIMEOUTMS: … … 418 407 static DECLCALLBACK(int) VBoxModBallooningInit(void) 419 408 { 420 return VINF_SUCCESS; /* Nothing to do here right now. */ 409 if (!g_ulMemoryBalloonTimeoutMS) 410 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 411 "VBoxInternal2/Watchdog/BalloonCtrl/TimeoutMS", NULL /* Per-machine */, 412 &g_ulMemoryBalloonTimeoutMS, 30 * 1000 /* Default is 30 seconds timeout. */); 413 414 if (!g_ulMemoryBalloonIncrementMB) 415 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 416 "VBoxInternal2/Watchdog/BalloonCtrl/BalloonIncrementMB", NULL /* Per-machine */, 417 &g_ulMemoryBalloonIncrementMB, 256); 418 419 if (!g_ulMemoryBalloonDecrementMB) 420 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 421 "VBoxInternal2/Watchdog/BalloonCtrl/BalloonDecrementMB", NULL /* Per-machine */, 422 &g_ulMemoryBalloonDecrementMB, 128); 423 424 if (!g_ulMemoryBalloonLowerLimitMB) 425 cfgGetValueULong(g_pVirtualBox, NULL /* Machine */, 426 "VBoxInternal2/Watchdog/BalloonCtrl/BalloonLowerLimitMB", NULL /* Per-machine */, 427 &g_ulMemoryBalloonLowerLimitMB, 128); 428 429 return VINF_SUCCESS; 421 430 } 422 431 -
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdogInternal.h
r41286 r41422 232 232 int payloadAlloc(PVBOXWATCHDOG_MACHINE pMachine, const char *pszModule, size_t cbSize, void **ppszPayload); 233 233 void payloadFree(PVBOXWATCHDOG_MACHINE pMachine, const char *pszModule); 234 234 235 PVBOXWATCHDOG_MACHINE getMachine(const Bstr& strUuid); 235 236 MachineState_T getMachineState(const PVBOXWATCHDOG_MACHINE pMachine); 236 237 238 int cfgGetValueStr(const ComPtr<IVirtualBox> &rptrVBox, const ComPtr<IMachine> &rptrMachine, 239 const char *pszGlobal, const char *pszVM, Utf8Str &strValue, Utf8Str strDefault); 240 int cfgGetValueULong(const ComPtr<IVirtualBox> &rptrVBox, const ComPtr<IMachine> &rptrMachine, 241 const char *pszGlobal, const char *pszVM, unsigned long *pulValue, unsigned long ulDefault); 237 242 RT_C_DECLS_END 238 243 -
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdogUtils.cpp
r41286 r41422 208 208 } 209 209 210 int cfgGetValueStr(const ComPtr<IVirtualBox> &rptrVBox, const ComPtr<IMachine> &rptrMachine, 211 const char *pszGlobal, const char *pszVM, Utf8Str &strValue, Utf8Str strDefault) 212 { 213 AssertReturn(!rptrVBox.isNull(), VERR_INVALID_POINTER); 214 215 216 /* Try per-VM approach. */ 217 Bstr strTemp; 218 HRESULT hr; 219 if (!rptrMachine.isNull()) 220 { 221 AssertPtr(pszVM); 222 hr = rptrMachine->GetExtraData(Bstr(pszVM).raw(), 223 strTemp.asOutParam()); 224 if ( SUCCEEDED(hr) 225 && !strTemp.isEmpty()) 226 { 227 strValue = Utf8Str(strTemp); 228 } 229 } 230 231 if (strValue.isEmpty()) /* Not set by per-VM value? */ 232 { 233 AssertPtr(pszGlobal); 234 235 /* Try global approach. */ 236 hr = rptrVBox->GetExtraData(Bstr(pszGlobal).raw(), 237 strTemp.asOutParam()); 238 if ( SUCCEEDED(hr) 239 && !strTemp.isEmpty()) 240 { 241 strValue = Utf8Str(strTemp); 242 } 243 } 244 245 if (strValue.isEmpty()) 246 { 247 strValue = strDefault; 248 return VERR_NOT_FOUND; 249 } 250 251 return VINF_SUCCESS; 252 } 253 254 int cfgGetValueULong(const ComPtr<IVirtualBox> &rptrVBox, const ComPtr<IMachine> &rptrMachine, 255 const char *pszGlobal, const char *pszVM, unsigned long *pulValue, unsigned long ulDefault) 256 { 257 Utf8Str strValue; 258 int rc = cfgGetValueStr(rptrVBox, rptrMachine, pszGlobal, pszVM, strValue, "" /* Default */); 259 if (RT_SUCCESS(rc)) 260 { 261 *pulValue = strValue.toUInt32(); 262 } 263 else 264 *pulValue = ulDefault; 265 266 return rc; 267 } 268
Note:
See TracChangeset
for help on using the changeset viewer.