]> xenbits.xensource.com Git - libvirt.git/commitdiff
Experimental libvirtd upstart job
authorAlan Pevec <apevec@redhat.com>
Fri, 18 Feb 2011 18:45:49 +0000 (19:45 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 18 Apr 2011 09:38:30 +0000 (11:38 +0200)
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

I looked into the possibility to use the upstart script from Ubuntu or
at least getting inspiration from it but that's not possible. "expect
daemon" is a nice thing but it only works if the process is defined with
exec stanza instead of script ... no script. Unfortunately, with exec
stanza environment variables can only be set within upstart script
(i.e., configuration in /etc/sysconfig/libvirtd can't work). Hence, we
need to use script stanza, source sysconfig, and execute libvirtd
without --daemon. For similar reasons we can't use limit stanza and need
to handle DAEMON_COREFILE_LIMIT in job's script.

daemon/Makefile.am
daemon/libvirtd.upstart [new file with mode: 0644]
libvirt.spec.in

index cacec1c47c352a1d034b13142075045b578fa0f1..af71188bf73727ed5aef9cc5ba473ab179fa75d2 100644 (file)
@@ -26,6 +26,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 (file)
index 0000000..fd1d951
--- /dev/null
@@ -0,0 +1,46 @@
+# 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 [!345]
+
+respawn
+
+script
+    LIBVIRTD_CONFIG=
+    LIBVIRTD_ARGS=
+    KRB5_KTNAME=/etc/libvirt/krb5.tab
+
+    if [ -f /etc/sysconfig/libvirtd ]; then
+        . /etc/sysconfig/libvirtd
+    fi
+
+    export QEMU_AUDIO_DRV
+    export SDL_AUDIODRIVER
+    export KRB5_KTNAME
+
+    LIBVIRTD_CONFIG_ARGS=
+    if [ -n "$LIBVIRTD_CONFIG" ]; then
+        LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
+    fi
+
+    # DAEMON_COREFILE_LIMIT from /etc/sysconfig/libvirtd is not handled
+    # automatically
+    if [ -n "$DAEMON_COREFILE_LIMIT" ]; then
+        ulimit -c "$DAEMON_COREFILE_LIMIT"
+    fi
+
+    # Clean up a pidfile that might be left around
+    rm -f /var/run/libvirtd.pid
+
+    mkdir -p /var/cache/libvirt
+    rm -rf /var/cache/libvirt/*
+
+    exec /usr/sbin/libvirtd $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
+end script
+
+post-stop script
+    rm -f $PIDFILE
+    rm -rf /var/cache/libvirt/*
+end script
index 4162fbab54168b6e41383d512207d07e394a5431..bf6b9dfe901b304e34c7ceaedc00875b2328e2ba 100644 (file)
@@ -895,6 +895,7 @@ fi
 %{_sysconfdir}/libvirt/nwfilter/*.xml
 
 %{_sysconfdir}/rc.d/init.d/libvirtd
+%doc daemon/libvirtd.upstart
 %config(noreplace) %{_sysconfdir}/sysconfig/libvirtd
 %config(noreplace) %{_sysconfdir}/libvirt/libvirtd.conf
 %if %{with_dtrace}