diff --git a/drivers/blktap2.py b/drivers/blktap2.py index ea1eea316..a2474399d 100755 --- a/drivers/blktap2.py +++ b/drivers/blktap2.py @@ -1184,6 +1184,12 @@ class SymLink(Link): def readlink(self): return os.readlink(self.path()) + def realpath(self): + return os.path.realpath(self.path()) + + def is_block(self): + return S_ISBLK(os.stat(self.realpath()).st_mode) + def symlink(self): return self.path @@ -1487,6 +1493,13 @@ def attach(self, sr_uuid, vdi_uuid, writable, activate = False): {"rdonly": not writable}) self.BackendLink.from_uuid(sr_uuid, vdi_uuid).mklink(dev_path) + # Decide whether to use tapdisk3 or blkback + if (self.target.get_vdi_type() == "aio") and \ + (self.target.vdi.sr.handles("lvm")): + self.xenstore_data['backend-kind'] = 'vbd' + else: + self.xenstore_data['backend-kind'] = 'vbd3' + # Return backend/ link back_path = self.BackendLink.from_uuid(sr_uuid, vdi_uuid).path() struct = { 'params': back_path, @@ -1571,8 +1584,14 @@ def _activate_locked(self, sr_uuid, vdi_uuid, options): break raise + # Link backend directly to RAW LV VDIs + phy_dev = self.PhyLink.from_uuid(sr_uuid, vdi_uuid) + if phy_dev.is_block() and self.target.get_vdi_type() == "aio": + dev_path = phy_dev.realpath() + # Link result to backend/ self.BackendLink.from_uuid(sr_uuid, vdi_uuid).mklink(dev_path) + return True def _activate(self, sr_uuid, vdi_uuid, options):