WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xend: fix vbd/tapdisk device destruction

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xend: fix vbd/tapdisk device destruction
From: "Ryan O'Connor" <rjo@xxxxxxxxx>
Date: Tue, 23 Jun 2009 10:10:39 -0700
Cc: Dutch Meyer <dmeyer@xxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Delivery-date: Tue, 23 Jun 2009 10:12:06 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
blktap2 devices attach as a regular 'vbd' rather than a 'tap' device.
Accordingly, Xend should use 'vbd' as the device class of blktap2 devices. This
patch determines the appropriate device class by reading the 'type' field of the
backend's xenstore entry.

Signed-off-by: Ryan O'Connor <rjo@xxxxxxxxx>

diff -r 3c7536d6b583 -r 3f100fc620fd tools/python/xen/xend/XendDomainInfo.py
--- a/tools/python/xen/xend/XendDomainInfo.py   Tue Jun 23 17:27:01 2009 +0100
+++ b/tools/python/xen/xend/XendDomainInfo.py   Tue Jun 23 10:09:20 2009 -0700
@@ -1244,13 +1244,33 @@ class XendDomainInfo:
                     dev_num += 1
             return sxprs
 
-    def getBlockDeviceClass(self, devid):
-        # To get a device number from the devid,
-        # we temporarily use the device controller of VBD.
-        dev = self.getDeviceController('vbd').convertToDeviceNumber(devid)
-        dev_info = self._getDeviceInfo_vbd(dev)
-        if dev_info:
-            return dev_info[0]
+    def getBlockDeviceClass(self, devid, deviceClass=False):
+        backendType = 'vbd'
+
+        # For backwards compatability, we may have to get deviceClass ourselves
+        if not deviceClass:
+            t = xstransact("%s/device" % self.dompath)
+            for devclass in XendDevices.valid_devices():
+                if devid in t.list(devclass):
+                    deviceClass = devclass
+                    break
+            t.abort()
+
+        try:
+            # Note: deviceClass may be incorrect, so we cannot trust 
readBackend
+            # or readFrontend from the Device Controller to succeed
+            backendPath = xstransact.Read("%s/device/%s/%s"
+                                          % (self.dompath, deviceClass, devid),
+                                          "backend")
+            backendType = xstransact.Read(backendPath, "type")
+        except Exception, ex:
+            # we can probably just assume the block device is a VBD
+            log.debug("error reading backend for device (%s): %s", devid, 
str(ex))
+
+        if backendType == 'tap':
+            return 'tap'
+        else:
+            return 'vbd'
 
     def _getDeviceInfo_vif(self, mac):
         for dev_type, dev_info in self.info.all_devices_sxpr():
@@ -2217,7 +2237,7 @@ class XendDomainInfo:
                             # may possibly be "tap". Just in case, verify
                             # device class.
                             devid = dev.split('/')[-1]
-                            true_devclass = self.getBlockDeviceClass(devid)
+                            true_devclass = self.getBlockDeviceClass(devid, 
devclass)
                         log.debug("Removing %s", dev);
                         self.destroyDevice(true_devclass, dev, False);
                     except:

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