On Tue, Apr 23, 2024 at 04:16:23PM +0200, Michal Privoznik wrote: > 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 | 31 +++++++++++++++++++++++++++++++ > src/util/virhostcpu.h | 1 + > 3 files changed, 33 insertions(+) > > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index 2c7e4b45d3..0f2d5db883 100644 > --- a/src/libvirt_private.syms > +++ b/src/libvirt_private.syms > @@ -2504,6 +2504,7 @@ virHostCPUGetCount; > virHostCPUGetCPUID; > virHostCPUGetHaltPollTime; > virHostCPUGetInfo; > +virHostCPUGetIsolated; > virHostCPUGetKVMMaxVCPUs; > virHostCPUGetMap; > virHostCPUGetMicrocodeVersion; > diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c > index 01de69c0d1..b6d1db2302 100644 > --- a/src/util/virhostcpu.c > +++ b/src/util/virhostcpu.c > @@ -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 an success is returned. s/an success/and success/ > + * > + * 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; > +}
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx