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

Peter Krempa pkrempa at redhat.com
Mon Jul 20 13:15:45 UTC 2015


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150720/d64a6390/attachment-0001.sig>


More information about the libvir-list mailing list