]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: Allow to query the presence of host CPU bitmaps
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Fri, 25 Nov 2016 13:57:04 +0000 (14:57 +0100)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 13 Dec 2016 23:12:09 +0000 (18:12 -0500)
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>
src/libvirt_private.syms
src/util/virhostcpu.c
src/util/virhostcpu.h

index ffbf46c1ac8371a2084f91f40310efb85d9cb5c0..290c4799625d376111aa659c88354068dbbe2158 100644 (file)
@@ -1118,6 +1118,7 @@ virHostCPUGetOnlineBitmap;
 virHostCPUGetPresentBitmap;
 virHostCPUGetStats;
 virHostCPUGetThreadsPerSubcore;
+virHostCPUHasBitmap;
 virHostCPUStatsAssign;
 virHostMemAllocPages;
 virHostMemGetCellsFree;
index 42a52caa55a214de5c96fd4e201a2dfbf6e941fe..f29f3122acee018b9fd7dca06fd7ae1fc118b210 100644 (file)
@@ -1112,6 +1112,16 @@ virHostCPUGetCount(void)
 #endif
 }
 
+bool
+virHostCPUHasBitmap(void)
+{
+#ifdef __linux__
+    return true;
+#else
+    return false;
+#endif
+}
+
 virBitmapPtr
 virHostCPUGetPresentBitmap(void)
 {
index b0487046082f3a028e1edb06abf936ae095d9fb1..39f7cf8c88146cde145a8789eb368f01b05e36e5 100644 (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);