'Copy data from src_vol to dest_vol.'

def _copy_volume_data(self, ctxt, src_vol, dest_vol, remote=None):

    LOG.debug('copy_data_between_volumes    %(src)s    ->    %(dest)s.', {'src': src_vol['name'], 'dest': dest_vol['name']})
    attach_encryptor = False
    if volume_types.volume_types_encryption_changed(ctxt, src_vol.volume_type_id, dest_vol.volume_type_id):
        attach_encryptor = True
    properties = utils.brick_get_connector_properties()
    dest_remote = (remote in ['dest', 'both'])
    dest_attach_info = self._attach_volume(ctxt, dest_vol, properties, remote=dest_remote, attach_encryptor=attach_encryptor)
    try:
        src_remote = (remote in ['src', 'both'])
        src_attach_info = self._attach_volume(ctxt, src_vol, properties, remote=src_remote, attach_encryptor=attach_encryptor)
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error('Failed    to    attach    source    volume    for    copy.')
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, remote=dest_remote, attach_encryptor=attach_encryptor, force=True)
    rpcapi = volume_rpcapi.VolumeAPI()
    capabilities = rpcapi.get_capabilities(ctxt, dest_vol.service_topic_queue, False)
    sparse_copy_volume = bool((capabilities and capabilities.get('sparse_copy_volume', False)))
    try:
        size_in_mb = (int(src_vol['size']) * units.Ki)
        vol_utils.copy_volume(src_attach_info['device']['path'], dest_attach_info['device']['path'], size_in_mb, self.configuration.volume_dd_blocksize, sparse=sparse_copy_volume)
    except Exception:
        with excutils.save_and_reraise_exception():
            LOG.error('Failed    to    copy    volume    %(src)s    to    %(dest)s.', {'src': src_vol['id'], 'dest': dest_vol['id']})
    finally:
        try:
            self._detach_volume(ctxt, dest_attach_info, dest_vol, properties, force=True, remote=dest_remote, attach_encryptor=attach_encryptor)
        finally:
            self._detach_volume(ctxt, src_attach_info, src_vol, properties, force=True, remote=src_remote, attach_encryptor=attach_encryptor)
