Q: Guest shutdown from UPS power off signal with "virsh"

Hi ! I have a shell script running on all servers which intercepts power off signal (in case of power failure). Is it safe to use direct KVM “virsh” commands to force guest shutdown on oVirt nodes, bypassing oVirt engine ? “shutdown now” directly on oVirt nodes v4.2.6 takes an enormous amount of time because for whatever reason guests can’t be suspended. My nodes installed on CentOS 7.5, I’m not using pre-packaged version because each consecutive upgrade simply wipes out all my mods. Thanks in advance. Andrei PS. I found this script to shutdown KVM guests: *************************************** #!/bin/bash # https://ask.fedoraproject.org/en/question/8796/make-libvirt-to-shutdown-my-g... LIST_VM=`virsh list | grep running | awk '{print $2}'` TIMEOUT=90 DATE=`date -R` LOGFILE="/var/log/shutdownkvm.log" if [ "x$activevm" = "x" ] then exit 0 fi for activevm in $LIST_VM do PIDNO=`ps ax | grep $activevm | grep kvm | cut -c 1-6 | head -n1` echo "$DATE : Shutdown : $activevm : $PIDNO" >> $LOGFILE virsh shutdown $activevm > /dev/null COUNT=0 while [ "$COUNT" -lt "$TIMEOUT" ] do ps --pid $PIDNO > /dev/null if [ "$?" -eq "1" ] then COUNT=110 else sleep 5 COUNT=$(($COUNT+5)) fi done if [ $COUNT -lt 110 ] then echo "$DATE : $activevm not successful force shutdown" >> $LOGFILE virsh destroy $activevm > /dev/null fi done

On Thu, Nov 8, 2018 at 4:26 PM Andrei Verovski <andreil1@starlett.lv> wrote:
Hello, did you evaluated shutting down vms via ansible or ovirt sdk? https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/stop_vm.p... https://docs.ansible.com/ansible/2.7/modules/ovirt_vm_module.html#examples Luca -- "E' assurdo impiegare gli uomini di intelligenza eccellente per fare calcoli che potrebbero essere affidati a chiunque se si usassero delle macchine" Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716) "Internet è la più grande biblioteca del mondo. Ma il problema è che i libri sono tutti sparsi sul pavimento" John Allen Paulos, Matematico (1945-vivente) Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenzetto.luca@gmail.com>
participants (2)
-
Andrei Verovski
-
Luca 'remix_tj' Lorenzetto