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