From 1ca57d2254b39bc708c314e3ff59d1ff2bdcba4d Mon Sep 17 00:00:00 2001 From: John Lightsey Date: Sun, 28 Jul 2019 11:45:11 -0500 Subject: [PATCH] Use configured volume format during image to volume conversions. The NFS volume driver and other subclasses of the remotefs volume driver will now fetch images in the same disk format they use when creating standalone volumes. --- cinder/volume/drivers/remotefs.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index 613d32da0..54afad365 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -444,13 +444,20 @@ class RemoteFSDriver(driver.BaseVD): def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" - image_utils.fetch_to_raw(context, - image_service, - image_id, - self.local_path(volume), - self.configuration.volume_dd_blocksize, - size=volume.size, - run_as_root=self._execute_as_root) + volume_format = 'raw' + if getattr(self.configuration, + self.driver_prefix + '_qcow2_volumes', False): + volume_format = 'qcow2' + + image_utils.fetch_to_volume_format( + context, + image_service, + image_id, + self.local_path(volume), + volume_format, + self.configuration.volume_dd_blocksize, + size=volume.size, + run_as_root=self._execute_as_root) # NOTE (leseb): Set the virtual size of the image # the raw conversion overwrote the destination file -- 2.20.1