114
115
* Returns: a filled up sysinfo structure or NULL in case of error
116
#if defined(WIN32) || \
118
#if defined(__powerpc__)
120
virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
125
if ((cur = strstr(base, "platform")) == NULL)
129
/* Account for format 'platform : XXXX'*/
130
cur = strchr(cur, ':') + 1;
131
eol = strchr(cur, '\n');
134
((ret->system_family = strndup(cur, eol - cur)) == NULL))
137
if ((cur = strstr(base, "model")) != NULL) {
138
cur = strchr(cur, ':') + 1;
139
eol = strchr(cur, '\n');
141
if (eol && ((ret->system_serial = strndup(cur, eol - cur))
146
if ((cur = strstr(base, "machine")) != NULL) {
147
cur = strchr(cur, ':') + 1;
148
eol = strchr(cur, '\n');
150
if (eol && ((ret->system_version = strndup(cur, eol - cur))
162
virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
165
char *eol, *tmp_base;
166
virSysinfoProcessorDefPtr processor;
168
while((tmp_base = strstr(base, "processor")) != NULL) {
170
eol = strchr(base, '\n');
171
cur = strchr(base, ':') + 1;
173
if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
176
processor = &ret->processor[ret->nprocessor - 1];
180
((processor->processor_socket_destination = strndup
181
(cur, eol - cur)) == NULL))
184
if ((cur = strstr(base, "cpu")) != NULL) {
185
cur = strchr(cur, ':') + 1;
186
eol = strchr(cur, '\n');
189
((processor->processor_type = strndup(cur, eol - cur))
194
if ((cur = strstr(base, "revision")) != NULL) {
195
cur = strchr(cur, ':') + 1;
196
eol = strchr(cur, '\n');
199
((processor->processor_version = strndup(cur, eol - cur))
213
/* virSysinfoRead for PowerPC
214
* Gathers sysinfo data from /proc/cpuinfo */
216
virSysinfoRead(void) {
217
virSysinfoDefPtr ret = NULL;
220
if (VIR_ALLOC(ret) < 0)
223
if(virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
224
virSmbiosReportError(VIR_ERR_INTERNAL_ERROR,
225
_("Failed to open %s"), CPUINFO);
230
ret->processor = NULL;
231
if (virSysinfoParseProcessor(outbuf, ret) < 0)
234
if (virSysinfoParseSystem(outbuf, ret) < 0)
244
#elif defined(WIN32) || \
117
245
!(defined(__x86_64__) || \
118
246
defined(__i386__) || \
247
defined(__amd64__) || \
248
defined(__powerpc__))
121
250
virSysinfoRead(void) {
131
260
#else /* !WIN32 && x86 */
134
virSysinfoParseBIOS(char *base, virSysinfoDefPtr ret)
263
virSysinfoParseBIOS(const char *base, virSysinfoDefPtr ret)
136
char *cur, *eol = NULL;
265
const char *cur, *eol = NULL;
138
267
if ((cur = strstr(base, "BIOS Information")) == NULL)
142
271
if ((cur = strstr(base, "Vendor: ")) != NULL) {
167
return base + strlen("BIOS Information");
174
virSysinfoParseSystem(char *base, virSysinfoDefPtr ret)
303
virSysinfoParseSystem(const char *base, virSysinfoDefPtr ret)
176
char *cur, *eol = NULL;
305
const char *cur, *eol = NULL;
178
307
if ((cur = strstr(base, "System Information")) == NULL)
182
311
if ((cur = strstr(base, "Manufacturer: ")) != NULL) {
226
return base + strlen("System Information");
233
virSysinfoParseProcessor(char *base, virSysinfoDefPtr ret)
362
virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
235
char *cur, *eol, *tmp_base;
364
const char *cur, *tmp_base;
236
366
virSysinfoProcessorDefPtr processor;
238
368
while((tmp_base = strstr(base, "Processor Information")) != NULL) {
249
379
eol = strchr(cur, '\n');
250
380
virSkipSpacesBackwards(cur, &eol);
252
((processor->processor_socket_destination = strndup(cur, eol - cur)) == NULL))
382
((processor->processor_socket_destination
383
= strndup(cur, eol - cur)) == NULL))
255
386
if ((cur = strstr(base, "Type: ")) != NULL) {
273
405
eol = strchr(cur, '\n');
274
406
virSkipSpacesBackwards(cur, &eol);
276
((processor->processor_manufacturer = strndup(cur, eol - cur)) == NULL))
408
((processor->processor_manufacturer
409
= strndup(cur, eol - cur)) == NULL))
279
412
if ((cur = strstr(base, "Signature: ")) != NULL) {
281
414
eol = strchr(cur, '\n');
282
415
virSkipSpacesBackwards(cur, &eol);
284
((processor->processor_signature = strndup(cur, eol - cur)) == NULL))
417
((processor->processor_signature
418
= strndup(cur, eol - cur)) == NULL))
287
421
if ((cur = strstr(base, "Version: ")) != NULL) {
297
432
eol = strchr(cur, '\n');
298
433
virSkipSpacesBackwards(cur, &eol);
300
((processor->processor_external_clock = strndup(cur, eol - cur)) == NULL))
435
((processor->processor_external_clock
436
= strndup(cur, eol - cur)) == NULL))
303
439
if ((cur = strstr(base, "Max Speed: ")) != NULL) {
305
441
eol = strchr(cur, '\n');
306
442
virSkipSpacesBackwards(cur, &eol);
308
((processor->processor_max_speed = strndup(cur, eol - cur)) == NULL))
444
((processor->processor_max_speed
445
= strndup(cur, eol - cur)) == NULL))
311
448
if ((cur = strstr(base, "Status: ")) != NULL) {
321
459
eol = strchr(cur, '\n');
322
460
virSkipSpacesBackwards(cur, &eol);
324
((processor->processor_serial_number = strndup(cur, eol - cur)) == NULL))
462
((processor->processor_serial_number
463
= strndup(cur, eol - cur)) == NULL))
327
466
if ((cur = strstr(base, "Part Number: ")) != NULL) {
329
468
eol = strchr(cur, '\n');
330
469
virSkipSpacesBackwards(cur, &eol);
332
((processor->processor_part_number = strndup(cur, eol - cur)) == NULL))
471
((processor->processor_part_number
472
= strndup(cur, eol - cur)) == NULL))
336
476
base += strlen("Processor Information");
346
virSysinfoParseMemory(char *base, virSysinfoDefPtr ret)
486
virSysinfoParseMemory(const char *base, virSysinfoDefPtr ret)
348
char *cur, *eol, *tmp_base;
488
const char *cur, *tmp_base;
349
490
virSysinfoMemoryDefPtr memory;
351
492
while ((tmp_base = strstr(base, "Memory Device")) != NULL) {
482
629
ret->type = VIR_SYSINFO_SMBIOS;
486
if ((base = virSysinfoParseBIOS(base, ret)) == NULL)
631
if (virSysinfoParseBIOS(outbuf, ret) < 0)
489
if ((base = virSysinfoParseSystem(base, ret)) == NULL)
634
if (virSysinfoParseSystem(outbuf, ret) < 0)
492
637
ret->nprocessor = 0;
493
638
ret->processor = NULL;
494
if ((base = virSysinfoParseProcessor(base, ret)) == NULL)
639
if (virSysinfoParseProcessor(outbuf, ret) < 0)
497
642
ret->nmemory = 0;
498
643
ret->memory = NULL;
499
if (virSysinfoParseMemory(base, ret) == NULL)
644
if (virSysinfoParseMemory(outbuf, ret) < 0)