Wait for libvirtd socket to be available

There is a race where the libvirtd.pid file appears but the socket has
not (yet) been created; this adds a timeout-loop waiting specifically
for the socket.

Change-Id: Ib2ede3b8d5c49bc650bf8a64cbffc03444bb2dd0
This commit is contained in:
Chris Wedgwood 2017-08-31 17:24:47 +00:00
parent cb8efbd954
commit bfd9cb8655

View File

@ -31,7 +31,20 @@ while [[ ! -f /var/run/libvirtd.pid ]]; do
let TIMEOUT-=1
sleep 1
else
echo "ERROR: Libvirt did not start in time"
echo "ERROR: Libvirt did not start in time (pid file missing)"
exit 1
fi
done
# Even though we see the pid file the socket immediately (this is
# needed for virsh)
TIMEOUT=10
while [[ ! -e /var/run/libvirt/libvirt-sock ]]; do
if [[ ${TIMEOUT} -gt 0 ]]; then
let TIMEOUT-=1
sleep 1
else
echo "ERROR: Libvirt did not start in time (socket missing)"
exit 1
fi
done