mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 19:41:16 +00:00
virhostcpu.c: introduce virHostCPUGetAvailableCPUsBitmap()
The idea is to have a function that calls virHostCPUGetOnlineBitmap() but, instead of returning NULL if the host does not have CPU offlining capabilities, fall back to a bitmap containing all present CPUs. Next patch will use this helper in two other places. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
bc07020511
commit
42036650c6
@ -2223,6 +2223,7 @@ virHookPresent;
|
||||
|
||||
|
||||
# util/virhostcpu.h
|
||||
virHostCPUGetAvailableCPUsBitmap;
|
||||
virHostCPUGetCount;
|
||||
virHostCPUGetInfo;
|
||||
virHostCPUGetKVMMaxVCPUs;
|
||||
|
@ -1099,6 +1099,36 @@ virHostCPUGetMap(unsigned char **cpumap,
|
||||
}
|
||||
|
||||
|
||||
/* virHostCPUGetAvailableCPUsBitmap():
|
||||
*
|
||||
* Returns a virBitmap object with all available host CPUs.
|
||||
*
|
||||
* This is a glorified wrapper of virHostCPUGetOnlineBitmap()
|
||||
* that, instead of returning NULL when 'ifndef __linux__' and
|
||||
* the caller having to handle it outside the function, returns
|
||||
* a virBitmap with all the possible CPUs in the host, up to
|
||||
* virHostCPUGetCount(). */
|
||||
virBitmapPtr
|
||||
virHostCPUGetAvailableCPUsBitmap(void)
|
||||
{
|
||||
g_autoptr(virBitmap) bitmap = NULL;
|
||||
|
||||
if (!(bitmap = virHostCPUGetOnlineBitmap())) {
|
||||
int hostcpus;
|
||||
|
||||
if ((hostcpus = virHostCPUGetCount()) < 0)
|
||||
return NULL;
|
||||
|
||||
if (!(bitmap = virBitmapNew(hostcpus)))
|
||||
return NULL;
|
||||
|
||||
virBitmapSetAll(bitmap);
|
||||
}
|
||||
|
||||
return g_steal_pointer(&bitmap);
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT)
|
||||
|
||||
/* Get the number of threads per subcore.
|
||||
|
@ -43,6 +43,8 @@ int virHostCPUGetStats(int cpuNum,
|
||||
bool virHostCPUHasBitmap(void);
|
||||
virBitmapPtr virHostCPUGetPresentBitmap(void);
|
||||
virBitmapPtr virHostCPUGetOnlineBitmap(void);
|
||||
virBitmapPtr virHostCPUGetAvailableCPUsBitmap(void);
|
||||
|
||||
int virHostCPUGetCount(void);
|
||||
int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user