From: Ben Pfaff <blp@nicira.com>
Date: Tue, 23 Feb 2010 22:35:08 +0000 (-0800)
Subject: xenserver: In vif script, tolerate port existing when we (re)add it.
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=867cc7bd395b32a3516112127a04d41d9f1b15fc;p=sliver-openvswitch.git

xenserver: In vif script, tolerate port existing when we (re)add it.

When a Windows VM boots, it initially has "vif" devices.  Then, when
XS Tools loads during boot, those "vif" devices disappear and then are
recreated under the same name.  The vif script is not called to remove
the old devices, but it is called to add the new ones.  It refused to do
this, however, because it saw the new device as having a duplicate name
(because the old was wasn't deleted).

This commit fixes the problem by making the vif script delete the port,
if it exists, before it adds it.

Bug #2425.

CC: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
---

diff --git a/xenserver/etc_xensource_scripts_vif b/xenserver/etc_xensource_scripts_vif
index 4df1ac968..d27bc10da 100755
--- a/xenserver/etc_xensource_scripts_vif
+++ b/xenserver/etc_xensource_scripts_vif
@@ -97,7 +97,7 @@ add_to_bridge()
 			logger -t scripts-vif "Failed to retrieve vif details for vswitch"
 		fi
 
-		$vsctl add-port $bridge $dev $vif_details
+		$vsctl -- --if-exists del-port $dev -- add-port $bridge $dev $vif_details
 	    ;;
     esac