Changeset 59916 in vbox for trunk/src/VBox/Frontends/VBoxBalloonCtrl
- Timestamp:
- Mar 4, 2016 9:36:37 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105843
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxBalloonCtrl/VBoxModBallooning.cpp
r59909 r59916 65 65 typedef struct VBOXWATCHDOG_BALLOONCTRL_PAYLOAD 66 66 { 67 /** Last (most recent) ballooning size reported by the guest. */ 68 unsigned long ulBalloonCurLast; 67 69 /** Last (most recent) ballooning request received. */ 68 70 unsigned long ulBalloonReqLast; … … 288 290 289 291 /** 292 * Determines whether ballooning for the specified machine is enabled or not. 293 * This can be specified on a per-VM basis or as a globally set value for all VMs. 294 * 295 * @return bool Whether ballooning is enabled or not. 296 * @param pMachine Machine to determine enable status for. 297 */ 298 static bool balloonIsEnabled(PVBOXWATCHDOG_MACHINE pMachine) 299 { 300 const ComPtr<IMachine> &rptrMachine = pMachine->machine; 301 302 bool fEnabled = true; /* By default ballooning is enabled. */ 303 char szSource[64]; 304 305 Bstr strValue; 306 HRESULT hr = g_pVirtualBox->GetExtraData(Bstr("VBoxInternal/Guest/BalloonEnabled").raw(), 307 strValue.asOutParam()); 308 if ( SUCCEEDED(hr) 309 && strValue.isNotEmpty()) 310 { 311 if (g_fVerbose) 312 RTStrPrintf(szSource, sizeof(szSource), "global extra-data"); 313 } 314 else 315 { 316 hr = rptrMachine->GetExtraData(Bstr("VBoxInternal2/Watchdog/BalloonCtrl/BalloonEnabled").raw(), 317 strValue.asOutParam()); 318 if (SUCCEEDED(hr)) 319 { 320 if (g_fVerbose) 321 RTStrPrintf(szSource, sizeof(szSource), "per-VM extra-data"); 322 } 323 } 324 325 if (strValue.isNotEmpty()) 326 { 327 fEnabled = RT_BOOL(Utf8Str(strValue).toUInt32()); 328 serviceLogVerbose(("[%ls] Ballooning is forced to %s (%s)\n", 329 pMachine->strName.raw(), fEnabled ? "enabled" : "disabled", szSource)); 330 } 331 332 return fEnabled; 333 } 334 335 /** 290 336 * Indicates whether ballooning on the specified machine state is 291 337 * possible -- this only is true if the machine is up and running. … … 398 444 AssertPtr(pData); 399 445 446 /* Determine if ballooning is enabled or disabled. */ 447 bool fEnabled = balloonIsEnabled(pMachine); 448 400 449 /* Determine the current set maximum balloon size. */ 401 450 unsigned long ulBalloonMax = balloonGetMaxSize(pMachine); … … 425 474 ulBalloonCur = ulBalloonCur + lBalloonDelta; 426 475 427 serviceLog("[%ls] %s balloon by %RU32MB to %RU32MB ...\n", 428 pMachine->strName.raw(), lBalloonDelta > 0 ? "Inflating" : "Deflating", RT_ABS(lBalloonDelta), ulBalloonCur); 429 430 vrc = balloonSetSize(pMachine, ulBalloonCur); 431 } 432 476 if (fEnabled) 477 { 478 serviceLog("[%ls] %s balloon by %RU32MB to %RU32MB ...\n", 479 pMachine->strName.raw(), lBalloonDelta > 0 ? "Inflating" : "Deflating", RT_ABS(lBalloonDelta), ulBalloonCur); 480 vrc = balloonSetSize(pMachine, ulBalloonCur); 481 } 482 else 483 serviceLogVerbose(("[%ls] Requested %s balloon by %RU32MB to %RU32MB, but ballooning is disabled\n", 484 pMachine->strName.raw(), lBalloonDelta > 0 ? "inflating" : "deflating", 485 RT_ABS(lBalloonDelta), ulBalloonCur)); 486 } 487 488 if (ulBalloonCur != pData->ulBalloonCurLast) 489 { 490 /* If ballooning is disabled, always bolt down the ballooning size to 0. */ 491 if (!fEnabled) 492 { 493 serviceLogVerbose(("[%ls] Ballooning is disabled, forcing to 0\n", pMachine->strName.raw())); 494 int vrc2 = balloonSetSize(pMachine, 0); 495 if (RT_FAILURE(vrc2)) 496 serviceLog("[%ls] Error disabling ballooning, rc=%Rrc\n", pMachine->strName.raw(), vrc2); 497 } 498 } 499 500 pData->ulBalloonCurLast = ulBalloonCur; 433 501 pData->ulBalloonReqLast = ulBalloonReq; 434 502 } 435 503 else 436 serviceLog(" Error: Unable to retrieve metrics for machine '%ls', rc=%Rrc\n",437 pMachine->strName.raw(), vrc); 504 serviceLog("[%ls] Error retrieving metrics, rc=%Rrc\n", pMachine->strName.raw(), vrc); 505 438 506 return vrc; 439 507 }
Note:
See TracChangeset
for help on using the changeset viewer.