]> xenbits.xensource.com Git - libvirt.git/commitdiff
fixup_resctrlinfo
authorMartin Kletzander <mkletzan@redhat.com>
Wed, 24 Jan 2018 14:47:31 +0000 (15:47 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Thu, 25 Jan 2018 16:16:08 +0000 (17:16 +0100)
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
src/util/virresctrl.c

index f122af205085dcd0686e50e4c964b1eea24e0f01..d439e7792cb9f2602cc0d0b1417ebbd54f76f7f8 100644 (file)
@@ -200,6 +200,8 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
     }
 
     while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
+        VIR_DEBUG("Parsing info type '%s'", ent->d_name);
+
         if (ent->d_type != DT_DIR)
             continue;
 
@@ -207,16 +209,14 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
             continue;
 
         if (virStrToLong_uip(ent->d_name + 1, &endptr, 10, &level) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse resctrl cache info level"));
-            goto cleanup;
+            VIR_DEBUG("Cannot parse resctrl cache info level '%s'", ent->d_name + 1);
+            continue;
         }
 
         type = virResctrlTypeFromString(endptr);
         if (type < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("Cannot parse resctrl cache info type"));
-            goto cleanup;
+            VIR_DEBUG("Cannot parse resctrl cache info type '%s'", endptr);
+            continue;
         }
 
         if (VIR_ALLOC(i_type) < 0)
@@ -259,10 +259,19 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
                          level - resctrl->nlevels + 1) < 0)
             goto cleanup;
 
-        if (!resctrl->levels[level] &&
-            (VIR_ALLOC(resctrl->levels[level]) < 0 ||
-             VIR_ALLOC_N(resctrl->levels[level]->types, VIR_CACHE_TYPE_LAST) < 0))
-            goto cleanup;
+        if (!resctrl->levels[level]) {
+            virResctrlInfoPerTypePtr *types = NULL;
+
+            if (VIR_ALLOC_N(types, VIR_CACHE_TYPE_LAST) < 0)
+                goto cleanup;
+
+            if (VIR_ALLOC(resctrl->levels[level]) < 0) {
+                VIR_FREE(types);
+                goto cleanup;
+            }
+            resctrl->levels[level]->types = types;
+        }
+
         i_level = resctrl->levels[level];
 
         if (i_level->types[type]) {