mirror of https://gitee.com/openkylin/libvirt.git
qemu: Honor 'restart' action for 'on_poweroff'
We simply terminate qemu instead of issuing a reset as the semantics of the setting dictate. Fix it by handling it identically to 'fake reboot'. We need to forbid the combination of 'onReboot' -> 'destroy' and 'onPoweroff' -> reboot though as the handling would be hairy and it honetly makes no sense. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b1b85a475f
commit
4ffc807214
|
@ -1747,7 +1747,8 @@ Each of these states allow for the same four possible actions.
|
|||
supported by the libxl hypervisor driver.)
|
||||
|
||||
QEMU/KVM supports the ``on_poweroff`` and ``on_reboot`` events handling the
|
||||
``destroy`` and ``restart`` actions.
|
||||
``destroy`` and ``restart`` actions, but the combiatnion of ``on_poweroff`` set
|
||||
to ``restart`` and ``on_reboot`` set to ``destroy`` is forbidden.
|
||||
|
||||
The ``on_crash`` event supports these additional actions :since:`since 0.8.4` .
|
||||
|
||||
|
|
|
@ -543,7 +543,8 @@ qemuProcessShutdownOrReboot(virQEMUDriver *driver,
|
|||
{
|
||||
qemuDomainObjPrivate *priv = vm->privateData;
|
||||
|
||||
if (priv->fakeReboot) {
|
||||
if (priv->fakeReboot ||
|
||||
vm->def->onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) {
|
||||
g_autofree char *name = g_strdup_printf("reboot-%s", vm->def->name);
|
||||
virThread th;
|
||||
|
||||
|
@ -619,7 +620,8 @@ qemuProcessHandleShutdown(qemuMonitor *mon G_GNUC_UNUSED,
|
|||
|
||||
/* In case of fake reboot qemu shutdown state is transient so don't
|
||||
* change domain state nor send events. */
|
||||
if (!priv->fakeReboot) {
|
||||
if (!priv->fakeReboot ||
|
||||
vm->def->onPoweroff != VIR_DOMAIN_LIFECYCLE_ACTION_RESTART) {
|
||||
VIR_DEBUG("Transitioned guest %s to shutdown state",
|
||||
vm->def->name);
|
||||
virDomainObjSetState(vm,
|
||||
|
|
|
@ -1089,6 +1089,15 @@ qemuValidateLifecycleAction(virDomainLifecycleAction onPoweroff,
|
|||
return -1;
|
||||
}
|
||||
|
||||
/* the qemu driver can't meaningfully handle
|
||||
* onPoweroff -> reboot + onReboot -> destroy */
|
||||
if (onPoweroff == VIR_DOMAIN_LIFECYCLE_ACTION_RESTART &&
|
||||
onReboot == VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("qemu driver doesn't support 'onReboot' set to 'destroy and 'onPoweroff' set to 'reboot'"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue