提交 eaf43e37 编写于 作者: P Peter Krempa

storage: Improve error message when traversing backing chains

Report also the name of the parent file and uid/gid used to access it to
help debugging broken storage configurations.
上级 639a0098
...@@ -2781,6 +2781,7 @@ virStorageFileChown(virStorageSourcePtr src, ...@@ -2781,6 +2781,7 @@ virStorageFileChown(virStorageSourcePtr src,
/* Recursive workhorse for virStorageFileGetMetadata. */ /* Recursive workhorse for virStorageFileGetMetadata. */
static int static int
virStorageFileGetMetadataRecurse(virStorageSourcePtr src, virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
virStorageSourcePtr parent,
uid_t uid, gid_t gid, uid_t uid, gid_t gid,
bool allow_probe, bool allow_probe,
bool report_broken, bool report_broken,
...@@ -2805,9 +2806,18 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, ...@@ -2805,9 +2806,18 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
return -1; return -1;
if (virStorageFileAccess(src, F_OK) < 0) { if (virStorageFileAccess(src, F_OK) < 0) {
virReportSystemError(errno, if (src == parent) {
_("Cannot access backing file %s"), virReportSystemError(errno,
src->path); _("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; goto cleanup;
} }
...@@ -2848,7 +2858,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src, ...@@ -2848,7 +2858,7 @@ virStorageFileGetMetadataRecurse(virStorageSourcePtr src,
else else
backingStore->format = backingFormat; backingStore->format = backingFormat;
if ((ret = virStorageFileGetMetadataRecurse(backingStore, if ((ret = virStorageFileGetMetadataRecurse(backingStore, parent,
uid, gid, uid, gid,
allow_probe, report_broken, allow_probe, report_broken,
cycle)) < 0) { cycle)) < 0) {
...@@ -2912,7 +2922,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src, ...@@ -2912,7 +2922,7 @@ virStorageFileGetMetadata(virStorageSourcePtr src,
if (src->format <= VIR_STORAGE_FILE_NONE) if (src->format <= VIR_STORAGE_FILE_NONE)
src->format = allow_probe ? VIR_STORAGE_FILE_AUTO : VIR_STORAGE_FILE_RAW; 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); allow_probe, report_broken, cycle);
virHashFree(cycle); virHashFree(cycle);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册