[Ovirt-devel] [PATCH node] Causes ovirt-post to wait for libvirt to finish initializing.

Perry Myers pmyers at redhat.com
Tue Mar 24 22:00:03 UTC 2009


Darryl L. Pierce wrote:
> It will give libvirt up to 10 seconds to complete initializing before
> giving up. This overcomes a bug where ovirt-post fails to detect
> hardware virtualization due to libvirt having not finished initializing.
> 
> Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
> ---
>  scripts/ovirt-post |   14 ++++++++++++++
>  1 files changed, 14 insertions(+), 0 deletions(-)
> 
> diff --git a/scripts/ovirt-post b/scripts/ovirt-post
> index 2f0483b..6135119 100755
> --- a/scripts/ovirt-post
> +++ b/scripts/ovirt-post
> @@ -11,6 +11,20 @@
>  . /etc/init.d/ovirt-functions
>  
>  start() {
> +    # wait for libvirt to finish initializing
> +    local count=0
> +    while true; do
> +	if [ -r /var/run/libvirt/libvirt-sock ]; then
> +	    break
> +	elif [ "$count" == "10" ]; then
> +	    log "Libvirt did not initialize in time..."
> +	    exit 1
> +	else
> +	    log "Waiting for libvirt to finish initializing..."
> +	    count=$(xpr $count + 1)
> +	    sleep 1
> +	fi
> +    done

Waiting for 10 seconds seems somewhat arbitrary.  What if the machine is 
really slow and it takes more than 10 seconds for it to come up?  Maybe 
that's unlikely, it's just that relying on sleep always scares me.

Perry




More information about the ovirt-devel mailing list