[ovs-dev] [PATCH RFC v3] ovs-ctl: Allow selective start for db and switch

Aaron Conole aconole at redhat.com
Thu Mar 24 17:42:29 UTC 2016


Currently, ``ovs-ctl start'' will attempt to start both the DB and
vswitchd. This is quite convenient when the database already has all of
the configuration values required, and when using a single services file
for systemd integration. The same goes for the ``ovs-ctl stop'' command.

However, there are some cases which are not easily covered. The case
where we want to set values in the database prior to starting the
forwarding path, as well as the case of supporting multiple service
files, one per daemon (which is how systemd expects services to look).

Signed-off-by: Aaron Conole <aconole at redhat.com>
---
v2:
It's possible that the way I did the save/restore flows is not the way folks
want it, so please let me know. I did only basic testing with this.
- Renamed the options to --ovs-vswitchd/--no-ovs-vswitchd
  and --ovsdb-server/--no-ovsdb-server
- Updated the force_reload_kmod to abort in case of --no-ovs-vswitchd
- Updated the flow save/restore functions to test for --ovs-vswitchd

v3:
- Updated the ovs-ctl.8 manpage to document the new options in a more
  appropriate way.

 NEWS                 |  3 +++
 utilities/ovs-ctl.8  | 32 ++++++++++++++++++++++++++------
 utilities/ovs-ctl.in | 46 ++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 67 insertions(+), 14 deletions(-)

diff --git a/NEWS b/NEWS
index 81489ab..6083110 100644
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,9 @@ Post-v2.5.0
      bitrot.
    - ovs-appctl:
      * New "vlog/close" command.
+   - ovs-ctl:
+     * Added the ability to selectively start the forwarding and database
+       functions (ovs-vswitchd and ovsdb-server, respectively).
    - ovsdb-server:
      * Remove max number of sessions limit, to enable connection scaling
        testing.
diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index 6a9a544..4b441b4 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -81,7 +81,8 @@ If the database does exist, but it has an obsolete version, it
 upgrades it to the latest schema.
 .
 .IP 3.
-Starts \fBovsdb-server\fR.
+Starts \fBovsdb-server\fR, unless the \fB\-\-no\-ovsdb\-server\fR command
+option is given.
 .
 .IP 4.
 Initializes a few values inside the database.
@@ -96,7 +97,8 @@ that have \fBother_config:transient\fR set to true.
 .
 .PP
 The \fBstart\fR command skips the following step if
-\fBovs\-vswitchd\fR is already running:
+\fBovs\-vswitchd\fR is already running, or if the \fB\-\-no\-ovs\-vswitchd\fR
+command option is given:
 .IP 7.
 Starts \fBovs\-vswitchd\fR.
 .
@@ -238,7 +240,9 @@ taken as relative to \fIdbdir\fR.
 .
 .PP
 The \fBstop\fR command does not unload the Open vSwitch kernel
-modules.
+modules. It can take the same \fB\-\-no\-ovsdb\-server\fR and
+\fB\-\-no\-ovs\-vswitchd\fR options as that of the \fBstart\fR
+command. 
 .
 .PP
 This command does nothing and finishes successfully if the OVS daemons
@@ -314,7 +318,8 @@ particular distribution and installation.)
 .
 .PP
 \fBforce\-kmod\-reload\fR internally stops and starts OVS, so it
-accepts all of the options accepted by the \fBstart\fR command.
+accepts all of the options accepted by the \fBstart\fR command except
+for the \fB\-\-no\-ovs\-vswitchd\fR option.
 .
 .SH "The ``load\-kmod'' command"
 .
@@ -377,8 +382,23 @@ Prints a usage message and exits successfully.
 .
 .SH "OPTIONS"
 .PP
