diff --git a/cinder/image/image_utils.py b/cinder/image/image_utils.py index a1154967486..4c47b57775c 100644 --- a/cinder/image/image_utils.py +++ b/cinder/image/image_utils.py @@ -297,7 +297,7 @@ def fetch_to_volume_format(context, image_service, return data = qemu_img_info(tmp, run_as_root=run_as_root) - virt_size = data.virtual_size / units.Gi + virt_size = int(math.ceil(float(data.virtual_size) / units.Gi)) # NOTE(xqueralt): If the image virtual size doesn't fit in the # requested volume there is no point on resizing it because it will diff --git a/cinder/tests/unit/test_image_utils.py b/cinder/tests/unit/test_image_utils.py index 3a90c287733..398bd28ae41 100644 --- a/cinder/tests/unit/test_image_utils.py +++ b/cinder/tests/unit/test_image_utils.py @@ -925,7 +925,7 @@ class TestFetchToVolumeFormat(test.TestCase): data = mock_info.return_value data.file_format = volume_format data.backing_file = None - data.virtual_size = 4321 * 1024 ** 3 + data.virtual_size = int(1234.5 * units.Gi) tmp = mock_temp.return_value.__enter__.return_value self.assertRaises(