Skip to contentSkip to conversation

libvirtd not properly shutting down on oVirt node install

PATCH Superseded Zibo Zhao 1 participant 1 message Oct 7, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zibo Zhao

author
#0 lore raw

PATCH 1/1 libvirtd not properly shutting down on oVirt node install

From: Prateek Kumar <[email protected]>

On registering the ovirt node form the ovirt engine web interface the ovirt node installation goes fine but the node will suffer a "communication failure" and the status of the node will fail to go up status. Its due to the race condition in libvirtd shutdown where pid file is deleted before the real libvirtd process get terminated.
The issue is fixed by making sure the libvirtd process is terminated before deteting the pid file and providing sufficient delay.

---
 recipes-extended/libvirt/libvirt/libvirtd.sh | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
recipes-extended/libvirt/libvirt/libvirtd.sh +19 -3
index 29dbf39..c1cd6ee 100755
@@ -86,10 +86,26 @@ case "$1" in
                 log_end_msg $?
                 ;;
         stop)
+                if [ -f /var/run/libvirtd.pid ]; then
+                        pid=$(cat /var/run/libvirtd.pid)
+                fi
                 log_begin_msg "Stopping virtualization library daemon: libvirtd"
-		start-stop-daemon --stop --quiet --retry 3 --exec /usr/sbin/libvirtd --pidfile /var/run/libvirtd.pid
-                log_end_msg $?
-                rm -f /var/run/libvirtd.pid
+                start-stop-daemon --stop --quiet --retry 3 --exec /usr/sbin/libvirtd --pidfile /var/run/libvirtd.pid
+                CHECK=0
+                k=0
+                while /bin/kill -0 $pid >/dev/null 2>&1; do
+                        k=$(($k+1))
+                        sleep 1
+                        if [ $k -ge 60 ]; then
+                                log_end_msg "Stopping the libvertd timedout"
+                                CHECK=1
+                                break
+                        fi				
+                done
+                if [ $CHECK -eq 0 ]; then
+                        log_end_msg "Removing the pid $PID"
+                        rm -f /var/run/libvirtd.pid
+                fi
                 ;;
         restart)
                 $0 stop
Signature · 1 line
2.1.0