Commit 5997c4b1 by Szeberényi Imre

Saving compressed qcow2 file at template saving

TODO: UI for choosing compreesed / uncompressed file format at template save
parent 662f421c
......@@ -294,9 +294,10 @@ class Disk(object):
if 'qcow' in ftype.lower():
move(downloaded_file, self.get_path())
else:
cmdline = ['qemu-img',
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'convert',
'-O', 'qcow2',
'-m', '4', '-O', 'qcow2',
downloaded_file,
self.get_path()]
subprocess.check_output(cmdline)
......@@ -324,9 +325,12 @@ class Disk(object):
def export(self, task, disk_format, exported_name, upload_link, parent_id):
exported_path = self.get_path() + '.' + disk_format
cmdline = ['qemu-img',
'convert',
'-O', disk_format,
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'convert']
if disk_format == 'qcow2':
cmdline += ['-c']
cmdline += ['-m', '4', '-O', disk_format,
self.get_path(),
exported_path]
......@@ -409,7 +413,8 @@ class Disk(object):
elif self.format == 'raw':
raise NotImplemented()
else:
cmdline = ['qemu-img',
cmdline = ['ionice', '-c', 'idle',
'qemu-img',
'create',
'-b', self.get_base(),
'-f', self.format,
......@@ -420,13 +425,14 @@ class Disk(object):
def merge_disk_with_base(self, task, new_disk, parent_id=None):
proc = None
try:
cmdline = [
'qemu-img', 'convert', self.get_path(),
'-O', new_disk.format, new_disk.get_path()]
cmdline = ['ionice', '-c', 'idle', 'qemu-img', 'convert', '-m', '4']
if new_disk.format == 'qcow2':
cmdline += ['-c']
cmdline += ['-O', new_disk.format, self.get_path(), new_disk.get_path()]
# Call subprocess
logger.debug(
"Merging %s into %s.", self.get_path(),
new_disk.get_path())
"Merging %s into %s. %s", self.get_path(),
new_disk.get_path(), cmdline)
percent = 0
diff_disk = Disk.get(self.dir, self.name)
base_disk = Disk.get(self.dir, self.base_name)
......
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 sign in to comment