[ovs-dev] create/remove /var/lock/subsys/vswitch on initscript start/stop

Ian Campbell Ian.Campbell at citrix.com
Wed Sep 16 14:56:00 UTC 2009

A lock file in /var/lock/subsys must be created with the same name as
the initscript in order for the stop action to be automatically called
on runlevel change. This is true at least on Red Hat derived systems
such as XenServer where /etc/rcS contains:
        # First, run the KILL scripts.
        for i in /etc/rc$runlevel.d/K* ; do
                check_runlevel "$i" || continue
                # Check if the subsystem is already up.
                [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
                        || continue

(This could potentially expose bugs e.g. in the stop priority for the
script since I think it is likely that the stop action hasn't been
running to now. I haven't closely considered this case yet but vswitch
is currently scheduled at K91vswitch vs K90network which seems correct
at first glance)

diff --git a/xenserver/etc_init.d_vswitch b/xenserver/etc_init.d_vswitch
index 8f0adf7..e63a001 100755
--- a/xenserver/etc_init.d_vswitch
+++ b/xenserver/etc_init.d_vswitch
@@ -269,11 +269,13 @@ function start {
     reload_vswitchd  # ensures ovs-vswitchd has fully read config file.
+    touch /var/lock/subsys/vswitch
 function stop {
+    rm -f /var/lock/subsys/vswitch
 function restart {

More information about the dev mailing list