DIR *dirp)
{
int rv = -1;
- int ret = -1;
struct dirent *ent = NULL;
while ((rv = virDirRead(dirp, &ent, SYSFS_RESCTRL_PATH "/info")) > 0) {
ent->d_name);
} else if (rv < 0) {
/* Other failures are fatal, so just quit */
- goto cleanup;
+ return -1;
}
rv = virFileReadValueString(&cbm_mask_str,
_("Cannot get cbm_mask from resctrl cache info"));
}
if (rv < 0)
- goto cleanup;
+ return -1;
virStringTrimOptionalNewline(cbm_mask_str);
if (!(cbm_mask_map = virBitmapNewString(cbm_mask_str))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot parse cbm_mask from resctrl cache info"));
- goto cleanup;
+ return -1;
}
i_type->bits = virBitmapCountBits(cbm_mask_map);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot get min_cbm_bits from resctrl cache info"));
if (rv < 0)
- goto cleanup;
+ return -1;
if (resctrl->nlevels <= level)
VIR_EXPAND_N(resctrl->levels, resctrl->nlevels,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Duplicate cache type in resctrl for level %u"),
level);
- goto cleanup;
+ return -1;
}
i_level->types[type] = g_steal_pointer(&i_type);
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
virResctrlGetMemoryBandwidthInfo(virResctrlInfoPtr resctrl)
{
- int ret = -1;
int rv = -1;
g_autofree virResctrlInfoMemBWPtr i_membw = NULL;
* probably memory bandwidth allocation unsupported */
VIR_INFO("The path '" SYSFS_RESCTRL_PATH "/info/MB/bandwidth_gran'"
"does not exist");
- ret = 0;
- goto cleanup;
+ return 0;
} else if (rv < 0) {
/* Other failures are fatal, so just quit */
- goto cleanup;
+ return -1;
}
rv = virFileReadValueUint(&i_membw->min_bandwidth,
_("Cannot get min bandwidth from resctrl memory info"));
}
if (rv < 0)
- goto cleanup;
+ return -1;
rv = virFileReadValueUint(&i_membw->max_allocation,
SYSFS_RESCTRL_PATH "/info/MB/num_closids");
_("Cannot get max allocation from resctrl memory info"));
}
if (rv < 0)
- goto cleanup;
+ return -1;
resctrl->membw_info = g_steal_pointer(&i_membw);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
static int
virResctrlGetMonitorInfo(virResctrlInfoPtr resctrl)
{
- int ret = -1;
int rv = -1;
g_autofree char *featurestr = NULL;
g_auto(GStrv) features = NULL;
* monitor unsupported */
VIR_INFO("The file '" SYSFS_RESCTRL_PATH "/info/L3_MON/num_rmids' "
"does not exist");
- ret = 0;
- goto cleanup;
+ return 0;
} else if (rv < 0) {
/* Other failures are fatal, so just quit */
- goto cleanup;
+ return -1;
}
rv = virFileReadValueUint(&info_monitor->cache_reuse_threshold,
VIR_DEBUG("File '" SYSFS_RESCTRL_PATH
"/info/L3_MON/max_threshold_occupancy' does not exist");
} else if (rv < 0) {
- goto cleanup;
+ return -1;
}
rv = virFileReadValueString(&featurestr,
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Cannot get mon_features from resctrl"));
if (rv < 0)
- goto cleanup;
+ return -1;
if (!*featurestr) {
/* If no feature found in "/info/L3_MON/mon_features",
* some error happens */
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Got empty feature list from resctrl"));
- goto cleanup;
+ return -1;
}
features = virStringSplitCount(featurestr, "\n", 0, &nfeatures);
info_monitor->features = g_steal_pointer(&features);
resctrl->monitor_info = g_steal_pointer(&info_monitor);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
char *tmp = NULL;
size_t nmbs = 0;
size_t i;
- int ret = -1;
/* For no reason there can be spaces */
virSkipSpaces((const char **) &line);
mbs = virStringSplitCount(tmp, ";", 0, &nmbs);
for (i = 0; i < nmbs; i++) {
if (virResctrlAllocParseProcessMemoryBandwidth(resctrl, alloc, mbs[i]) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
char *tmp = strchr(cache, '=');
unsigned int cache_id = 0;
g_autoptr(virBitmap) mask = NULL;
- int ret = -1;
if (!tmp)
return 0;
_("Missing or inconsistent resctrl info for "
"level '%u' type '%s'"),
level, virCacheTypeToString(type));
- goto cleanup;
+ return -1;
}
virBitmapShrink(mask, resctrl->levels[level]->types[type]->bits);
if (virResctrlAllocUpdateMask(alloc, level, type, cache_id, mask) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int type = -1;
size_t ncaches = 0;
size_t i = 0;
- int ret = -1;
/* For no reason there can be spaces */
virSkipSpaces((const char **) &line);
for (i = 0; i < ncaches; i++) {
if (virResctrlAllocParseProcessCache(resctrl, alloc, level, type, caches[i]) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
g_auto(GStrv) lines = NULL;
size_t nlines = 0;
size_t i = 0;
- int ret = -1;
lines = virStringSplitCount(schemata, "\n", 0, &nlines);
for (i = 0; i < nlines; i++) {
if (virResctrlAllocParseCacheLine(resctrl, alloc, lines[i]) < 0)
- goto cleanup;
+ return -1;
if (virResctrlAllocParseMemoryBandwidthLine(resctrl, alloc, lines[i]) < 0)
- goto cleanup;
-
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
ssize_t pos = -1;
ssize_t last_bits = 0;
ssize_t last_pos = -1;
- int ret = -1;
if (!size)
return 0;
ignore_value(virBitmapSetBit(a_mask, i));
if (virResctrlAllocUpdateMask(alloc, level, type, cache, a_mask) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virResctrlAllocAssign(virResctrlInfoPtr resctrl,
virResctrlAllocPtr alloc)
{
- int ret = -1;
unsigned int level = 0;
g_autoptr(virResctrlAlloc) alloc_free = NULL;
g_autoptr(virResctrlAlloc) alloc_default = NULL;
alloc_default = virResctrlAllocGetDefault(resctrl);
if (!alloc_default)
- goto cleanup;
+ return -1;
if (virResctrlAllocMemoryBandwidth(resctrl, alloc) < 0)
- goto cleanup;
+ return -1;
if (virResctrlAllocCopyMasks(alloc, alloc_default) < 0)
- goto cleanup;
+ return -1;
if (virResctrlAllocCopyMemBW(alloc, alloc_default) < 0)
- goto cleanup;
+ return -1;
for (level = 0; level < alloc->nlevels; level++) {
virResctrlAllocPerLevelPtr a_level = alloc->levels[level];
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("Cache level %d does not support tuning"),
level);
- goto cleanup;
+ return -1;
}
for (type = 0; type < VIR_CACHE_TYPE_LAST; type++) {
_("Cache level %d does not support tuning for "
"scope type '%s'"),
level, virCacheTypeToString(type));
- goto cleanup;
+ return -1;
}
for (cache = 0; cache < a_type->nsizes; cache++) {
virResctrlInfoPerTypePtr i_type = i_level->types[type];
if (virResctrlAllocFindUnused(alloc, i_type, f_type, level, type, cache) < 0)
- goto cleanup;
+ return -1;
}
}
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
{
g_autofree char *tasks = NULL;
g_autofree char *pidstr = NULL;
- int ret = 0;
if (!path) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
virReportSystemError(errno,
_("Cannot write pid in tasks file '%s'"),
tasks);
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}