'Copy the volume to the specified image.'

def _copy_volume_to_image(self, context, volume, image_service, image_meta):

    active_file = self.get_active_image_from_info(volume)
    active_file_path = os.path.join(self._local_volume_dir(volume), active_file)
    info = self._qemu_img_info(active_file_path, volume.name)
    backing_file = info.backing_file
    root_file_fmt = info.file_format
    tmp_params = {'prefix': ('%s.temp_image.%s' % (volume.id, image_meta['id'])), 'suffix': '.img'}
    with image_utils.temporary_file(**tmp_params) as temp_path:
        if (backing_file or (root_file_fmt != 'raw')):
            image_utils.convert_image(active_file_path, temp_path, 'raw', run_as_root=self._execute_as_root)
            upload_path = temp_path
        else:
            upload_path = active_file_path
        image_utils.upload_volume(context, image_service, image_meta, upload_path, run_as_root=self._execute_as_root)
