libraries/libvirt: Added soft_restart() to rc.libvirt

With this patch, "rc.libvirt soft_restart" will kill and restart the
libvirt services without affecting any running virtual machines.
This has been a necessity for the SBo infrastructure given our recent
struggles with libvirt losing dbus connectivity without explanation.

Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
This commit is contained in:
Erik Hanson 2017-06-13 08:09:47 -05:00 committed by Willy Sudiarto Raharjo
parent 277ff139e9
commit b459b3623f
1 changed files with 21 additions and 1 deletions

View File

@ -188,6 +188,23 @@ stop_virtlockd() {
sleep 1
}
soft_restart() {
echo "Soft-restarting libvirt..."
if [ ! -f $LIBVIRTD_PIDFILE ];then
echo "libvirt is not running..."
exit 2
fi
echo "Stopping libvirtd..."
kill -TERM $(cat $LIBVIRTD_PIDFILE)
sleep 3
stop_virtlogd
stop_virtlockd
sleep 1
start_virtlockd
start_virtlogd
start_libvirtd
}
case $1 in
start)
start_virtlockd
@ -208,6 +225,9 @@ restart)
start_virtlogd
start_libvirtd
;;
soft_restart)
soft_restart
;;
guests_shutdown)
guests_shutdown
;;
@ -215,7 +235,7 @@ guests_reboot)
guests_reboot
;;
*)
echo "Usage: $0 (start|stop|restart|guests_shutdown|guests_reboot)"
echo "Usage: $0 (start|stop|restart|soft_restart|guests_shutdown|guests_reboot)"
;;
esac