render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c1c534
From ff96b6f60e7062da45f24366db871c3ce675892e Mon Sep 17 00:00:00 2001
c1c534
Message-Id: <ff96b6f60e7062da45f24366db871c3ce675892e@dist-git>
c1c534
From: Martin Kletzander <mkletzan@redhat.com>
c1c534
Date: Wed, 31 Jan 2018 16:32:28 +0100
c1c534
Subject: [PATCH] fixup_resctrlinfo
c1c534
c1c534
https://bugzilla.redhat.com/show_bug.cgi?id=1289368
c1c534
c1c534
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
c1c534
(cherry picked from commit 434848d7dca9d1a7838ab53bbfdcf580ef7f2cc2)
c1c534
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
c1c534
---
c1c534
 src/util/virresctrl.c | 29 +++++++++++++++++++----------
c1c534
 1 file changed, 19 insertions(+), 10 deletions(-)
c1c534
c1c534
diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c
c1c534
index f122af2050..d439e7792c 100644
c1c534
--- a/src/util/virresctrl.c
c1c534
+++ b/src/util/virresctrl.c
c1c534
@@ -200,6 +200,8 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
c1c534
     }
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
@@ -207,16 +209,14 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
c1c534
             continue;
c1c534
 
c1c534
         if (virStrToLong_uip(ent->d_name + 1, &endptr, 10, &level) < 0) {
c1c534
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
c1c534
-                           _("Cannot parse resctrl cache info level"));
c1c534
-            goto cleanup;
c1c534
+            VIR_DEBUG("Cannot parse resctrl cache info level '%s'", ent->d_name + 1);
c1c534
+            continue;
c1c534
         }
c1c534
 
c1c534
         type = virResctrlTypeFromString(endptr);
c1c534
         if (type < 0) {
c1c534
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
c1c534
-                           _("Cannot parse resctrl cache info type"));
c1c534
-            goto cleanup;
c1c534
+            VIR_DEBUG("Cannot parse resctrl cache info type '%s'", endptr);
c1c534
+            continue;
c1c534
         }
c1c534
 
c1c534
         if (VIR_ALLOC(i_type) < 0)
c1c534
@@ -259,10 +259,19 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
c1c534
                          level - resctrl->nlevels + 1) < 0)
c1c534
             goto cleanup;
c1c534
 
c1c534
-        if (!resctrl->levels[level] &&
c1c534
-            (VIR_ALLOC(resctrl->levels[level]) < 0 ||
c1c534
-             VIR_ALLOC_N(resctrl->levels[level]->types, VIR_CACHE_TYPE_LAST) < 0))
c1c534
-            goto cleanup;
c1c534
+        if (!resctrl->levels[level]) {
c1c534
+            virResctrlInfoPerTypePtr *types = NULL;
c1c534
+
c1c534
+            if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0)
c1c534
+                goto cleanup;
c1c534
+
c1c534
+            if (VIR_ALLOC(resctrl->levels[level]) < 0) {
c1c534
+                VIR_FREE(types);
c1c534
+                goto cleanup;
c1c534
+            }
c1c534
+            resctrl->levels[level]->types = types;
c1c534
+        }
c1c534
+
c1c534
         i_level = resctrl->levels[level];
c1c534
 
c1c534
         if (i_level->types[type]) {
c1c534
-- 
c1c534
2.16.1
c1c534