#include "virsysinfo.h"
#include "viralloc.h"
#include "vircommand.h"
+#include "virlog.h"
#include "virfile.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_SYSINFO
+VIR_LOG_INIT("util.sysinfo");
VIR_ENUM_IMPL(virSysinfo, VIR_SYSINFO_LAST,
"smbios");
char *tmp_base;
char *manufacturer = NULL;
char *procline = NULL;
+ char *ncpu = NULL;
int result = -1;
virSysinfoProcessorDefPtr processor;
if (!(tmp_base = virSysinfoParseS390Line(base, "vendor_id", &manufacturer)))
- goto cleanup;
+ goto error;
/* Find processor N: line and gather the processor manufacturer,
version, serial number, and family */
&& (tmp_base = virSysinfoParseS390Line(tmp_base, "processor ",
&procline))) {
if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
- goto cleanup;
+ goto error;
processor = &ret->processor[ret->nprocessor - 1];
if (VIR_STRDUP(processor->processor_manufacturer, manufacturer) < 0)
- goto cleanup;
+ goto error;
if (!virSysinfoParseS390Delimited(procline, "version",
&processor->processor_version,
'=', ',') ||
!virSysinfoParseS390Delimited(procline, "machine",
&processor->processor_family,
'=', '\n'))
- goto cleanup;
+ goto error;
VIR_FREE(procline);
}
- result = 0;
+
+ /* now, for each processor found, extract the frequency information */
+ tmp_base = (char *) base;
+
+ while ((tmp_base = strstr(tmp_base, "cpu number")) &&
+ (tmp_base = virSysinfoParseS390Line(tmp_base, "cpu number", &ncpu))) {
+ unsigned int n;
+ char *mhz = NULL;
+
+ if (virStrToLong_uip(ncpu, NULL, 10, &n) < 0)
+ goto error;
+
+ if (n >= ret->nprocessor) {
+ VIR_DEBUG("CPU number '%u' out of range", n);
+ goto cleanup;
+ }
+
+ if (!(tmp_base = strstr(tmp_base, "cpu MHz static")) ||
+ !virSysinfoParseS390Line(tmp_base, "cpu MHz static", &mhz))
+ goto cleanup;
+
+ ret->processor[n].processor_max_speed = mhz;
+
+ VIR_FREE(ncpu);
+ }
cleanup:
+ result = 0;
+
+ error:
VIR_FREE(manufacturer);
VIR_FREE(procline);
+ VIR_FREE(ncpu);
return result;
}