[meta-virtualization] [PATCH 1/1] libvirtd not properly shutting down on oVirt node install

Zibo Zhao zibo.zhao at windriver.com
Tue Oct 7 09:22:41 PDT 2014


From: Prateek Kumar <prateek.kumar at windriver.com>

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.

Signed-off-by: Prateek Kumar <prateek.kumar at windriver.com>
Signed-off-by: Zibo Zhao <zibo.zhao at windriver.com>
---
 recipes-extended/libvirt/libvirt/libvirtd.sh | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/recipes-extended/libvirt/libvirt/libvirtd.sh b/recipes-extended/libvirt/libvirt/libvirtd.sh
index 29dbf39..c1cd6ee 100755
--- a/recipes-extended/libvirt/libvirt/libvirtd.sh
+++ b/recipes-extended/libvirt/libvirt/libvirtd.sh
@@ -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
-- 
2.1.0



More information about the meta-virtualization mailing list