mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-09 15:00:07 +00:00
virhostcpu: Introduce virHostCPUGetIsolated()
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@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
f3c6c7623c
commit
3c948ef699
@ -2505,6 +2505,7 @@ virHostCPUGetCount;
|
||||
virHostCPUGetCPUID;
|
||||
virHostCPUGetHaltPollTime;
|
||||
virHostCPUGetInfo;
|
||||
virHostCPUGetIsolated;
|
||||
virHostCPUGetKVMMaxVCPUs;
|
||||
virHostCPUGetMap;
|
||||
virHostCPUGetMicrocodeVersion;
|
||||
|
@ -1152,6 +1152,37 @@ virHostCPUGetAvailableCPUsBitmap(void)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virHostCPUGetIsolated:
|
||||
* @isolated: returned bitmap of isolated CPUs
|
||||
*
|
||||
* Sets @isolated to point to a bitmap of isolated CPUs (e.g. those passed to
|
||||
* isolcpus= kernel cmdline). If the file doesn't exist, @isolated is set to
|
||||
* NULL and success is returned. If the file does exist but it's empty,
|
||||
* @isolated is set to an empty bitmap and success is returned.
|
||||
*
|
||||
* Returns: 0 on success,
|
||||
* -1 otherwise (with error reported).
|
||||
*/
|
||||
int
|
||||
virHostCPUGetIsolated(virBitmap **isolated)
|
||||
{
|
||||
g_autoptr(virBitmap) bitmap = NULL;
|
||||
int rc;
|
||||
|
||||
rc = virFileReadValueBitmapAllowEmpty(&bitmap, "%s/cpu/isolated", SYSFS_SYSTEM_PATH);
|
||||
if (rc == -2) {
|
||||
*isolated = NULL;
|
||||
return 0;
|
||||
} else if (rc < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*isolated = g_steal_pointer(&bitmap);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#if WITH_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT)
|
||||
|
||||
/* Get the number of threads per subcore.
|
||||
|
@ -43,6 +43,7 @@ bool virHostCPUHasBitmap(void);
|
||||
virBitmap *virHostCPUGetPresentBitmap(void);
|
||||
virBitmap *virHostCPUGetOnlineBitmap(void);
|
||||
virBitmap *virHostCPUGetAvailableCPUsBitmap(void);
|
||||
int virHostCPUGetIsolated(virBitmap **isolated);
|
||||
|
||||
int virHostCPUGetCount(void);
|
||||
int virHostCPUGetThreadsPerSubcore(virArch arch) G_NO_INLINE;
|
||||
|
Loading…
Reference in New Issue
Block a user