From ff96b6f60e7062da45f24366db871c3ce675892e Mon Sep 17 00:00:00 2001 Message-Id: From: Martin Kletzander Date: Wed, 31 Jan 2018 16:32:28 +0100 Subject: [PATCH] fixup_resctrlinfo https://bugzilla.redhat.com/show_bug.cgi?id=1289368 Signed-off-by: Martin Kletzander (cherry picked from commit 434848d7dca9d1a7838ab53bbfdcf580ef7f2cc2) Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index f122af2050..d439e7792c 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -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]) { -- 2.16.1