virfile: Refactor safezero
virfile: Refactor safezero

Currently build conditionals decide which of two safezero() functions
should be built - either the posix_fallocate() or mmap() with a fallback
to a slower safewrite() algorithm in order to preallocate space in a raw file.

This patch will refactor safezero to utilize static functions for either
posix_fallocate or mmap/safewrite. The build conditional still exist, but
are only for shorter sections of code.

The posix_fallocate path will make use of the ret/errno setting to contain
the logic for safezero to decide whether it needs to fallback to other
algorithms. A return of -1 with errno not changed will indicate the conditional
is not present; otherwise, a return of -1 with errno change indicates the
call was made and it failed (no functional difference to current algorithm).

The mmap/safewrite option changes only slightly to handle the ftruncate
failure for mmap. That is, previously if the ftruncate failed, there was
no fallback to the slow safewrite option.

Signed-off-by: John Ferlan <87558058f6f829e5ec976c8ef960720af4ff9c7d@redhat.com>

crobinso/libvirt,crobinso/libvirt,zippy2/libvirt,fabianfreyer/libvirt,libvirt/libvirt,zippy2/libvirt,shugaoye/libvirt,elmarco/libvirt,nertpinx/libvirt,andreabolognani/libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,datto/libvirt,jardasgit/libvirt,nertpinx/libvirt,datto/libvirt,jardasgit/libvirt,libvirt/libvirt,jardasgit/libvirt,crobinso/libvirt,jfehlig/libvirt,rlaager/libvirt,nertpinx/libvirt,olafhering/libvirt,fabianfreyer/libvirt,agx/libvirt,rlaager/libvirt,VenkatDatta/libvirt,taget/libvirt,datto/libvirt,agx/libvirt,VenkatDatta/libvirt,VenkatDatta/libvirt,nertpinx/libvirt,elmarco/libvirt,shugaoye/libvirt,rlaager/libvirt,libvirt/libvirt,agx/libvirt,libvirt/libvirt,fabianfreyer/libvirt,elmarco/libvirt,datto/libvirt,olafhering/libvirt,rlaager/libvirt,crobinso/libvirt,fabianfreyer/libvirt,jfehlig/libvirt,eskultety/libvirt,taget/libvirt,shugaoye/libvirt,eskultety/libvirt,jardasgit/libvirt,taget/libvirt,olafhering/libvirt,andreabolognani/libvirt,agx/libvirt,jfehlig/libvirt,agx/libvirt,andreabolognani/libvirt,VenkatDatta/libvirt,olafhering/libvirt,shugaoye/libvirt,eskultety/libvirt,taget/libvirt,shugaoye/libvirt,elmarco/libvirt,eskultety/libvirt,nertpinx/libvirt,elmarco/libvirt,jfehlig/libvirt,taget/libvirt,fabianfreyer/libvirt,zippy2/libvirt,zippy2/libvirt,eskultety/libvirt,andreabolognani/libvirt,rlaager/libvirt,datto/libvirt,jardasgit/libvirt