[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Resurrect vifname xm create vif option support. This was present in earlier



# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 95f84e37c90d573dd01cc29db5b81ffb5f86f84a
# Parent  7256d2425fa795556903b706beed870014c48406
Resurrect vifname xm create vif option support.  This was present in earlier
versions of Xen, and allows one to name a vif when it is created.  This is
useful for integration with IP accounting packages, for example.

Closes bug #439.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r 7256d2425fa7 -r 95f84e37c90d tools/examples/vif-common.sh
--- a/tools/examples/vif-common.sh      Tue Dec 13 17:31:35 2005
+++ b/tools/examples/vif-common.sh      Tue Dec 13 18:06:03 2005
@@ -51,6 +51,17 @@
 # Check presence of compulsory args.
 XENBUS_PATH="${XENBUS_PATH:?}"
 vif="${vif:?}"
+
+
+vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "")
+if [ "$vifname" ]
+then
+  if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null
+  then
+    do_or_die ip link set "$vif" name "$vifname"
+  fi
+  vif="$vifname"
+fi
 
 
 function frob_iptable()
diff -r 7256d2425fa7 -r 95f84e37c90d tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Tue Dec 13 17:31:35 2005
+++ b/tools/python/xen/xend/server/netif.py     Tue Dec 13 18:06:03 2005
@@ -74,9 +74,10 @@
         typ = sxp.child_value(config, 'type')
         if typ == 'ioemu':
             return (None,{},{})
-        bridge = sxp.child_value(config, 'bridge')
-        mac    = sxp.child_value(config, 'mac')
-        ipaddr = _get_config_ipaddr(config)
+        bridge  = sxp.child_value(config, 'bridge')
+        mac     = sxp.child_value(config, 'mac')
+        vifname = sxp.child_value(config, 'vifname')
+        ipaddr  = _get_config_ipaddr(config)
 
         devid = self.allocateDeviceID()
 
@@ -90,6 +91,8 @@
             back['ip'] = ' '.join(ipaddr)
         if bridge:
             back['bridge'] = bridge
+        if vifname:
+            back['vifname'] = vifname
 
         front = { 'handle' : "%i" % devid,
                   'mac'    : mac }
@@ -102,9 +105,8 @@
 
         result = DevController.configuration(self, devid)
 
-        (script, ip, bridge, mac) = self.readBackend(devid,
-                                                     'script', 'ip', 'bridge',
-                                                     'mac')
+        (script, ip, bridge, mac, typ, vifname) = self.readBackend(
+            devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname')
 
         if script:
             result.append(['script',
@@ -116,5 +118,9 @@
             result.append(['bridge', bridge])
         if mac:
             result.append(['mac', mac])
+        if typ:
+            result.append(['type', typ])
+        if vifname:
+            result.append(['vifname', vifname])
 
         return result

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.