提交 82d858ce 编写于 作者: O Olivia Yin 提交者: Ján Tomko

Define CPUINFO_FILE_LEN and fix maxlen of cpuinfo file for all uses

For example, the file /proc/cpuinfo for 24 cores PowerPC platform is larger than
the previous maximum size 2KB.
It will fail to start libvirtd with the error message as below:
virFileReadAll: Failed to read file '/proc/cpuinfo': Value too large for defined
data type
virSysinfoRead: internal error Failed to open /proc/cpuinfo

This patch defines CPUINFO_FILE_LEN as 10KB which is enough for most architectures.
Signed-off-by: NOlivia Yin <Hong-Hua.Yin@freescale.com>
Signed-off-by: NJán Tomko <jtomko@redhat.com>
上级 34542473
......@@ -50,6 +50,7 @@ static const char *sysinfoCpuinfo = "/proc/cpuinfo";
#define SYSINFO_SMBIOS_DECODER sysinfoDmidecode
#define SYSINFO sysinfoSysinfo
#define CPUINFO sysinfoCpuinfo
#define CPUINFO_FILE_LEN (10*1024) /* 10KB limit for /proc/cpuinfo file */
/* only to be used test programs, therefore not in sysinfo.h */
extern void virSysinfoSetup(const char *dmidecode, const char *sysinfo,
......@@ -223,7 +224,7 @@ virSysinfoRead(void)
if (VIR_ALLOC(ret) < 0)
goto no_memory;
if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
return NULL;
......@@ -341,7 +342,7 @@ virSysinfoRead(void)
if (VIR_ALLOC(ret) < 0)
goto no_memory;
if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
return NULL;
......@@ -470,7 +471,7 @@ virSysinfoRead(void)
goto no_memory;
/* Gather info from /proc/cpuinfo */
if (virFileReadAll(CPUINFO, 8192, &outbuf) < 0) {
if (virFileReadAll(CPUINFO, CPUINFO_FILE_LEN, &outbuf) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to open %s"), CPUINFO);
return NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册