mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
virHostCPUHasValidSubcoreConfiguration: Refactor cleanup
Use automatic memory freeing for the temporary bitmap and remove the pointless 'cleanup' section. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
19228b6016
commit
20ddaa9797
@ -450,31 +450,25 @@ virHostCPUParseNode(const char *node,
|
|||||||
static bool
|
static bool
|
||||||
virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore)
|
virHostCPUHasValidSubcoreConfiguration(int threads_per_subcore)
|
||||||
{
|
{
|
||||||
virBitmap *online_cpus = NULL;
|
g_autoptr(virBitmap) online_cpus = NULL;
|
||||||
int cpu = -1;
|
int cpu = -1;
|
||||||
bool ret = false;
|
|
||||||
|
|
||||||
/* No point in checking if subcores are not in use */
|
/* No point in checking if subcores are not in use */
|
||||||
if (threads_per_subcore <= 0)
|
if (threads_per_subcore <= 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
if (!(online_cpus = virHostCPUGetOnlineBitmap()))
|
if (!(online_cpus = virHostCPUGetOnlineBitmap()))
|
||||||
goto cleanup;
|
return false;
|
||||||
|
|
||||||
while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) {
|
while ((cpu = virBitmapNextSetBit(online_cpus, cpu)) >= 0) {
|
||||||
|
|
||||||
/* A single online secondary thread is enough to
|
/* A single online secondary thread is enough to
|
||||||
* make the configuration invalid */
|
* make the configuration invalid */
|
||||||
if (cpu % threads_per_subcore != 0)
|
if (cpu % threads_per_subcore != 0)
|
||||||
goto cleanup;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = true;
|
return true;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virBitmapFree(online_cpus);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user