[PATCH V3 1/2] util: Allow to query the presence of host CPU bitmaps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux