]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virfile: Fix error path for forked virFileRemove
authorJohn Ferlan <jferlan@redhat.com>
Wed, 30 Sep 2015 21:37:27 +0000 (17:37 -0400)
committerCole Robinson <crobinso@redhat.com>
Thu, 11 Feb 2016 19:37:28 +0000 (14:37 -0500)
commit58e916ffaf72a9bf848e66cfa84f3f70f12438c5
treea7d224c53dafaa1c1b1e2f82ded66e6e061bbc75
parent74909e9648366f9fc6cd7a29a71791d29f04ff7f
virfile: Fix error path for forked virFileRemove

As it turns out the caller in this case expects a return < 0 for failure
and to get/use "errno" rather than using the negative of returned status.
Again different than the create path.

If someone "deleted" a file from the pool without using virsh vol-delete,
then the unlink/rmdir would return an error (-1) and set errno to ENOENT.
The caller checks errno for ENOENT when determining whether to throw an
error message indicating the failure.  Without the change, the error
message is:

error: Failed to delete vol $vol
error: cannot unlink file '/$pathto/$vol': Success

This patch thus allows the fork path to follow the non-fork path
where unlink/rmdir return -1 and errno.

(cherry picked from commit cb19cff468432e55366014658f405066ce06c2f2)
src/util/virfile.c