[libvirt] [PATCH] nodeinfo: enable nodeGetCPUCount for older kernels

Eric Blake eblake at redhat.com
Thu Nov 1 16:15:54 UTC 2012


On 11/01/2012 09:43 AM, Viktor Mihajlovski wrote:
> Since /sys/devices/system/cpu/present is not available on
> older kernels like on RHEL 5.x nodeGetCPUCount will
> fail there. The fallback implemented is to scan for
> /sys/devices/system/cpu/cpuNN entries.
> 
> Signed-off-by: Viktor Mihajlovski <mihajlov at linux.vnet.ibm.com>
> ---
>  src/nodeinfo.c |   33 ++++++++++++++++++++++++++++-----
>  1 files changed, 28 insertions(+), 5 deletions(-)

I like this.  I'll give it a run through my RHEL 5 VM, and if it works,
I'll install this before 1.0.0.

> +    if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/present")) {
> +        i = linuxParseCPUmax(SYSFS_SYSTEM_PATH "/cpu/present");
> +    } else if (virFileExists(SYSFS_SYSTEM_PATH "/cpu/cpu0")) {
> +        do {
> +            i++;
> +            VIR_FREE(cpupath);
> +            if (virAsprintf(&cpupath, "%s/cpu/cpu%d",
> +                            SYSFS_SYSTEM_PATH, i) < 0) {
> +                virReportOOMError();
> +                return -1;
> +            }
> +        } while (virFileExists(cpupath));

Okay, so this leaves 'i' at one larger than the maximum found cpu/cpuNN,
under the assumption is that if cpu/present is not found, then you can't
offline cpus, so cpu/cpuNN will exist and be contiguous.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

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


More information about the libvir-list mailing list