ovs-ctl: Add load-kmod command
authorSimon Horman <horms@verge.net.au>
Wed, 7 Sep 2011 01:10:30 +0000 (10:10 +0900)
committerBen Pfaff <blp@nicira.com>
Thu, 8 Sep 2011 19:53:45 +0000 (12:53 -0700)
On Debian there is a need for the init scripts to die gracefully
if module insertion fails. In such a case it is desirable to print
some sort of informative message.

By adding the load-kmod sub-command to ovs-ctl init scripts
may try to load modules and take appropriate action on failure
or then try to start the daemons.

utilities/ovs-ctl.8
utilities/ovs-ctl.in

index 8d8088a..0e41162 100644 (file)
@@ -27,6 +27,10 @@ ovs\-ctl \- OVS startup helper script
 \fBovs\-ctl version
 .br
 \fBovs\-ctl
 \fBovs\-ctl version
 .br
 \fBovs\-ctl
+[\fIoptions\fR]
+\fBload\-kmod\fR
+.br
+\fBovs\-ctl
 \fB\-\-system\-id=random\fR|\fIuuid\fR
 [\fIoptions\fR]
 \fBforce\-reload\-kmod\fR
 \fB\-\-system\-id=random\fR|\fIuuid\fR
 [\fIoptions\fR]
 \fBforce\-reload\-kmod\fR
@@ -263,6 +267,20 @@ have to be restarted after completing the above procedure.
 \fBforce\-kmod\-reload\fR internally stops and starts OVS, so it
 accepts all of the options accepted by the \fBstart\fR command.
 .
 \fBforce\-kmod\-reload\fR internally stops and starts OVS, so it
 accepts all of the options accepted by the \fBstart\fR command.
 .
+.SH "The ``load\-kmod'' command"
+.
+.PP
+The \fBload\-kmod\fR command loads the openvswitch kernel modules if
+they are not already loaded. This operation also occurs as part of
+the \fBstart\fR command. The motivation for providing the \fBload\-kmod\fR
+command is to allow errors when loading modules to be handled separatetly
+from other errors that may occur when running the \fBstart\fR command.
+.
+.PP
+By default the \fBload\-kmod\fR command attempts to load the
+openvswitch_mod kernel module. If the \fB\-\-brcompat\fR option is
+specified then the brcompat_mod kernel module is also loaded.
+.
 .SH "The ``enable\-protocol'' command"
 .
 .PP
 .SH "The ``enable\-protocol'' command"
 .
 .PP
index c102419..8788e4a 100755 (executable)
@@ -56,6 +56,13 @@ insert_brcompat_mod_if_required () {
     action "Inserting brcompat module" modprobe brcompat_mod
 }
 
     action "Inserting brcompat module" modprobe brcompat_mod
 }
 
+insert_mod_if_required () {
+    insert_openvswitch_mod_if_required || return 1
+    if test X"$BRCOMPAT" = Xyes; then
+        insert_brcompat_mod_if_required || return 1
+    fi
+}
+
 ovs_vsctl () {
     ovs-vsctl --no-wait --timeout=5 "$@"
 }
 ovs_vsctl () {
     ovs-vsctl --no-wait --timeout=5 "$@"
 }
@@ -160,10 +167,7 @@ start () {
         ulimit -Sc 67108864
     fi
 
         ulimit -Sc 67108864
     fi
 
-    insert_openvswitch_mod_if_required || return 1
-    if test X"$BRCOMPAT" = Xyes; then
-        insert_brcompat_mod_if_required || return 1
-    fi
+    insert_mod_if_required || return 1
 
     if daemon_is_running ovsdb-server; then
        log_success_msg "ovsdb-server is already running"
 
     if daemon_is_running ovsdb-server; then
        log_success_msg "ovsdb-server is already running"
@@ -394,6 +398,7 @@ Commands:
   stop               stop Open vSwitch daemons
   status             check whether Open vSwitch daemons are running
   version            print versions of Open vSwitch daemons
   stop               stop Open vSwitch daemons
   status             check whether Open vSwitch daemons are running
   version            print versions of Open vSwitch daemons
+  load-kmod          insert modules if not already present
   force-reload-kmod  save OVS network device state, stop OVS, unload kernel
                      module, reload kernel module, start OVS, restore state
   enable-protocol    enable protocol specified in options with iptables
   force-reload-kmod  save OVS network device state, stop OVS, unload kernel
                      module, reload kernel module, start OVS, restore state
   enable-protocol    enable protocol specified in options with iptables
@@ -418,7 +423,7 @@ Less important options for "start" and "force-reload-kmod":
   --ovs-vswitchd-priority=NICE   set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY)
   --ovs-brcompatd-priority=NICE  set ovs-brcompatd's niceness (default: $OVS_BRCOMPATD_PRIORITY)
 
   --ovs-vswitchd-priority=NICE   set ovs-vswitchd's niceness (default: $OVS_VSWITCHD_PRIORITY)
   --ovs-brcompatd-priority=NICE  set ovs-brcompatd's niceness (default: $OVS_BRCOMPATD_PRIORITY)
 
-Options for "start", "force-reload-kmod", "status", and "version":
+Options for "start", "force-reload-kmod", "load-kmod", "status", and "version":
   --brcompat         enable Linux bridge compatibility module and daemon
 
 File location options:
   --brcompat         enable Linux bridge compatibility module and daemon
 
 File location options:
@@ -548,6 +553,9 @@ case $command in
     force-reload-kmod)
        force_reload_kmod
         ;;
     force-reload-kmod)
        force_reload_kmod
         ;;
+    load-kmod)
+        insert_mod_if_required
+        ;;
     enable-protocol)
         enable_protocol
         ;;
     enable-protocol)
         enable_protocol
         ;;