From b459b3623fc470ec781254b7633ddf066152774d Mon Sep 17 00:00:00 2001 From: Erik Hanson Date: Tue, 13 Jun 2017 08:09:47 -0500 Subject: 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 --- libraries/libvirt/rc.libvirt | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'libraries/libvirt') diff --git a/libraries/libvirt/rc.libvirt b/libraries/libvirt/rc.libvirt index 18cc374059..376dcb0d9b 100644 --- a/libraries/libvirt/rc.libvirt +++ b/libraries/libvirt/rc.libvirt @@ -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 -- cgit v1.2.3-65-gdbad