We are skipping non-directories under /sys/fs/resctrl/info/ since those are not interesting for us. However in tests it can sometimes happen that ent->d_type is 0 instead of 4 (DT_DIR) for directories. I've seen it fail on two machines. Different machines, different systems, I cannot reproduce it even using the same setup. So one of the ways how to work around this is call stat() on it. Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/util/virresctrl.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index 684cb22fd8a2..12dda76f9d33 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -409,11 +409,32 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl) } while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) { + struct stat st; + char *path = NULL; + VIR_DEBUG("Parsing info type '%s'", ent->d_name); + if (virAsprintf(&path, SYSFS_RESCTRL_PATH "/info/%s", ent->d_name) < 0) + continue; + + if (stat(path, &st) < 0) { + virReportSystemError(errno, _("Cannot stat '%s'"), path); + VIR_FREE(path); + continue; + } + VIR_FREE(path); + + /* + * So this doesn't work on some machines when we're mocking syscalls in tests + if (ent->d_type != DT_DIR) continue; + But the following does, for some reason. + */ + if ((st.st_mode & S_IFMT) != S_IFDIR) + continue; + if (ent->d_name[0] != 'L') continue; -- 2.16.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list