Bug 857881

Summary: libvirt returns wrong memory size on uclibc
Product: [Community] Virtualization Tools Reporter: Carlo Landmeter <clandmeter>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NEXTRELEASE QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: acathrow, jtomko
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-04-22 07:19:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Carlo Landmeter 2012-09-17 11:52:21 UTC
Description of problem:

libvirt reports wrong "memory size"

Version-Release number of selected component (if applicable):

Latest stable (0.10.1)

How reproducible:

Install latest alpinelinux stable (uclibc based distribution) including libvirt

Exec: virsh nodeinfo
  
Actual results:

Memory size:         65536 KiB

Expected results:

Installed memory size is 4GB

Additional info:

on uclibc sysconf(_SC_PHYS_PAGES) returns -1
while _SC_PAGE_SIZE gives the correct value

found in: gnulib/lib/physmem.c

Comment 1 Ján Tomko 2014-04-22 07:19:53 UTC
This has been fixed in gnulib:
commit 22756d58aa46c291f7fa1c63d61c7c0483622c4e
Author:     Natanael Copa <ncopa>
AuthorDate: 2014-04-18 09:16:27 +0000
Commit:     Pádraig Brady <P>
CommitDate: 2014-04-19 12:34:49 +0100

    physmem: use sysinfo if _SC_PHYS_PAGES unavailable
    
    * lib/physmem.c (physmem_total): Some systems like musl libc do not
    (yet) support _SC_PHYS_PAGES.  Use the linux syscall sysinfo as fallback
    if _SC_PHYS_PAGES or _SC_PAGESIZE fails.
    (physmem_available): Likewise for _SC_AVPHYS_PAGES.
    
    Signed-off-by: Natanael Copa <ncopa>

git describe: v0.1-119-g22756d5

Libvirt uses it since
commit 45e134d6fcb63e9fa052b3490120d51040f7cec4
Author:     Eric Blake <eblake>
CommitDate: 2014-04-21 14:52:28 -0600

    maint: update to latest gnulib
    
    Among other patches, Natanael Copa contributed a fix for
    pyshmem_available when using musl libc that directly affects
    libvirt.
    
    * .gnulib: Update to latest, in part for musl libc compat.
    
    Signed-off-by: Eric Blake <eblake>

git describe: v1.2.3-142-g45e134d