[libvirt] [PATCH] RFC: experimental libvirtd upstart job

Serge E. Hallyn serge.hallyn at canonical.com
Fri Feb 18 21:48:29 UTC 2011


Quoting apevec at gmail.com (apevec at gmail.com):
> From: Alan Pevec <apevec at redhat.com>
> 
> To install it, disable libvirtd sysv initscript:
>     chkconfig libvirtd off
>     service libvirtd stop
> 
> and enable libvirtd upstart job:
>     cp  /usr/share/doc/libvirt-*/libvirtd.upstart \
>         /etc/init/libvirtd.conf
>     initctl reload-configuration
>     initctl start libvirtd
> 
> Test:
>     initctl status libvirtd
> libvirtd start/running, process 3929
>     killall -9 libvirtd
>     initctl status libvirtd
> libvirtd start/running, process 4047
> ---
>  daemon/Makefile.am      |    1 +
>  daemon/libvirtd.upstart |   47 +++++++++++++++++++++++++++++++++++++++++++++++
>  libvirt.spec.in         |    1 +
>  3 files changed, 49 insertions(+), 0 deletions(-)
>  create mode 100644 daemon/libvirtd.upstart
> 
> diff --git a/daemon/Makefile.am b/daemon/Makefile.am
> index cdf0f75..a4ebcf8 100644
> --- a/daemon/Makefile.am
> +++ b/daemon/Makefile.am
> @@ -27,6 +27,7 @@ EXTRA_DIST =						\
>  	remote_generate_stubs.pl			\
>  	libvirtd.conf					\
>  	libvirtd.init.in				\
> +	libvirtd.upstart				\
>  	libvirtd.policy-0				\
>  	libvirtd.policy-1				\
>  	libvirtd.sasl					\
> diff --git a/daemon/libvirtd.upstart b/daemon/libvirtd.upstart
> new file mode 100644
> index 0000000..40d5fa3
> --- /dev/null
> +++ b/daemon/libvirtd.upstart
> @@ -0,0 +1,47 @@
> +# libvirtd upstart job
> +#
> +# XXX wait for rc to get all dependent initscripts started
> +# from sysv libvirtd initscript: Required-Start: $network messagebus
> +start on stopped rc RUNLEVEL=[345]
> +stop on runlevel [016]
> +respawn
> +# default rate limit is 10x/5s
> +#respawn limit 10 5
> +
> +# DAEMON_COREFILE_LIMIT in /etc/sysconfig/libvirtd doesn't have effect
> +# must set resource limits here
> +#limit core unlimited unlimited
> +
> +# documented http://upstart.ubuntu.com/wiki/Stanzas#pid
> +# but not accepted by upstart-0.6.5
> +#pid file /var/run/libvirtd.pid
> +
> +env PIDFILE=/var/run/libvirtd.pid
> +
> +script
> +	LIBVIRTD_CONFIG=
> +	LIBVIRTD_ARGS=
> +	KRB5_KTNAME=/etc/libvirt/krb5.tab
> +	
> +	test -f /etc/sysconfig/libvirtd && . /etc/sysconfig/libvirtd
> +	
> +	export QEMU_AUDIO_DRV
> +	export SDL_AUDIODRIVER
> +	
> +	LIBVIRTD_CONFIG_ARGS=
> +	if [ -n "$LIBVIRTD_CONFIG" ]
> +	then
> +		LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
> +	else
> +		true
> +	fi
> +	
> +	mkdir -p /var/cache/libvirt
> +	rm -rf /var/cache/libvirt/*
> +	KRB5_KTNAME=$KRB5_KTNAME /usr/sbin/libvirtd $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
> +end script
> +
> +post-stop script
> +	rm -f $PIDFILE
> +	rm -rf /var/cache/libvirt/*
> +end script

Hi,

If you're using upstart, then why use your own pidfile? FWIW, attached is
the upstart script used in Ubuntu:

=============================================
description "libvirt daemon"
author "Dustin Kirkland <kirkland at canonical.com>"

start on runlevel [2345]
stop on runlevel [!2345]

expect daemon
respawn

env libvirtd_opts="-d"
env start_libvirtd="yes"
pre-start script
	[ -r /etc/default/libvirt-bin ] && . /etc/default/libvirt-bin
	[ ! "x$start_libvirtd" = "xyes" ] && { stop; exit 0; }
	mkdir -p /var/run/libvirt
	# Clean up a pidfile that might be left around
	rm -f /var/run/libvirtd.pid
end script

# If you used to set $libvirtd_opts in /etc/default/libvirt-bin,
# change the 'exec' line here instead.
exec /usr/sbin/libvirtd $libvirtd_opts
=============================================

In order to play nicely with libcgroup, we're also testing
the following job to ship with libcgroup:

=============================================
# libvirt-cgred-wait
start on starting libvirt-bin
stop on started cgred or stopped cgred

task
normal exit 2
script
  status cgred | grep -q "start/running" && exit 0
  start cgred || true
  sleep 3600
end script
=============================================

thanks,
-serge




More information about the libvir-list mailing list