245
#elif defined(__s390__) || defined(__s390x__)
248
virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
250
char *cur, *eol = NULL;
251
const char *property;
253
/* Return if Manufacturer field is not found */
254
if ((cur = strstr(base, "Manufacturer")) == NULL)
258
if ((cur = strstr(base, "Manufacturer")) != NULL) {
259
cur = strchr(cur, ':') + 1;
260
eol = strchr(cur, '\n');
261
virSkipSpacesBackwards(cur, &eol);
262
if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
264
virSkipSpaces(&property);
265
ret->system_manufacturer = (char *) property;
267
if ((cur = strstr(base, "Type")) != NULL) {
268
cur = strchr(cur, ':') + 1;
269
eol = strchr(cur, '\n');
270
virSkipSpacesBackwards(cur, &eol);
271
if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
273
virSkipSpaces(&property);
274
ret->system_family = (char *) property;
276
if ((cur = strstr(base, "Sequence Code")) != NULL) {
277
cur = strchr(cur, ':') + 1;
278
eol = strchr(cur, '\n');
279
virSkipSpacesBackwards(cur, &eol);
280
if ((eol) && ((property = strndup(cur, eol - cur)) == NULL))
282
virSkipSpaces(&property);
283
ret->system_serial = (char *) property;
293
virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
295
char *cur, *eol, *tmp_base;
298
virSysinfoProcessorDefPtr processor;
300
if ((cur = strstr(base, "vendor_id")) != NULL) {
301
cur = strchr(cur, ':') + 1;
302
eol = strchr(cur, '\n');
303
virSkipSpacesBackwards(cur, &eol);
304
if ((eol) && ((tmp = strndup(cur, eol - cur)) == NULL))
307
manufacturer = (char *) tmp;
310
/* Find processor N: line and gather the processor manufacturer, version,
311
* serial number, and family */
312
while ((tmp_base = strstr(base, "processor ")) != NULL) {
314
eol = strchr(base, '\n');
315
cur = strchr(base, ':') + 1;
317
if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
321
processor = &ret->processor[ret->nprocessor - 1];
323
/* Set the processor manufacturer */
324
processor->processor_manufacturer = manufacturer;
326
if ((cur = strstr(base, "version =")) != NULL) {
327
cur += sizeof("version =");
328
eol = strchr(cur, ',');
330
((processor->processor_version = strndup(cur, eol - cur)) == NULL))
333
if ((cur = strstr(base, "identification =")) != NULL) {
334
cur += sizeof("identification =");
335
eol = strchr(cur, ',');
337
((processor->processor_serial_number = strndup(cur, eol - cur)) == NULL))
340
if ((cur = strstr(base, "machine =")) != NULL) {
341
cur += sizeof("machine =");
342
eol = strchr(cur, '\n');
344
((processor->processor_family = strndup(cur, eol - cur)) == NULL))
357
/* virSysinfoRead for s390x
358
* Gathers sysinfo data from /proc/sysinfo and /proc/cpuinfo */
360
virSysinfoRead(void) {
361
virSysinfoDefPtr ret = NULL;
364
if (VIR_ALLOC(ret) < 0)
367
/* Gather info from /proc/cpuinfo */
368
if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
369
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
370
_("Failed to open %s"), CPUINFO);
375
ret->processor = NULL;
376
if (virSysinfoParseProcessor(outbuf, ret) < 0)
379
/* Free buffer before reading next file */
382
/* Gather info from /proc/sysinfo */
383
if (virFileReadAll(SYSINFO, 4096, &outbuf) < 0) {
384
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
385
_("Failed to open %s"), SYSINFO);
389
if (virSysinfoParseSystem(outbuf, ret) < 0)
244
399
#elif defined(WIN32) || \
245
400
!(defined(__x86_64__) || \
246
401
defined(__i386__) || \