Make the cow file sparse
Add method in Device to list the partitions
Add a "is bootable" flag in Device constructor
size = blockdev('--getsize', sourcedev)
cowfd, cow = tempfile.mkstemp()
self._add_cleanup(os.unlink, cow)
size = blockdev('--getsize', sourcedev)
cowfd, cow = tempfile.mkstemp()
self._add_cleanup(os.unlink, cow)
- dd('if=/dev/zero', 'of=%s' % cow, 'count=%d' % (1024*1024))#(int(size)/4))
+ # Create 1G cow file
+ dd('if=/dev/null', 'of=%s' % cow, 'bs=1k' ,'seek=%d' % (1024*1024))
cowdev = self._losetup(cow)
snapshot = uuid.uuid4().hex
cowdev = self._losetup(cow)
snapshot = uuid.uuid4().hex
class DiskDevice(object):
class DiskDevice(object):
- def __init__(self, disk, device):
+ def __init__(self, disk, device, bootable = True):
+ self.device = device
+ self.is_bootable = bootable
self.partitions_mapped = False
self.magic_number = uuid.uuid4().hex
def list_partitions(self):
self.partitions_mapped = False
self.magic_number = uuid.uuid4().hex
def list_partitions(self):
+ if not self.partitions_mapped:
+ kpartx("-a", "-p", self.magic_number, self.dev)
+ self.disk._cleanup_jobs.append(kpartx, "-d", "-p",
+ self.magic_number, self.dev)
+ self.partitions_mapped = True
+
output = kpartx("-l", "-p", self.magic_number, self.dev)
return [ "/dev/mapper/%s" % x for x in
re.findall('^\S+', str(output), flags=re.MULTILINE)]
def mount(self, partition):
if not self.partitions_mapped:
output = kpartx("-l", "-p", self.magic_number, self.dev)
return [ "/dev/mapper/%s" % x for x in
re.findall('^\S+', str(output), flags=re.MULTILINE)]
def mount(self, partition):
if not self.partitions_mapped:
kpartx("-a", "-p", self.magic_number, self.dev)
self.disk._cleanup_jobs.append(kpartx, "-d", "-p",
self.magic_number, self.dev)
kpartx("-a", "-p", self.magic_number, self.dev)
self.disk._cleanup_jobs.append(kpartx, "-d", "-p",
self.magic_number, self.dev)