Extend libvirt-guests to shutdown only persistent VMs

At the moment, there is no configuration option for the libvirt-guests
service that allows users to define that only persistent virtual machines
should be shutdown on host shutdown.

Currently, the service config allows to choose between two ON_SHUTDOWN
actions that are executed on running virtual machines when the host goes
down: shutdown, suspend.
The ON_SHUTDOWN action should be orthogonal to the type of the virtual
machine. However, the existing implementation, does not suspend
transient virtual machines.
This is the matrix of actions that is executed on virtual machines based
on the configured ON_SHUTDOWN action and the type of a virtual machine.

         | persistent | transient
shutdown | shutdown   | shutdown (what we want to change)
suspend  | suspend    | nothing

Add config option PERSISTENT_ONLY to libvirt-guests config that allows
users to define if the ON_SHUTDOWN action should be applied only on
persistent virtual machines. PERSISTENT_ONLY can be set to true, false,
default. The default option will implement the already existing logic.

Case 1: PERSISTENT_ONLY=default
         | persistent | transient
shutdown | shutdown   | shutdown
suspend  | suspend    | nothing

Case 2: PERSISTENT_ONLY=true
         | persistent | transient
shutdown | shutdown   | nothing
suspend  | suspend    | nothing

Case 3: PERSISTENT_ONLY=false
         | persistent | transient
shutdown | shutdown   | shutdown
suspend  | suspend    | suspend

Signed-off-by: Benjamin Taubmann <benjamin.taubmann@nutanix.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Benjamin Taubmann
2024-03-26 11:37:21 +00:00
committed by Michal Privoznik
parent 5138dd2478
commit a39dd25715
2 changed files with 52 additions and 7 deletions

View File

@@ -113,6 +113,28 @@ The following variables are supported:
this requires guest agent with support for time synchronization
running in the guest. By default, this functionality is turned off.
- PERSISTENT_ONLY=default
Defines what type of guest virtual machine ON_SHUTDOWN action is applied to
* default
This implements the already existing default behavior.
If ON_SHUTDOWN action is shutdown, transient and persistent guest virtual
machines are asked to shutdown.
If ON_SHUTDOWN action is suspend, only persistent guest virtual machines
are asked to suspend.
* true
ON_SHUTDOWN action is executed only on persistent guest virtual machines.
Transient guest virtual machines are not affected.
* false
ON_SHUTDOWN action is executed on persistent and transient guest virtual
machines.
BUGS
====