[libvirt] [PATCH 1/3] util: Report an error when virFileResolveLinkHelper's lstat fails

Erik Skultety posted 3 patches 8 years, 7 months ago
There is a newer version of this series
[libvirt] [PATCH 1/3] util: Report an error when virFileResolveLinkHelper's lstat fails
Posted by Erik Skultety 8 years, 7 months ago
During investigation of [1] I saw nothing in the logs that would help me
get to the root cause. Then I found out that we don't log anything when
lstat fails. Sure, doesn't happen often, but if it happens we should
reflect that in the logs to prevent spurious behaviour.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1463285

Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 src/util/virfile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/util/virfile.c b/src/util/virfile.c
index d444b32f8..6bbcc3d15 100644
--- a/src/util/virfile.c
+++ b/src/util/virfile.c
@@ -1560,8 +1560,10 @@ virFileResolveLinkHelper(const char *linkpath,
      * directories, if linkpath is absolute and the basename is
      * already a non-symlink.  */
     if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) {
-        if (lstat(linkpath, &st) < 0)
+        if (lstat(linkpath, &st) < 0) {
+            virReportSystemError(errno, "%s", linkpath);
             return -1;
+        }
 
         if (!S_ISLNK(st.st_mode))
             return VIR_STRDUP_QUIET(*resultpath, linkpath) < 0 ? -1 : 0;
-- 
2.13.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 1/3] util: Report an error when virFileResolveLinkHelper's lstat fails
Posted by Peter Krempa 8 years, 7 months ago
On Tue, Jun 20, 2017 at 17:03:30 +0200, Erik Skultety wrote:
> During investigation of [1] I saw nothing in the logs that would help me
> get to the root cause. Then I found out that we don't log anything when
> lstat fails. Sure, doesn't happen often, but if it happens we should
> reflect that in the logs to prevent spurious behaviour.
> 
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=1463285
> 
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/util/virfile.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/util/virfile.c b/src/util/virfile.c
> index d444b32f8..6bbcc3d15 100644
> --- a/src/util/virfile.c
> +++ b/src/util/virfile.c
> @@ -1560,8 +1560,10 @@ virFileResolveLinkHelper(const char *linkpath,
>       * directories, if linkpath is absolute and the basename is
>       * already a non-symlink.  */
>      if (IS_ABSOLUTE_FILE_NAME(linkpath) && !intermediatePaths) {
> -        if (lstat(linkpath, &st) < 0)
> +        if (lstat(linkpath, &st) < 0) {
> +            virReportSystemError(errno, "%s", linkpath);
>              return -1;
> +        }

NACK, this function is designed not to report errors. It's even
documented so. Some other callers even report their own errors.

At most a VIR_DEBUG is appropriate here.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list