Windows SMBFS: fix VHD/x resize

The os-win vhdutils resize method, by default, treats the requested
size as the maximum VHD/x file size. Considering the size of the
internal metadata, the virtual size of the image will be slightly
smaller.

Resizing an image may fail when the image size is close to the
requested size, in which case the new calculated internal size may be
smaller than the current image internal size.

This fix consists in going back to the old behavior (pre os-win),
ensuring that the new VHD/x internal size always matches the requested
VHD/x size, regardless of the internal metadata overhead (which is
really small anyway).

Change-Id: Ib910ae388e210f33e4cfd87438e8e0ee17020d40
Closes-Bug: #1591988
This commit is contained in:
Lucian Petrut 2016-06-13 15:48:05 +03:00
parent 0f72ff555d
commit 63092924cc
2 changed files with 10 additions and 5 deletions

View File

@ -221,7 +221,8 @@ class WindowsSmbFsTestCase(test.TestCase):
mock.sentinel.block_size)
drv._vhdutils.resize_vhd.assert_called_once_with(
self._FAKE_VOLUME_PATH,
self._FAKE_VOLUME['size'] * units.Gi)
self._FAKE_VOLUME['size'] * units.Gi,
is_file_max_size=False)
def test_copy_volume_from_snapshot(self):
drv = self._smbfs_driver
@ -251,7 +252,8 @@ class WindowsSmbFsTestCase(test.TestCase):
mock.sentinel.new_volume_path)
drv._vhdutils.resize_vhd.assert_called_once_with(
mock.sentinel.new_volume_path,
self._FAKE_VOLUME['size'] * units.Gi)
self._FAKE_VOLUME['size'] * units.Gi,
is_file_max_size=False)
def test_rebase_img(self):
drv = self._smbfs_driver

View File

@ -152,7 +152,8 @@ class WindowsSmbfsDriver(smbfs.SmbfsDriver):
backing_file_full_path)
def _do_extend_volume(self, volume_path, size_gb, volume_name=None):
self._vhdutils.resize_vhd(volume_path, size_gb * units.Gi)
self._vhdutils.resize_vhd(volume_path, size_gb * units.Gi,
is_file_max_size=False)
@remotefs_drv.locked_volume_id_operation
def copy_volume_to_image(self, context, volume, image_service, image_meta):
@ -203,7 +204,8 @@ class WindowsSmbfsDriver(smbfs.SmbfsDriver):
self.configuration.volume_dd_blocksize)
self._vhdutils.resize_vhd(self.local_path(volume),
volume['size'] * units.Gi)
volume['size'] * units.Gi,
is_file_max_size=False)
def _copy_volume_from_snapshot(self, snapshot, volume, volume_size):
"""Copy data from snapshot to destination volume."""
@ -230,4 +232,5 @@ class WindowsSmbfsDriver(smbfs.SmbfsDriver):
self._delete(volume_path)
self._vhdutils.convert_vhd(snapshot_path,
volume_path)
self._vhdutils.resize_vhd(volume_path, volume_size * units.Gi)
self._vhdutils.resize_vhd(volume_path, volume_size * units.Gi,
is_file_max_size=False)