util: Allow to query the presence of host CPU bitmaps

The functions to retrieve online and present host CPU information
are only supported on Linux for the time being.

This leads to runtime errors if these function are used on other
platforms. To avoid that, code in higher levels using the functions
must replicate the conditional compilation in higher level which
is error prone (and is plainly spoken ugly).

Adding a function virHostCPUHasBitmap that can be used to check
for host CPU bitmap support.

NB: There are other functions including the host CPU count that
are lacking support on all platforms, but they are too essential
in order to be bypassed.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
This commit is contained in:
Viktor Mihajlovski 2016-11-25 14:57:04 +01:00 committed by John Ferlan
parent f00c00475f
commit 1be35910f7
3 changed files with 12 additions and 0 deletions

View File

@ -1118,6 +1118,7 @@ virHostCPUGetOnlineBitmap;
virHostCPUGetPresentBitmap;
virHostCPUGetStats;
virHostCPUGetThreadsPerSubcore;
virHostCPUHasBitmap;
virHostCPUStatsAssign;
virHostMemAllocPages;
virHostMemGetCellsFree;

View File

@ -1112,6 +1112,16 @@ virHostCPUGetCount(void)
#endif
}
bool
virHostCPUHasBitmap(void)
{
#ifdef __linux__
return true;
#else
return false;
#endif
}
virBitmapPtr
virHostCPUGetPresentBitmap(void)
{

View File

@ -35,6 +35,7 @@ int virHostCPUGetStats(int cpuNum,
int *nparams,
unsigned int flags);
bool virHostCPUHasBitmap(void);
virBitmapPtr virHostCPUGetPresentBitmap(void);
virBitmapPtr virHostCPUGetOnlineBitmap(void);
int virHostCPUGetCount(void);