def add_tapdisk(self, dbg): if self.tapdisk is None: self.tapdisk = tapdisk.create("") self.tapdisk.open(dbg, self.image) if self.dm is not None: self.dm.suspend(dbg) self.dm.reload(dbg, self.tapdisk.block_device()) self.dm.resume(dbg) if self.loop is not None: self.loop.destroy(dbg) self.loop = None self.block = self.dm.block_device() self.save()
def block_device(self): dbg = "Device.block_device" if self.block is None: self.connected = True if isinstance(self.image, image.Raw): self.loop = losetup.find(dbg, self.image.path) if self.loop is None: self.loop = losetup.create(dbg, self.image.path) self.dm = dmsetup.find(dbg, self.loop.block_device()) if self.dm is None: self.dm = dmsetup.create(dbg, self.loop.block_device()) self.block = self.dm.block_device() self.save() return self.block elif isinstance(self.image, image.Vhd): self.tapdisk = tapdisk.create(dbg) self.tapdisk.open(dbg, self.image) self.block = self.tapdisk.block_device() self.save() return self.block else: return self.block