[libvirt] [PATCH] Define CPUINFO_FILE_LEN and fix maxlen of cpuinfo file for powerpc

Hong-Hua.Yin at freescale.com Hong-Hua.Yin at freescale.com
Fri Apr 4 00:55:19 UTC 2014


Hi Eric,

Thanks for comments. I'll submit a new revision of this patch.

Best Regards,
Olivia

> -----Original Message-----
> From: Eric Blake [mailto:eblake at redhat.com]
> Sent: Thursday, April 03, 2014 8:25 PM
> To: Yin Olivia-R63875; libvir-list at redhat.com
> Subject: Re: [libvirt] [PATCH] Define CPUINFO_FILE_LEN and fix maxlen of
> cpuinfo file for powerpc
> 
> On 04/03/2014 12:43 AM, Olivia Yin wrote:
> > This patch define CPUINFO_FILE_LEN as 2KB which is enough for most
> architectures.
> >
> > For the 24 cores PowerPC machines, the file of /proc/cpuinfo will be
> larger than 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
> >
> > So this patch increases the maxlen of cpuinfo for PowerPC architecture.
> >
> > Signed-off-by: Olivia Yin <Hong-Hua.Yin at freescale.com>
> > ---
> >  src/util/virsysinfo.c | 6 +++---
> >  src/util/virsysinfo.h | 2 ++
> >  2 files changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index
> > 7b16157..33c4bc6 100644
> > --- a/src/util/virsysinfo.c
> > +++ b/src/util/virsysinfo.c
> > @@ -223,7 +223,7 @@ virSysinfoRead(void)
> >      if (VIR_ALLOC(ret) < 0)
> >          goto no_memory;
> >
> > -    if (virFileReadAll(CPUINFO, 2048, &outbuf) < 0) {
> > +    if (virFileReadAll(CPUINFO, 2 * CPUINFO_FILE_LEN, &outbuf) < 0) {
> 
> Uggh.  Having to multiply the constant means you defined the constant wrong.
> Just make CPUINFO_FILE_LEN big enough.  Even as large as 1M, for ALL uses,
> is not a burden.
> 
> > +++ b/src/util/virsysinfo.h
> > @@ -102,4 +102,6 @@ bool virSysinfoIsEqual(virSysinfoDefPtr src,
> >
> >  VIR_ENUM_DECL(virSysinfo)
> >
> > +#define CPUINFO_FILE_LEN	2048	/*2KB limit for normal cpuinfo file*/
> > +
> >  #endif /* __VIR_SYSINFOS_H__ */
> >
> 
> --
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org





More information about the libvir-list mailing list