9.22. VirtualBox Watchdog

Oracle VM VirtualBox

9.22. VirtualBox Watchdog

Starting with VirtualBox 4.2 the memory ballooning service formerly known as VBoxBalloonCtrl was renamed to VBoxWatchdog, which now incorporates several host services that are meant to be run in a server environment.

These services are:

  • Memory ballooning control, which automatically takes care of a VM's configured memory balloon (see Section 4.9.1, “Memory ballooning” for an introduction to memory ballooning). This especially is useful for server environments where VMs may dynamically require more or less memory during runtime.

    The service periodically checks a VM's current memory balloon and its free guest RAM and automatically adjusts the current memory balloon by inflating or deflating it accordingly. This handling only applies to running VMs having recent Guest Additions installed.

  • Host isolation detection, which provides a way to detect whether the host cannot reach the specific VirtualBox server instance anymore and take appropriate actions, such as shutting down, saving the current state or even powering down certain VMs.

All configuration values can be either specified via command line or global extradata, whereas command line values always have a higher priority when set. Some of the configuration values also be specified on a per-VM basis. So the overall lookup order is: command line, per-VM basis extradata (if available), global extradata.

9.22.1. Memory ballooning control

The memory ballooning control inflates and deflates the memory balloon of VMs based on the VMs free memory and the desired maximum balloon size.

To set up the memory ballooning control the maximum ballooning size a VM can reach needs to be set. This can be specified via command line with

--balloon-max <Size in MB>

, on a per-VM basis extradata value with

VBoxManage setextradata <VM-Name> VBoxInternal2/Watchdog/BalloonCtrl/BalloonSizeMax <Size in MB>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/BalloonCtrl/BalloonSizeMax <Size in MB>

Note

If no maximum ballooning size is specified by at least one of the parameters above, no ballooning will be performed at all.

Setting the ballooning increment in MB can be either done via command line with

--balloon-inc <Size in MB>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/BalloonCtrl/BalloonIncrementMB <Size in MB>

Default ballooning increment is 256 MB if not specified.

Same goes with the ballooning decrement: Via command line with

--balloon-dec <Size in MB>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/BalloonCtrl/BalloonDecrementMB <Size in MB>

Default ballooning decrement is 128 MB if not specified.

To define the lower limit in MB a balloon can be the command line with

--balloon-lower-limit <Size in MB>

can be used or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/BalloonCtrl/BalloonLowerLimitMB <Size in MB>

is available. Default lower limit is 128 if not specified.

9.22.2. Host isolation detection

To detect whether a host is being isolated, that is, the host cannot reach the VirtualBox server instance anymore, the host needs to set an alternating value to a global extradata value within a time period. If this value is not set within that time period a timeout occurred and the so-called host isolation response will be performed to the VMs handled. Which VMs are handled can be controlled by defining VM groups and assigning VMs to those groups. By default no groups are set, meaning that all VMs on the server will be handled when no host response is received within 30 seconds.

To set the groups handled by the host isolation detection via command line:

--apimon-groups=<string[,stringN]>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/APIMonitor/Groups <string[,stringN]>

To set the host isolation timeout via command line:

--apimon-isln-timeout=<ms>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/APIMonitor/IsolationTimeoutMS <ms>

To set the actual host isolation response via command line:

--apimon-isln-response=<cmd>

or using a global extradata value with

VBoxManage setextradata global VBoxInternal2/Watchdog/APIMonitor/IsolationResponse <cmd>

The following response commands are available:

  • none, which does nothing.

  • pause, which pauses the execution of a VM.

  • poweroff, which shuts down the VM by pressing the virtual power button. The VM will not have the chance of saving any data or veto the shutdown process.

  • save, which saves the current machine state and powers off the VM afterwards. If saving the machine state fails the VM will be paused.

  • shutdown, which shuts down the VM in a gentle way by sending an ACPI shutdown event to the VM's operating system. The OS then has the chance of doing a clean shutdown.

9.22.3. More information

For more advanced options and parameters like verbose logging check the built-in command line help accessible with --help.

9.22.4. Linux: starting the watchdog service via init

On Linux, the watchdog service can be automatically started during host boot by adding appropriate parameters to the file /etc/default/virtualbox. There is one mandatory parameter, VBOXWATCHDOG_USER, which must be set to the user which will later start the VMs. For backward compatibility you can also specify VBOXBALLOONCTRL_USERThe parameters in the table below all start with VBOXWATCHDOG_ (VBOXWATCHDOG_BALLOON_INTERVAL, VBOXWATCHDOG_LOGSIZE etc., and for previously existing parameters the VBOXBALLOONCTRL_INTERVAL etc. parameters can still be used):

Table 9.3. VirtualBox watchdog configuration parameters

Parameter Description Default
USER The user as which the watchdog service runs  
ROTATE Number of log files; 0 disables log rotation 10
LOGSIZE Maximum size of a log file in bytes to trigger rotation 1MB
LOGINTERVAL Maximum time interval in seconds to trigger log rotation 1 day
BALLOON_INTERVAL Interval for checking the balloon size (msec) 30000
BALLOON_INCREMENT Balloon size increment (MByte) 256
BALLOON_DECREMENT Balloon size decrement (MByte) 128
BALLOON_LOWERLIMIT Balloon size lower limit (MByte) 64
BALLOON_SAFETYMARGIN Free memory required for decreasing the balloon size (MByte) 1024

9.22.5. Solaris: starting the watchdog service via SMF

On Solaris hosts, the VirtualBox watchdog service daemon is integrated into the SMF framework. You can change the parameters, but don't have to if the defaults already match your needs:

svccfg -s svc:/application/virtualbox/balloonctrl:default setprop config/balloon_interval=10000
svccfg -s svc:/application/virtualbox/balloonctrl:default setprop config/balloon_safetymargin=134217728

The table in the previous section showing the parameter names and defaults also applies to Solaris. The parameter names must be changed to lowercase and a prefix of config/ has to be added, e.g. config/user or config/balloon_safetymargin. If you made any change, don't forget to run the following command to put the changes into effect immediately:

svcadm refresh svc:/application/virtualbox/balloonctrl:default

If you forget the above command then the previous settings will be used when enabling the service. Check the current property settings with:

svcprop -p config svc:/application/virtualbox/balloonctrl:default

When everything is configured correctly you can start the VirtualBox watchdog service with the following command:

svcadm enable svc:/application/virtualbox/balloonctrl:default

For more information about SMF, please refer to the Solaris documentation.