Commit 8fed77f7 authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Make the cow file size equal to the original media

The size of the cow file was hardcoded to 1G. This was buggy, because
for a big image, the resize operation could fill up the cow file and
parent a95930f8
......@@ -114,12 +114,12 @@ class Disk(object):
# Take a snapshot and return it to the user
self.out.output("Snapshotting media source...", False)
size = blockdev('--getsize', sourcedev)
size = blockdev('--getsz', sourcedev)
cowfd, cow = tempfile.mkstemp()
self._add_cleanup(os.unlink, cow)
# Create 1G cow sparse file
dd('if=/dev/null', 'of=%s' % cow, 'bs=1k', 'seek=%d' % (1024 * 1024))
# Create cow sparse file
dd('if=/dev/null', 'of=%s' % cow, 'bs=512', 'seek=%d' % int(size))
cowdev = self._losetup(cow)
snapshot = uuid.uuid4().hex
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment