mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +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
|
# util/virhostcpu.h
|
||||||
|
virHostCPUGetAvailableCPUsBitmap;
|
||||||
virHostCPUGetCount;
|
virHostCPUGetCount;
|
||||||
virHostCPUGetInfo;
|
virHostCPUGetInfo;
|
||||||
virHostCPUGetKVMMaxVCPUs;
|
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)
|
#if HAVE_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT)
|
||||||
|
|
||||||
/* Get the number of threads per subcore.
|
/* Get the number of threads per subcore.
|
||||||
|
@ -43,6 +43,8 @@ int virHostCPUGetStats(int cpuNum,
|
|||||||
bool virHostCPUHasBitmap(void);
|
bool virHostCPUHasBitmap(void);
|
||||||
virBitmapPtr virHostCPUGetPresentBitmap(void);
|
virBitmapPtr virHostCPUGetPresentBitmap(void);
|
||||||
virBitmapPtr virHostCPUGetOnlineBitmap(void);
|
virBitmapPtr virHostCPUGetOnlineBitmap(void);
|
||||||
|
virBitmapPtr virHostCPUGetAvailableCPUsBitmap(void);
|
||||||
|
|
||||||
int virHostCPUGetCount(void);
|
int virHostCPUGetCount(void);
|
||||||
int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE;
|
int virHostCPUGetThreadsPerSubcore(virArch arch) G_GNUC_NO_INLINE;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user