After thinking some time about this, I'm not convinced anymore that libvirtd itself should handle this.
If libvirtd is started and finds the stale pid file there. It could check if the process with the pid contained in that file is running anymore. But even if libvirtd crashed, in the meantime another process could have got exactly the same pid.
Fortunately, upstart _knows_ that libvirtd just crashed and is not longer running anymore, and can therefore safely remove the pidfile (example below). What do you think about this?
E.g.:
1 description "libvirt daemon"
2 author "Dustin Kirkland <email address hidden>"
3
4 start on runlevel [2345]
5 stop on runlevel [!2345]
6
7 expect daemon
8 respawn
9
10 pre-start script
11 mkdir -p /var/run/libvirt
12 if [ -e /var/run/libvirtd.pid ]; then
13 rm /var/run/libvirtd.pid
14 fi
15 end script
16
17 # if you used to set $libvirtd_opts in /etc/default/libvirt-bin, you can change the
18 # 'exec' line here instead
19 exec /usr/sbin/libvirtd -d
After thinking some time about this, I'm not convinced anymore that libvirtd itself should handle this.
If libvirtd is started and finds the stale pid file there. It could check if the process with the pid contained in that file is running anymore. But even if libvirtd crashed, in the meantime another process could have got exactly the same pid.
Fortunately, upstart _knows_ that libvirtd just crashed and is not longer running anymore, and can therefore safely remove the pidfile (example below). What do you think about this?
E.g.:
1 description "libvirt daemon" libvirtd. pid ]; then libvirtd. pid libvirt- bin, you can change the
2 author "Dustin Kirkland <email address hidden>"
3
4 start on runlevel [2345]
5 stop on runlevel [!2345]
6
7 expect daemon
8 respawn
9
10 pre-start script
11 mkdir -p /var/run/libvirt
12 if [ -e /var/run/
13 rm /var/run/
14 fi
15 end script
16
17 # if you used to set $libvirtd_opts in /etc/default/
18 # 'exec' line here instead
19 exec /usr/sbin/libvirtd -d