[ovs-dev] [PATCH] xenserver: Fix bugs related to using xe-switch-network-backend in spec file.

Justin Pettit jpettit at nicira.com
Wed May 11 07:40:59 UTC 2011


Commit daf2ebb (xenserver: Use xe-switch-network-stack in RPM spec
file.) changed the spec file to use xe-switch-network-backend instead of
directly modifying "/etc/xensource/network.conf".  It incorrectly
assumed that the command was in the search path.  It also didn't take
into account that the command will remove the "openvswitch" service with
chkconfig.  This commit fixes those errors.

(For consistency, xe-switch-network-backend should also remove
"openvswitch-xapi-update" service.  I will file an issue with the
XenServer guys about that.)
---
 xenserver/openvswitch-xen.spec |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/xenserver/openvswitch-xen.spec b/xenserver/openvswitch-xen.spec
index 7409fdf..cf4f943 100644
--- a/xenserver/openvswitch-xen.spec
+++ b/xenserver/openvswitch-xen.spec
@@ -226,7 +226,7 @@ done
 
 if [ "$1" = "1" ]; then    # $1 = 1 for install
     # Configure system to use Open vSwitch
-    xe-switch-network-backend vswitch
+    /opt/xensource/bin/xe-switch-network-backend vswitch
 else    # $1 = 2 for upgrade
 
     mode=$(cat /etc/xensource/network.conf)
@@ -248,8 +248,15 @@ depmod %{xen_version}
 
 %preun
 if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
+    # Configure system to use bridge
+    /opt/xensource/bin/xe-switch-network-backend bridge
+
+    # The "openvswitch" service should have been removed from
+    # "xe-switch-network-backend bridge".
     for s in openvswitch openvswitch-xapi-update; do
-        chkconfig --del $s || printf "Could not remove $s init script."
+        if chkconfig --list $s >/dev/null 2>&1; then
+            chkconfig --del $s || printf "Could not remove $s init script."
+        fi
     done
 fi
 
@@ -296,16 +303,16 @@ if [ "$1" = "0" ]; then     # $1 = 0 for uninstall
         /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyc \
         /usr/share/openvswitch/scripts/InterfaceReconfigureVSwitch.pyo
 
+    # Remove saved XenServer scripts directory, but only if it's empty.
+    # (This command cannot be at the end of "postun" scriplet, since it
+    # will have a non-zero exit code, which will be propagated out of
+    # the scriplet and cause uninstallation to fail.)
+    rmdir -p /usr/lib/openvswitch/xs-saved 2>/dev/null
+
     # Remove all configuration files
     rm -f /etc/openvswitch/conf.db
     rm -f /etc/sysconfig/openvswitch
     rm -f /etc/openvswitch/vswitchd.cacert
-
-    # Remove saved XenServer scripts directory, but only if it's empty
-    rmdir -p /usr/lib/openvswitch/xs-saved 2>/dev/null
-
-    # Configure system to use bridge
-    xe-switch-network-backend bridge
 fi
 
 %files
-- 
1.7.1




More information about the dev mailing list