qemu: Set fake reboot flag only in acpi mode for shutdown

Conditional setting of the fake reboot flag should only happen for
the acpi mode shutdown path; however, for the agent mode shutdown,
the fake reboot should be cleared. This patch will essentially revert
commit id '8be502fd', but adds an explicit setting of the flag to false
when using mode=agent while also only conditionally setting the reboot
flag if the guest went away. This also avoids an issue where a shutdown
with reboot semantics is done from agent mode which sets the reboot
flag followed by a shutdown from within the guest which would result
in a reboot due to the fake reboot flag being set. The change will
also properly handle the cases described in the following archive post:

  https://www.redhat.com/archives/libvir-list/2015-April/msg00715.html
This commit is contained in:
Nikolay Shirokovskiy 2016-07-14 14:08:22 +03:00 committed by John Ferlan
parent 172218a01e
commit 3b676eb67f

View File

@ -1997,9 +1997,9 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
useAgent = false; useAgent = false;
} }
qemuDomainSetFakeReboot(driver, vm, isReboot);
if (useAgent) { if (useAgent) {
qemuDomainSetFakeReboot(driver, vm, false);
qemuDomainObjEnterAgent(vm); qemuDomainObjEnterAgent(vm);
ret = qemuAgentShutdown(priv->agent, agentFlag); ret = qemuAgentShutdown(priv->agent, agentFlag);
qemuDomainObjExitAgent(vm); qemuDomainObjExitAgent(vm);
@ -2018,6 +2018,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags)
goto endjob; goto endjob;
} }
qemuDomainSetFakeReboot(driver, vm, isReboot);
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
ret = qemuMonitorSystemPowerdown(priv->mon); ret = qemuMonitorSystemPowerdown(priv->mon);
if (qemuDomainObjExitMonitor(driver, vm) < 0) if (qemuDomainObjExitMonitor(driver, vm) < 0)