[SYSREG2] Attempt a graceful ACPI shutdown before poweroff

This commit is contained in:
Pierre Schweitzer 2018-12-27 21:21:22 +01:00
parent 1d2fe15ed9
commit d2d0ef6677
No known key found for this signature in database
GPG Key ID: 7545556C3D585B0B

View File

@ -172,9 +172,21 @@ void LibVirt::ShutdownMachine()
*/
virDomainGetInfo(vDom, &info);
/* Kill the VM - if running */
/* Shutdown the VM - if running */
if (info.state != VIR_DOMAIN_SHUTOFF)
virDomainDestroy(vDom);
{
/* We will first try a graceful shutdown */
virDomainReboot(vDom, VIR_DOMAIN_REBOOT_ACPI_POWER_BTN);
sleep(3);
/* Is the VM shut? */
virDomainGetInfo(vDom, &info);
/* Kill the VM - if running */
if (info.state != VIR_DOMAIN_SHUTOFF)
virDomainDestroy(vDom);
}
for (unsigned int i = 0; i < 12; ++i)
{