VirtualDomain: Properly migrate VMs on node shutdown (bsc#1074014)
There are three actors in sum controlling the VMs:
- pacemaker/VirtualDomain RA
- issuing cluster resource operations,
- libvirtd
- executing the given commands,
- systemd and systemd-machined
- manages scope units of running VMs.
During shutdown both libvirtd and systemd-machined termination runs
concurrently with pacemaker so it cannot properly communicate with
libvirtd and terminate the machines (e.g. stopped scope unit would turn
the VM off instead of migration that's usually intended in a HA
cluster).
We add ordering dependency both on libvirtd.service and
virt-guest-shutdown.target so that pacemaker is terminated *before* the
other mechanisms would stop the VMs. Thus it can invoke appropriate
resource action on the running VM.
In order the ordering against virt-guest-shutdown.target to work its
stop job must be in the shutdown transaction thus we start the target
when activating a VM. The target is ordering-only, it doesn't activate
any other units.
Ref: #1087