[libvirt] [PATCH v2] Define CPUINFO_FILE_LEN and fix maxlen of cpuinfo file for all uses

Ján Tomko jtomko at redhat.com
Fri Apr 4 06:19:41 UTC 2014


On 04/04/2014 03:21 AM, Olivia Yin wrote:
> 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: 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..873872c 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, CPUINFO_FILE_LEN, &outbuf) < 0) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("Failed to open %s"), CPUINFO);
>          return NULL;
> @@ -341,7 +341,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 +470,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;
> diff --git a/src/util/virsysinfo.h b/src/util/virsysinfo.h
> index fbb505b..b5336e2 100644
> --- a/src/util/virsysinfo.h
> +++ b/src/util/virsysinfo.h
> @@ -102,4 +102,6 @@ bool virSysinfoIsEqual(virSysinfoDefPtr src,
>  
>  VIR_ENUM_DECL(virSysinfo)
>  
> +#define CPUINFO_FILE_LEN (10*1024)	/*10KB limit for /proc/cpuinfo file*/
> +

This doesn't need to be in the header file.

I moved it near the definition of CPUINFO and pushed it. Thank you for the patch!

Jan


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140404/5a03ed22/attachment-0001.sig>


More information about the libvir-list mailing list