Blob Blame History Raw
From a6d413271d9e0467ba32561bb1b8f3412bdfdc69 Mon Sep 17 00:00:00 2001
Message-Id: <a6d413271d9e0467ba32561bb1b8f3412bdfdc69@dist-git>
From: Peter Krempa <pkrempa@redhat.com>
Date: Wed, 24 Sep 2014 11:01:30 +0200
Subject: [PATCH] storage: Improve error message when traversing backing chains

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

Report also the name of the parent file and uid/gid used to access it to
help debugging broken storage configurations.

(cherry picked from commit eaf43e37552e6b40468b72b2819d9b7a5874095e)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/storage/storage_driver.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c3b29c4..7c518bf 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -2781,6 +2781,7 @@ virStorageFileChown(virStorageSourcePtr src,
 /* Recursive workhorse for virStorageFileGetMetadata.  */
 static int
 virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
+                                 virStorageSourcePtr parent,
                                  uid_t uid, gid_t gid,
                                  bool allow_probe,
                                  bool report_broken,
@@ -2805,9 +2806,18 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
         return -1;
 
     if (virStorageFileAccess(src, F_OK) < 0) {
-        virReportSystemError(errno,
-                             _("Cannot access backing file %s"),
-                             src->path);
+        if (src == parent) {
+            virReportSystemError(errno,
+                                 _("Cannot access storage file '%s' "
+                                   "(as uid:%d, gid:%d)"),
+                                 src->path, (int)uid, (int)gid);
+        } else {
+            virReportSystemError(errno,
+                                 _("Cannot access backing file '%s' "
+                                   "of storage file '%s' (as uid:%d, gid:%d)"),
+                                 src->path, parent->path, (int)uid, (int)gid);
+        }
+
         goto cleanup;
     }
 
@@ -2848,7 +2858,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
     else
         backingStore->format = backingFormat;
 
-    if ((ret = virStorageFileGetMetadataRecurse(backingStore,
+    if ((ret = virStorageFileGetMetadataRecurse(backingStore, parent,
                                                 uid, gid,
                                                 allow_probe, report_broken,
                                                 cycle)) < 0) {
@@ -2912,7 +2922,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
     if (src->format <= VIR_STORAGE_FILE_NONE)
         src->format = allow_probe ? VIR_STORAGE_FILE_AUTO : VIR_STORAGE_FILE_RAW;
 
-    ret = virStorageFileGetMetadataRecurse(src, uid, gid,
+    ret = virStorageFileGetMetadataRecurse(src, src, uid, gid,
                                            allow_probe, report_broken, cycle);
 
     virHashFree(cycle);
-- 
2.1.1