Virtual size should get ceiling of image

In function fetch_to_volume_format when converting the image virtual
size to Gb, we need to get ceiling of image size. Otherwise the
following comparing between image virtual size and volume size would
not work if image virtual size is 2.75Gb and volume size is 2Gb.
This patch fixes it by getting ceiling image virtual size in function
fetch_to_volume_format.

Change-Id: Id9ea080c109b7cc5068a991eb07b6c9bd1147c77
Closes-Bug: #1590242
This commit is contained in:
yuyafei 2016-06-08 15:05:02 +08:00
parent 42db20e90a
commit 1730f2dd56
2 changed files with 2 additions and 2 deletions

View File

@ -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

View File

@ -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(