[PATCH 1/2] virhostcpu: Introduce virHostCPUGetIsolated()

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

 



This is a helper that parses /sys/devices/system/cpu/isolated
into a virBitmap. It's going to be needed soon.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 src/libvirt_private.syms |  1 +
 src/util/virhostcpu.c    | 21 +++++++++++++++++++++
 src/util/virhostcpu.h    |  1 +
 3 files changed, 23 insertions(+)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 839fe4f545..ed85f022e4 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2502,6 +2502,7 @@ virHostCPUGetCount;
 virHostCPUGetCPUID;
 virHostCPUGetHaltPollTime;
 virHostCPUGetInfo;
+virHostCPUGetIsolated;
 virHostCPUGetKVMMaxVCPUs;
 virHostCPUGetMap;
 virHostCPUGetMicrocodeVersion;
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 01de69c0d1..e61eb12414 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -1151,6 +1151,27 @@ virHostCPUGetAvailableCPUsBitmap(void)
     return g_steal_pointer(&bitmap);
 }
 
+/**
+ * virHostCPUGetIsolated:
+ *
+ * Returns a bitmap of isolated CPUs (e.g. those passed to isolcpus= kernel
+ * cmdline).
+ */
+virBitmap *
+virHostCPUGetIsolated(void)
+{
+#ifdef __linux__
+    virBitmap *ret = NULL;
+
+    virFileReadValueBitmap(&ret, "%s/cpu/isolated", SYSFS_SYSTEM_PATH);
+
+    return ret;
+#else
+    virReportError(VIR_ERR_NO_SUPPORT, "%s",
+                   _("map of isolated CPUs not implemented on this platform"));
+    return NULL;
+#endif
+}
 
 #if WITH_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT)
 
diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h
index d7e09bff22..e7b15a2649 100644
--- a/src/util/virhostcpu.h
+++ b/src/util/virhostcpu.h
@@ -43,6 +43,7 @@ bool virHostCPUHasBitmap(void);
 virBitmap *virHostCPUGetPresentBitmap(void);
 virBitmap *virHostCPUGetOnlineBitmap(void);
 virBitmap *virHostCPUGetAvailableCPUsBitmap(void);
+virBitmap *virHostCPUGetIsolated(void);
 
 int virHostCPUGetCount(void);
 int virHostCPUGetThreadsPerSubcore(virArch arch) G_NO_INLINE;
-- 
2.43.2
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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