[libvirt] [RFC] New API to retrieve node CPU map

Eric Blake eblake at redhat.com
Thu Oct 11 12:27:32 UTC 2012


On 10/11/2012 01:01 AM, Viktor Mihajlovski wrote:
> 
> No problem to include flags for future extensions to be on the safe
> side. However, the map will contain all CPUs with the bits representing
> the online/offline state. If the intention is to quickly get the number
> of offline/online CPUS the following signature would be better IMO
> 
> int
> virNodeGetCpuMap(virConnectPtr conn,
>                  unsigned char **cpumap,
>          unsigned int *online,
>          unsigned int *offline,
>                  unsigned int flags);
> 

That starts to feel rather complex.

On the other hand, you have a point that returning maplen (number of
bytes allocated in the map) does NOT tell you how many cpus are online
without doing a population count of the result; worse, it cannot tell
you how many cpus are offline (a maplen of 1 is returned whether I have
4 cpus or 8 cpus, so if the map contains the value 0xb, does that mean I
had a 4 cpu machine with cpu2 off, or an 8 cpu machine with cpu2 and
cpu4-7 off?).  So allowing the user to optionally ask how many cpus are
online or offline might indeed also be useful, in addition to the maplen
needed to return the bitmap.

-- 
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/20121011/2ca20a17/attachment-0001.sig>


More information about the libvir-list mailing list