/* virSysinfoRead for ARMv7 * Gathers sysinfo data from /proc/cpuinfo */ virSysinfoDefPtr virSysinfoRead(void) { virSysinfoDefPtr ret = NULL; char *outbuf = NULL; if (VIR_ALLOC(ret) < 0) goto no_memory; if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), CPUINFO); return NULL; } ret->nprocessor = 0; ret->processor = NULL; if (virSysinfoParseProcessor(outbuf, ret) < 0) goto no_memory; if (virSysinfoParseSystem(outbuf, ret) < 0) goto no_memory; return ret; no_memory: VIR_FREE(outbuf); return NULL; }
virSysinfoDefPtr virSysinfoRead(void) { char *path; virSysinfoDefPtr ret = NULL; char *outbuf = NULL; virCommandPtr cmd; path = virFindFileInPath(SYSINFO_SMBIOS_DECODER); if (path == NULL) { virSmbiosReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to find path for %s binary"), SYSINFO_SMBIOS_DECODER); return NULL; } cmd = virCommandNewArgList(path, "-q", "-t", "0,1,4,17", NULL); VIR_FREE(path); virCommandSetOutputBuffer(cmd, &outbuf); if (virCommandRun(cmd, NULL) < 0) { virSmbiosReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to execute command %s"), path); goto cleanup; } if (VIR_ALLOC(ret) < 0) goto no_memory; ret->type = VIR_SYSINFO_SMBIOS; if (virSysinfoParseBIOS(outbuf, ret) < 0) goto no_memory; if (virSysinfoParseSystem(outbuf, ret) < 0) goto no_memory; ret->nprocessor = 0; ret->processor = NULL; if (virSysinfoParseProcessor(outbuf, ret) < 0) goto no_memory; ret->nmemory = 0; ret->memory = NULL; if (virSysinfoParseMemory(outbuf, ret) < 0) goto no_memory; cleanup: VIR_FREE(outbuf); virCommandFree(cmd); return ret; no_memory: virReportOOMError(); virSysinfoDefFree(ret); ret = NULL; goto cleanup; }
/* virSysinfoRead for s390x * Gathers sysinfo data from /proc/sysinfo and /proc/cpuinfo */ virSysinfoDefPtr virSysinfoRead(void) { virSysinfoDefPtr ret = NULL; char *outbuf = NULL; if (VIR_ALLOC(ret) < 0) goto no_memory; /* Gather info from /proc/cpuinfo */ if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), CPUINFO); return NULL; } ret->nprocessor = 0; ret->processor = NULL; if (virSysinfoParseProcessor(outbuf, ret) < 0) goto no_memory; /* Free buffer before reading next file */ VIR_FREE(outbuf); /* Gather info from /proc/sysinfo */ if (virFileReadAll(SYSINFO, 8192, &outbuf) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to open %s"), SYSINFO); return NULL; } if (virSysinfoParseSystem(outbuf, &ret->system) < 0) goto no_memory; return ret; no_memory: virSysinfoDefFree(ret); VIR_FREE(outbuf); return NULL; }