Fix vhd image conversion regression
A recent change introduced a regression: due to a wrong assignment, we're no longer passing qemu-img the right format when converting images to "vhd". Note that it expects the legacy "vpc" name. This change addresses this issue. Closes-Bug: #1757244 Change-Id: If7a2e3470403b45eff69dcf69b67615bb982a4eb
This commit is contained in:
parent
63aa5a9a7f
commit
cf9ea3fdb3
|
@ -145,7 +145,7 @@ def _get_qemu_convert_cmd(src, dest, out_format, src_format=None,
|
|||
|
||||
if out_format == 'vhd':
|
||||
# qemu-img still uses the legacy vpc name
|
||||
out_format == 'vpc'
|
||||
out_format = 'vpc'
|
||||
|
||||
cmd = ['qemu-img', 'convert', '-O', out_format]
|
||||
|
||||
|
|
|
@ -260,6 +260,24 @@ class TestConvertImage(test.TestCase):
|
|||
'-O', out_format, '-t', 'none',
|
||||
source, dest, run_as_root=True)
|
||||
|
||||
@mock.patch('cinder.image.image_utils.qemu_img_info')
|
||||
@mock.patch('cinder.utils.execute')
|
||||
@mock.patch('cinder.utils.is_blk_device', return_value=False)
|
||||
@mock.patch('cinder.volume.utils.check_for_odirect_support')
|
||||
def test_convert_to_vhd(self, mock_check_odirect, mock_isblk,
|
||||
mock_exec, mock_info):
|
||||
source = mock.sentinel.source
|
||||
dest = mock.sentinel.dest
|
||||
out_format = "vhd"
|
||||
mock_info.return_value.virtual_size = 1048576
|
||||
|
||||
output = image_utils.convert_image(source, dest, out_format)
|
||||
self.assertIsNone(output)
|
||||
# Qemu uses the legacy "vpc" format name, instead of "vhd".
|
||||
mock_exec.assert_called_once_with('qemu-img', 'convert',
|
||||
'-O', 'vpc',
|
||||
source, dest, run_as_root=True)
|
||||
|
||||
|
||||
class TestResizeImage(test.TestCase):
|
||||
@mock.patch('cinder.utils.execute')
|
||||
|
|
Loading…
Reference in New Issue