static int
virPerfRdtAttrInit(void)
{
- char *buf = NULL;
char *tmp = NULL;
unsigned int attr_type = 0;
+ VIR_AUTOFREE(char *) buf = NULL;
if (virFileReadAllQuiet("/sys/devices/intel_cqm/type", 10, &buf) < 0)
- goto error;
+ return -1;
if ((tmp = strchr(buf, '\n')))
*tmp = '\0';
if (virStrToLong_ui(buf, NULL, 10, &attr_type) < 0) {
virReportSystemError(errno, "%s",
_("failed to get rdt event type"));
- goto error;
+ return -1;
}
- VIR_FREE(buf);
attrs[VIR_PERF_EVENT_CMT].attrType = attr_type;
attrs[VIR_PERF_EVENT_MBMT].attrType = attr_type;
attrs[VIR_PERF_EVENT_MBML].attrType = attr_type;
return 0;
-
- error:
- VIR_FREE(buf);
- return -1;
}
virPerfEventType type,
pid_t pid)
{
- char *buf = NULL;
struct perf_event_attr attr;
virPerfEventPtr event = &(perf->events[type]);
virPerfEventAttrPtr event_attr = &attrs[type];
}
if (type == VIR_PERF_EVENT_CMT) {
+ VIR_AUTOFREE(char *) buf = NULL;
+
if (virFileReadAll("/sys/devices/intel_cqm/events/llc_occupancy.scale",
10, &buf) < 0)
goto error;
_("failed to get cmt scaling factor"));
goto error;
}
-
- VIR_FREE(buf);
}
memset(&attr, 0, sizeof(attr));
error:
VIR_FORCE_CLOSE(event->fd);
- VIR_FREE(buf);
return -1;
}