Re: [PATCH 05/10] nodeinfo: Add out parameter to nodeGetPresentCPUBitmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 17, 2015 at 18:13:24 +0200, Andrea Bolognani wrote:
> This aligns it with nodeGetCPUBitmap(), which already has a
> similar out parameters, and relieves users of this API from the
> need to call virBitmapSize() on the returned bitmap.
> ---
>  src/nodeinfo.c       | 8 ++++++--
>  src/nodeinfo.h       | 6 ++++--
>  src/util/vircgroup.c | 4 +---
>  3 files changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/src/nodeinfo.c b/src/nodeinfo.c
> index 5aa0607..7aecc8f 100644
> --- a/src/nodeinfo.c
> +++ b/src/nodeinfo.c
> @@ -440,7 +440,7 @@ virNodeParseNode(const char *sysfs_prefix,
>          goto cleanup;
>      }
>  
> -    present_cpumap = nodeGetPresentCPUBitmap(sysfs_prefix);
> +    present_cpumap = nodeGetPresentCPUBitmap(sysfs_prefix, NULL);
>      if (!present_cpumap)
>          goto cleanup;
>  
> @@ -1280,7 +1280,8 @@ nodeGetCPUCount(const char *sysfs_prefix ATTRIBUTE_UNUSED)
>  }
>  
>  virBitmapPtr
> -nodeGetPresentCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED)
> +nodeGetPresentCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED,
> +                        int *size ATTRIBUTE_UNUSED)
>  {
>  #ifdef __linux__
>      virBitmapPtr present_cpus = NULL;
> @@ -1313,6 +1314,9 @@ nodeGetPresentCPUBitmap(const char *sysfs_prefix ATTRIBUTE_UNUSED)
>   cleanup:
>      VIR_FREE(present_path);
>  
> +    if (present_cpus && size)
> +        *size = npresent_cpus;
> +
>      return present_cpus;
>  #endif
>      virReportError(VIR_ERR_NO_SUPPORT, "%s",
> diff --git a/src/nodeinfo.h b/src/nodeinfo.h
> index 4f983c2..e83db7b 100644
> --- a/src/nodeinfo.h
> +++ b/src/nodeinfo.h
> @@ -44,8 +44,10 @@ int nodeGetCellsFreeMemory(unsigned long long *freeMems,
>  int nodeGetMemory(unsigned long long *mem,
>                    unsigned long long *freeMem);
>  
> -virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix);
> -virBitmapPtr nodeGetCPUBitmap(const char *sysfs_prefix, int *max_id);
> +virBitmapPtr nodeGetPresentCPUBitmap(const char *sysfs_prefix,
> +                                     int *size);
> +virBitmapPtr nodeGetCPUBitmap(const char *sysfs_prefix,
> +                              int *size);

I'd prefer something like "ncpus" or maxcpu rather than size. For
getting size virBitmapSize() is totally apropriate.

Peter

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]