-In addition to the options listed for each command above, this option
-controls the behavior of several of \fBovs\-ctl\fR's commands.
+In addition to the options listed for each command above, these options
+control the behavior of several of \fBovs\-ctl\fR's commands.
+.
+.PP
+By default, \fBovs\-ctl\fR will control the \fBovsdb\-server\fR, and
+the \fBovs\-vswitchd\fR daemons. The following options restrict that control
+to exclude one or the other:
+.
+.IP "\fB\-\-no\-ovsdb-server\fR"
+Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
+\fBrestart\fR should not modify the running status of \fBovsdb\-server\fR.
+.
+.IP "\fB\-\-no\-ovs\-vswitchd\fR"
+Specifies that the \fBovs\-ctl\fR commands \fBstart\fR, \fBstop\fR, and
+\fBrestart\fR should not modify the running status of \fBovs\-vswitchd\fR.
+It is an error to include this option with the \fBforce\-reload\-kmod\fR
+command.
 .
 .SH "EXIT STATUS"
 .
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 7354a47..838bb8a 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -135,7 +135,7 @@ del_transient_ports () {
     done
 }
 
-start_ovsdb () {
+do_start_ovsdb () {
     check_force_cores
 
     if daemon_is_running ovsdb-server; then
@@ -183,6 +183,12 @@ start_ovsdb () {
     fi
 }
 
+start_ovsdb() {
+    if test X"$OVSDB_SERVER" = Xyes; then
+        do_start_ovsdb
+    fi
+}
+
 add_managers () {
     # Now that ovs-vswitchd has started and completed its initial
     # configuration, tell ovsdb-server to conenct to the remote managers.  We
@@ -196,7 +202,7 @@ add_managers () {
 	    db:Open_vSwitch,Open_vSwitch,manager_options
 }
 
-start_forwarding () {
+do_start_forwarding () {
     check_force_cores
 
     insert_mod_if_required || return 1
@@ -223,16 +229,26 @@ start_forwarding () {
     fi
 }
 
+start_forwarding () {
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        do_start_forwarding
+    fi
+}
+
 ## ---- ##
 ## stop ##
 ## ---- ##
 
 stop_ovsdb () {
-    stop_daemon ovsdb-server
+    if test X"$OVSDB_SERVER" = Xyes; then
+        stop_daemon ovsdb-server
+    fi
 }
 
 stop_forwarding () {
-    stop_daemon ovs-vswitchd
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        stop_daemon ovs-vswitchd
+    fi
 }
 
 ## ----------------- ##
@@ -282,12 +298,16 @@ save_interfaces () {
 }
 
 flow_restore_wait () {
-    ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        ovs_vsctl set open_vswitch . other_config:flow-restore-wait="true"
+    fi
 }
 
 flow_restore_complete () {
-    ovs_vsctl --if-exists remove open_vswitch . other_config \
-        flow-restore-wait="true"
+    if test X"$OVS_VSWITCHD" = Xyes; then
+        ovs_vsctl --if-exists remove open_vswitch . other_config \
+                  flow-restore-wait="true"
+    fi
 }
 
 restore_flows () {
@@ -316,6 +336,12 @@ init_restore_scripts () {
 }
 
 force_reload_kmod () {
+
+    if test X"$OVS_VSWITCHD" != Xyes; then
+        log_failure_msg "Reloading of kmod without ovs-vswitchd is an error"
+        exit 1
+    fi
+
     ifaces=`internal_interfaces`
     action "Detected internal interfaces: $ifaces" true
 
@@ -375,7 +401,9 @@ force_reload_kmod () {
 restart () {
     if daemon_is_running ovsdb-server && daemon_is_running ovs-vswitchd; then
         init_restore_scripts
-        save_flows_if_required
+        if test X"$OVS_VSWITCHD" = Xyes; then
+            save_flows_if_required
+        fi
     fi
 
     # Restart the database first, since a large database may take a
@@ -457,6 +485,8 @@ set_defaults () {
     DAEMON_CWD=/
     FORCE_COREFILES=yes
     MLOCKALL=yes
+    OVSDB_SERVER=yes
+    OVS_VSWITCHD=yes
     OVSDB_SERVER_PRIORITY=-10
     OVS_VSWITCHD_PRIORITY=-10
     OVSDB_SERVER_WRAPPER=
-- 
2.8.0.rc2.35.gc2c5f6b.dirty




More information about the dev mailing list