qemu: Don't unconditionally delete file in qemuOpenFileAs
qemu: Don't unconditionally delete file in qemuOpenFileAs

https://bugzilla.redhat.com/show_bug.cgi?id=1158034

If we're expecting to create a file somewhere and that fails for some
reason during qemuOpenFileAs, then we unlink the path we're attempting
to create leaving no way to determine what the "existing" privileges,
protections, or labels are that caused the failure (open, change owner
and group, change mode, etc.).

Furthermore, if we fall into the path where we'll be opening / creating
the file using VIR_FILE_OPEN_FORK, we need to first unlink/delete the file
we created in the first path; otherwise, the attempt by the child process
to open as some specific user:group may fail because the file was already
created using nfsnobody:nfsnobody. Again, if we didn't create the file we
don't want to blindly delete what already exists. Thus, a second reason for
the original check to set need_unlink to false when we find the file with
CREAT set, but already existing.

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

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