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(a)linux.vnet.ibm.com>
---
src/libvirt_private.syms | 1 +
src/util/virhostcpu.c | 10 ++++++++++
src/util/virhostcpu.h | 1 +
3 files changed, 12 insertions(+)
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b7d26fd..7468623 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 f68176f..ec2469d 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 b048704..39f7cf8 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);
--
1.9.1