[libvirt] [PATCH 2/3] libvirt-guests: Wait for libirtd to initialize

Eric Blake eblake at redhat.com
Fri Feb 21 17:28:07 UTC 2014


On 02/21/2014 05:32 AM, Michal Privoznik wrote:

s/libirtd/libvirtd/ in subject

> I've noticed that in some cases systemd was quick enough and even
> if libvirt-guests.service is marked to be started after the
> libvirtd.service my guests were not resumed as
> libvirt-guests.sh failed to connect. This is because of a
> simple fact: systemd correctly starts libvirt-guests after it
> execs libvirtd. However, the daemon is not able to accept
> connections right from the start. It's doing some
> initialization which may take ages. This problem is not limited
> to systemd only, indeed. Any init system that is able to startup
> services in parallel (e.g. OpenRC) may run into this situation.
> The fix is to try connecting not only once, but continuously a few
> times with a small sleep in between tries.
> 

> +++ b/tools/libvirt-guests.sh.in
> @@ -37,6 +37,8 @@ SHUTDOWN_TIMEOUT=300
>  PARALLEL_SHUTDOWN=0
>  START_DELAY=0
>  BYPASS_CACHE=0
> +CONNECT_RETRIES=10
> +RETRIES_SLEEP=.5

fractional second sleep is a GNU sleep extension; it is not portable to
all platforms.

> +        fi
> +        sleep ${RETRIES_SLEEP}

You may need to rework this to be a bit more robust to a sleep failure,
if sleep refuses to parse the fractional second.


-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140221/f077a6e5/attachment-0001.sig>


More information about the libvir-list mailing list