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
|