|
|
c1c534 |
From eaeaf49524c3b7f26afb86bdeddba8d86bce4790 Mon Sep 17 00:00:00 2001
|
|
|
c1c534 |
Message-Id: <eaeaf49524c3b7f26afb86bdeddba8d86bce4790@dist-git>
|
|
|
c1c534 |
From: Martin Kletzander <mkletzan@redhat.com>
|
|
|
c1c534 |
Date: Wed, 31 Jan 2018 16:32:39 +0100
|
|
|
c1c534 |
Subject: [PATCH] util: Don't check if entries under /sys/fs/resctrl/(info/)
|
|
|
c1c534 |
are directories
|
|
|
c1c534 |
|
|
|
c1c534 |
We are skipping non-directories under /sys/fs/resctrl/(info/) since those are not
|
|
|
c1c534 |
interesting for us. However in tests it can sometimes happen that ent->d_type
|
|
|
c1c534 |
is 0 instead of 4 (DT_DIR) for directories.
|
|
|
c1c534 |
|
|
|
c1c534 |
I've seen it fail on two machines. Different machines, different systems, I
|
|
|
c1c534 |
cannot reproduce it even using the same setup. So one of the ways how to work
|
|
|
c1c534 |
around this is call stat() on it. The other one is not checking if it is a
|
|
|
c1c534 |
directory since we'll find out eventually when we want to read some files
|
|
|
c1c534 |
underneath it.
|
|
|
c1c534 |
|
|
|
c1c534 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
c1c534 |
(cherry picked from commit f2e16994f7d660a54daba1059441dc0dcf4d9cbd)
|
|
|
c1c534 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
c1c534 |
|
|
|
c1c534 |
https://bugzilla.redhat.com/show_bug.cgi?id=1289368
|
|
|
c1c534 |
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
|
|
c1c534 |
---
|
|
|
c1c534 |
src/util/virresctrl.c | 27 +++++++++++++++------------
|
|
|
c1c534 |
1 file changed, 15 insertions(+), 12 deletions(-)
|
|
|
c1c534 |
|
|
|
c1c534 |
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
|
|
|
c1c534 |
index 684cb22fd8..42876c6e2b 100644
|
|
|
c1c534 |
--- a/src/util/virresctrl.c
|
|
|
c1c534 |
+++ b/src/util/virresctrl.c
|
|
|
c1c534 |
@@ -410,10 +410,6 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
c1c534 |
|
|
|
c1c534 |
while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
|
|
|
c1c534 |
VIR_DEBUG("Parsing info type '%s'", ent->d_name);
|
|
|
c1c534 |
-
|
|
|
c1c534 |
- if (ent->d_type != DT_DIR)
|
|
|
c1c534 |
- continue;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
if (ent->d_name[0] != 'L')
|
|
|
c1c534 |
continue;
|
|
|
c1c534 |
|
|
|
c1c534 |
@@ -436,19 +432,29 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
|
|
|
c1c534 |
rv = virFileReadValueUint(&i_type->control.max_allocation,
|
|
|
c1c534 |
SYSFS_RESCTRL_PATH "/info/%s/num_closids",
|
|
|
c1c534 |
ent->d_name);
|
|
|
c1c534 |
- if (rv == -2)
|
|
|
c1c534 |
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c1c534 |
- _("Cannot get num_closids from resctrl cache info"));
|
|
|
c1c534 |
- if (rv < 0)
|
|
|
c1c534 |
+ if (rv == -2) {
|
|
|
c1c534 |
+ /* The file doesn't exist, so it's unusable for us,
|
|
|
c1c534 |
+ * but we can scan further */
|
|
|
c1c534 |
+ VIR_WARN("The path '" SYSFS_RESCTRL_PATH "/info/%s/num_closids' "
|
|
|
c1c534 |
+ "does not exist",
|
|
|
c1c534 |
+ ent->d_name);
|
|
|
c1c534 |
+ } else if (rv < 0) {
|
|
|
c1c534 |
+ /* Other failures are fatal, so just quit */
|
|
|
c1c534 |
goto cleanup;
|
|
|
c1c534 |
+ }
|
|
|
c1c534 |
|
|
|
c1c534 |
rv = virFileReadValueString(&i_type->cbm_mask,
|
|
|
c1c534 |
SYSFS_RESCTRL_PATH
|
|
|
c1c534 |
"/info/%s/cbm_mask",
|
|
|
c1c534 |
ent->d_name);
|
|
|
c1c534 |
- if (rv == -2)
|
|
|
c1c534 |
+ if (rv == -2) {
|
|
|
c1c534 |
+ /* If the previous file exists, so should this one. Hence -2 is
|
|
|
c1c534 |
+ * fatal in this case as well (errors out in next condition) - the
|
|
|
c1c534 |
+ * kernel interface might've changed too much or something else is
|
|
|
c1c534 |
+ * wrong. */
|
|
|
c1c534 |
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
|
c1c534 |
_("Cannot get cbm_mask from resctrl cache info"));
|
|
|
c1c534 |
+ }
|
|
|
c1c534 |
if (rv < 0)
|
|
|
c1c534 |
goto cleanup;
|
|
|
c1c534 |
|
|
|
c1c534 |
@@ -1169,9 +1175,6 @@ virResctrlAllocGetUnused(virResctrlInfoPtr resctrl)
|
|
|
c1c534 |
goto error;
|
|
|
c1c534 |
|
|
|
c1c534 |
while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH)) > 0) {
|
|
|
c1c534 |
- if (ent->d_type != DT_DIR)
|
|
|
c1c534 |
- continue;
|
|
|
c1c534 |
-
|
|
|
c1c534 |
if (STREQ(ent->d_name, "info"))
|
|
|
c1c534 |
continue;
|
|
|
c1c534 |
|
|
|
c1c534 |
--
|
|
|
c1c534 |
2.16.1
|
|
|
c1c534 |
|