HostPower.cpp revision 0a1ded7cadae50b2ee93d8df1d2af5b00b5b88e5
/** @file
*
* VirtualBox interface to host's power notification service
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include "HostPower.h"
#include "Logging.h"
#include "VirtualBoxImpl.h"
#include "MachineImpl.h"
{
// keep this in sync with the host-specific implementations
#if defined(RT_OS_WINDOWS) || defined(RT_OS_DARWIN)
bstrValue.asOutParam());
|| bstrValue != "0"))
{
fSavestateOnBatteryLow = true;
LogRel(("Power: BatteryLow event will trigger VM savestate\n"));
}
else
#endif
{
fSavestateOnBatteryLow = false;
LogRel(("Power: BatteryLow will be ignored\n"));
}
}
{
}
{
switch (aReason)
{
case Reason_HostSuspend:
{
LogFunc(("SUSPEND\n"));
#ifdef VBOX_WITH_RESOURCE_USAGE_API
/* Suspend performance sampling to avoid unnecessary callbacks due to jumps in time. */
if (perfcollector)
#endif
/* pause running VMs */
++it)
{
/* PauseWithReason() will simply return a failure if
* the VM is in an inappropriate state */
continue;
/* save the control to un-pause the VM later */
}
break;
}
case Reason_HostResume:
{
LogFunc(("RESUME\n"));
/* go through VMs we paused on Suspend */
{
/* note that Resume() will simply return a failure if the VM is
* in an inappropriate state (it will also fail if the VM has
* been somehow closed by this time already so that the
* console reference we have is dead) */
continue;
++resumed;
}
#ifdef VBOX_WITH_RESOURCE_USAGE_API
/* Resume the performance sampling. */
if (perfcollector)
#endif
break;
}
case Reason_HostBatteryLow:
{
{
LogFunc(("BATTERY LOW -- savestate running VMs\n"));
/* save running VMs */
++it)
{
/* note that SaveStateWithReason() will simply return a failure
* if the VM is in an inappropriate state */
continue;
/* Wait until the operation has been completed. */
{
}
++saved;
}
}
else
{
LogFunc(("BATTERY LOW -- no action\n"));
}
break;
}
default:
/* nothing */;
}
}
/* vi: set tabstop=4 shiftwidth=4 expandtab: */