--- src/qemu/qemu_driver.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ba5600d..084412f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -1697,6 +1697,8 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { int ret = -1; qemuDomainObjPrivatePtr priv; bool useAgent = false, agentRequested, acpiRequested; + bool isReboot = false; + int agentFlag = QEMU_AGENT_SHUTDOWN_POWERDOWN; virCheckFlags(VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN | VIR_DOMAIN_SHUTDOWN_GUEST_AGENT, -1); @@ -1704,6 +1706,13 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { if (!(vm = qemuDomObjFromDomain(dom))) goto cleanup; + if (vm->def->onPoweroff == VIR_DOMAIN_LIFECYCLE_RESTART || + vm->def->onPoweroff == VIR_DOMAIN_LIFECYCLE_RESTART_RENAME) { + isReboot = true; + agentFlag = QEMU_AGENT_SHUTDOWN_REBOOT; + VIR_INFO("Domain on_poweroff setting overridden, attempting reboot"); + } + priv = vm->privateData; agentRequested = flags & VIR_DOMAIN_SHUTDOWN_GUEST_AGENT; acpiRequested = flags & VIR_DOMAIN_SHUTDOWN_ACPI_POWER_BTN; @@ -1744,7 +1753,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { if (useAgent) { qemuDomainObjEnterAgent(vm); - ret = qemuAgentShutdown(priv->agent, QEMU_AGENT_SHUTDOWN_POWERDOWN); + ret = qemuAgentShutdown(priv->agent, agentFlag); qemuDomainObjExitAgent(vm); } @@ -1753,7 +1762,7 @@ static int qemuDomainShutdownFlags(virDomainPtr dom, unsigned int flags) { */ if (!useAgent || (ret < 0 && (acpiRequested || !flags))) { - qemuDomainSetFakeReboot(driver, vm, false); + qemuDomainSetFakeReboot(driver, vm, isReboot); qemuDomainObjEnterMonitor(driver, vm); ret = qemuMonitorSystemPowerdown(priv->mon); @@ -1784,6 +1793,8 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) int ret = -1; qemuDomainObjPrivatePtr priv; bool useAgent = false; + bool isReboot = true; + int agentFlag = QEMU_AGENT_SHUTDOWN_REBOOT; virCheckFlags(VIR_DOMAIN_REBOOT_ACPI_POWER_BTN | VIR_DOMAIN_REBOOT_GUEST_AGENT , -1); @@ -1799,6 +1810,13 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) if (!(vm = qemuDomObjFromDomain(dom))) goto cleanup; + if (vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_DESTROY || + vm->def->onReboot == VIR_DOMAIN_LIFECYCLE_PRESERVE) { + agentFlag = QEMU_AGENT_SHUTDOWN_POWERDOWN; + isReboot = false; + VIR_INFO("Domain on_reboot setting overridden, shutting down"); + } + priv = vm->privateData; if ((flags & VIR_DOMAIN_REBOOT_GUEST_AGENT) || @@ -1847,7 +1865,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) if (useAgent) { qemuDomainObjEnterAgent(vm); - ret = qemuAgentShutdown(priv->agent, QEMU_AGENT_SHUTDOWN_REBOOT); + ret = qemuAgentShutdown(priv->agent, agentFlag); qemuDomainObjExitAgent(vm); } else { qemuDomainObjEnterMonitor(driver, vm); @@ -1855,7 +1873,7 @@ qemuDomainReboot(virDomainPtr dom, unsigned int flags) qemuDomainObjExitMonitor(driver, vm); if (ret == 0) - qemuDomainSetFakeReboot(driver, vm, true); + qemuDomainSetFakeReboot(driver, vm, isReboot); } endjob: -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list