From: Viktor Mihajlovski Date: Fri, 25 Nov 2016 13:57:04 +0000 (+0100) Subject: util: Allow to query the presence of host CPU bitmaps X-Git-Tag: v3.0.0-rc1~326 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1be35910f711e4a66f998569f3edee1532a42757;p=thirdparty%2Flibvirt.git 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 --- diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index ffbf46c1ac..290c479962 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1118,6 +1118,7 @@ virHostCPUGetOnlineBitmap; virHostCPUGetPresentBitmap; virHostCPUGetStats; virHostCPUGetThreadsPerSubcore; +virHostCPUHasBitmap; virHostCPUStatsAssign; virHostMemAllocPages; virHostMemGetCellsFree; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 42a52caa55..f29f3122ac 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -1112,6 +1112,16 @@ virHostCPUGetCount(void) #endif } +bool +virHostCPUHasBitmap(void) +{ +#ifdef __linux__ + return true; +#else + return false; +#endif +} + virBitmapPtr virHostCPUGetPresentBitmap(void) { diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index b048704608..39f7cf8c88 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -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);