diff options
| author | Ben Pfaff <blp@nicira.com> | 2011-02-08 16:43:40 -0800 |
|---|---|---|
| committer | Ben Pfaff <blp@nicira.com> | 2011-02-08 16:43:40 -0800 |
| commit | f7a122fc2457f805fd0906f4368ea42d2ea55584 (patch) | |
| tree | 7c57abcb6768dbc8d27b08f18477921daf6dfa55 /xenserver/etc_init.d_openvswitch | |
| parent | e051b42c418e0c0e6627ae78d2e86d2d8b24cfb2 (diff) | |
| download | openvswitch-f7a122fc2457f805fd0906f4368ea42d2ea55584.tar.gz | |
xenserver: Introduce "force-reload-kmod" to reload kernel module.
Running "service openvswitch force-reload-kmod" will now save the kernel
configuration state of Open vSwitch interfaces, stop the vswitch, unload
the kernel module, reload the kernel module, restart the vswitch, and
restore kernel configuration state. It is a reasonably safe way to upgrade
or downgrade the Open vSwitch kernel module on a running system.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'xenserver/etc_init.d_openvswitch')
| -rwxr-xr-x | xenserver/etc_init.d_openvswitch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/xenserver/etc_init.d_openvswitch b/xenserver/etc_init.d_openvswitch index a9e51de24..a08a95dbd 100755 --- a/xenserver/etc_init.d_openvswitch +++ b/xenserver/etc_init.d_openvswitch @@ -445,6 +445,51 @@ function restart { fi } +function internal_interfaces { + # Outputs a list of internal interfaces: + # + # - There is an internal interface for every bridge, whether it has + # an Interface record or not and whether the Interface record's + # 'type' is properly set. + # + # - There is an internal interface for each Interface record whose + # 'type' is 'internal'. + # + # But ignore interfaces that don't really exist. + for d in `(ovs-vsctl --bare \ + -- --columns=name find Interface type=internal \ + -- list-br) | sort -u` + do + if test -e "/sys/class/net/$d"; then + printf "%s " "$d" + fi + done +} + +function force_reload_kmod { + ifaces=$(internal_interfaces) + action "Configured internal interfaces: $ifaces" true + + stop + + script=$(mktemp) + action "Save interface configuration to $script" true + if ! /usr/share/openvswitch/scripts/ovs-save $ifaces > $script; then + warning "Failed to save configuration, not replacing kernel module" + start + exit 1 + fi + chmod +x $script + + action "Destroy datapaths" remove_all_dp + + remove_modules + + start + + action "Restore interface configuration from $script" $script +} + case "$1" in start) start @@ -480,6 +525,9 @@ case "$1" in /usr/sbin/ovs-vswitchd -V /usr/sbin/ovs-brcompatd -V ;; + force-reload-kmod) + force_reload_kmod + ;; help) printf "openvswitch [start|stop|restart|reload|force-reload|status|version]\n" ;; |
