From c4db75abddbb72ac5f717f6a9266e078b69206a8 Mon Sep 17 00:00:00 2001 From: Xavier Queralt Date: Fri, 22 Nov 2013 10:39:37 +0100 Subject: [PATCH] Pass the size when fetching image in xenapi driver In commit 6e287c0f2bb7d4994d50f1763f412277e4dac6f7 the fetch_to_raw method was changed to accept the volume size so it can fail when the image doesn't fit in the destination volume. In this commit we also updated all the volume drivers to pass the volume size to that method so it could perform the check. The xenapi driver missed that change. This commit updates the xenapi driver to pass the volume size when fetching the image to enable the introduced check. Change-Id: I89bc4b3b1c1e6b06f5c529166cf9ffa1fe600c96 Related-Bug: #1235358 --- cinder/tests/test_xenapi_sm.py | 4 ++-- cinder/volume/drivers/xenapi/sm.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cinder/tests/test_xenapi_sm.py b/cinder/tests/test_xenapi_sm.py index d619d257066..ed01dbaa685 100644 --- a/cinder/tests/test_xenapi_sm.py +++ b/cinder/tests/test_xenapi_sm.py @@ -392,7 +392,7 @@ class DriverTestCase(test.TestCase): mock, drv = self._setup_mock_driver( 'server', 'serverpath', '/var/run/sr-mount') - volume = dict(provider_location='sr-uuid/vdi-uuid') + volume = dict(provider_location='sr-uuid/vdi-uuid', size=1) context = MockContext('token') mock.StubOutWithMock(driver.image_utils, 'fetch_to_raw') @@ -402,7 +402,7 @@ class DriverTestCase(test.TestCase): simple_context('device')) driver.image_utils.fetch_to_raw( - context, 'image_service', 'image_id', 'device') + context, 'image_service', 'image_id', 'device', size=1) mock.ReplayAll() drv._use_image_utils_to_pipe_bytes_to_volume( diff --git a/cinder/volume/drivers/xenapi/sm.py b/cinder/volume/drivers/xenapi/sm.py index c2f53777d92..f19d48054c9 100644 --- a/cinder/volume/drivers/xenapi/sm.py +++ b/cinder/volume/drivers/xenapi/sm.py @@ -175,7 +175,8 @@ class XenAPINFSDriver(driver.VolumeDriver): image_utils.fetch_to_raw(context, image_service, image_id, - device) + device, + size=volume['size']) def _use_glance_plugin_to_copy_image_to_volume(self, context, volume, image_service, image_id):