Fix qemu-img convert image incompatability in alpine linux

Alpine linux runs qemu-img version, where you cannot put
parameter for convert "-f qcow2" in the end of the line,
because it expects location. Parameter must be included
before source and destination.

Change-Id: I7f75eb62c19190c0d523b49dd371d603cafd753f
Closes-Bug: 1634156
This commit is contained in:
Jakub Pavlik 2016-10-17 16:28:01 +02:00
parent 0132cc8c26
commit ce25736643
2 changed files with 4 additions and 3 deletions

View File

@ -649,8 +649,8 @@ disk size: 4.4M
target = 't.qcow2'
self.executes = []
expected_commands = [('qemu-img', 'convert', '-O', 'raw',
't.qcow2.part', 't.qcow2.converted',
'-f', 'qcow2'),
'-f', 'qcow2',
't.qcow2.part', 't.qcow2.converted'),
('rm', 't.qcow2.part'),
('mv', 't.qcow2.converted', 't.qcow2')]
images.fetch_to_raw(context, image_id, target)

View File

@ -96,9 +96,10 @@ def convert_image_unsafe(source, dest, out_format, run_as_root=False):
def _convert_image(source, dest, in_format, out_format, run_as_root):
cmd = ('qemu-img', 'convert', '-O', out_format, source, dest)
cmd = ('qemu-img', 'convert', '-O', out_format)
if in_format is not None:
cmd = cmd + ('-f', in_format)
cmd = cmd + (source, dest)
try:
utils.execute(*cmd, run_as_root=run_as_root)
except processutils.ProcessExecutionError as exp: