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

[Xen-changelog] [xen-unstable] xend: Allow off-line NIC removal



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1236855593 0
# Node ID 8401a1f14759ae05877f184fc409f835eb425167
# Parent  728df5693cd299a3eb1fc140c4c68a94f2838d4b
xend: Allow off-line NIC removal

Match a MAC address so device_destroy can remove off-line NICs.

Signed-off-by: John Levon <john.levon@xxxxxxx>
---
 tools/python/xen/xend/server/netif.py |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletion(-)

diff -r 728df5693cd2 -r 8401a1f14759 tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Thu Mar 12 10:59:19 2009 +0000
+++ b/tools/python/xen/xend/server/netif.py     Thu Mar 12 10:59:53 2009 +0000
@@ -24,7 +24,7 @@ import random
 import random
 import re
 
-from xen.xend import XendOptions
+from xen.xend import XendOptions, sxp
 from xen.xend.server.DevController import DevController
 from xen.xend.XendError import VmError
 from xen.xend.XendXSPolicyAdmin import XSPolicyAdminInstance
@@ -196,3 +196,23 @@ class NetifController(DevController):
                 result[x] = y
 
         return result
+
+    # match a VIF ID from xenstore, or a MAC address stored in the domain 
config
+    def convertToDeviceNumber(self, devid):
+        try:
+            return int(devid)
+        except ValueError:
+            if type(devid) is not str:
+                raise VmError("devid %s is wrong type" % str(devid))
+            try:
+                dev = devid.split('/')[-1]
+                return (int(dev))
+            except ValueError:
+                devs = [d for d in self.vm.info.all_devices_sxpr()
+                    if d[0] == 'vif']
+                for nr in range(len(devs)):
+                    dev_type, dev_info = devs[nr]
+                    if (sxp.child_value(dev_info, 'mac').lower() ==
+                        devid.lower()):
+                        return nr
+                raise VmError("unknown devid %s" % str(devid))

_______________________________________________
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®.