'Return a volume to do backup.
To backup a snapshot, create a temp volume from the snapshot and
back it up.
Otherwise to backup an in-use volume, create a temp volume and
back it up.'

def _get_backup_volume_temp_volume(self, context, backup):

    volume = objects.Volume.get_by_id(context, backup.volume_id)
    snapshot = None
    if backup.snapshot_id:
        snapshot = objects.Snapshot.get_by_id(context, backup.snapshot_id)
    LOG.debug('Creating    a    new    backup    for    volume    %s.', volume['name'])
    temp_vol_ref = None
    device_to_backup = volume
    if snapshot:
        temp_vol_ref = self._create_temp_volume_from_snapshot(context, volume, snapshot)
        backup.temp_volume_id = temp_vol_ref.id
        backup.save()
        device_to_backup = temp_vol_ref
    else:
        previous_status = volume.get('previous_status')
        if (previous_status == 'in-use'):
            temp_vol_ref = self._create_temp_cloned_volume(context, volume)
            backup.temp_volume_id = temp_vol_ref.id
            backup.save()
            device_to_backup = temp_vol_ref
    return device_to_backup
