mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
virhostmem: Let caller pass max NUMA node to virHostMemGetFreePages
In all three cases (LXC, QEMU and VBox drivers) the caller has access to host capabilities and thus know the maximum NUMA node. This means, that virHostMemGetFreePages() doesn't have to query it. Querying may fail if libvirt was compiled without numactl support. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
20816cbda5
commit
59e3584f71
@ -5013,12 +5013,22 @@ lxcNodeGetFreePages(virConnectPtr conn,
|
||||
unsigned long long *counts,
|
||||
unsigned int flags)
|
||||
{
|
||||
virLXCDriver *driver = conn->privateData;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
int lastCell;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (virNodeGetFreePagesEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell, cellCount, counts);
|
||||
if (!(caps = virLXCDriverGetCapabilities(driver, false)))
|
||||
return -1;
|
||||
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(caps->host.numa);
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell, cellCount,
|
||||
lastCell, counts);
|
||||
}
|
||||
|
||||
|
||||
|
@ -17428,12 +17428,22 @@ qemuNodeGetFreePages(virConnectPtr conn,
|
||||
unsigned long long *counts,
|
||||
unsigned int flags)
|
||||
{
|
||||
virQEMUDriver *driver = conn->privateData;
|
||||
g_autoptr(virCaps) caps = NULL;
|
||||
int lastCell;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
if (virNodeGetFreePagesEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell, cellCount, counts);
|
||||
if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
|
||||
return -1;
|
||||
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(caps->host.numa);
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell, cellCount,
|
||||
lastCell, counts);
|
||||
}
|
||||
|
||||
|
||||
|
@ -843,14 +843,12 @@ virHostMemGetFreePages(unsigned int npages,
|
||||
unsigned int *pages,
|
||||
int startCell,
|
||||
unsigned int cellCount,
|
||||
int lastCell,
|
||||
unsigned long long *counts)
|
||||
{
|
||||
int cell, lastCell;
|
||||
int cell;
|
||||
size_t i, ncounts = 0;
|
||||
|
||||
if ((lastCell = virNumaGetMaxNode()) < 0)
|
||||
return 0;
|
||||
|
||||
if (startCell > lastCell) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("start cell %d out of range (0-%d)"),
|
||||
|
@ -45,6 +45,7 @@ int virHostMemGetFreePages(unsigned int npages,
|
||||
unsigned int *pages,
|
||||
int startCell,
|
||||
unsigned int cellCount,
|
||||
int lastCell,
|
||||
unsigned long long *counts);
|
||||
|
||||
int virHostMemAllocPages(unsigned int npages,
|
||||
|
@ -7598,7 +7598,7 @@ vboxNodeGetFreeMemory(virConnectPtr conn G_GNUC_UNUSED)
|
||||
}
|
||||
|
||||
static int
|
||||
vboxNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
|
||||
vboxNodeGetFreePages(virConnectPtr conn,
|
||||
unsigned int npages,
|
||||
unsigned int *pages,
|
||||
int startCell,
|
||||
@ -7606,9 +7606,17 @@ vboxNodeGetFreePages(virConnectPtr conn G_GNUC_UNUSED,
|
||||
unsigned long long *counts,
|
||||
unsigned int flags)
|
||||
{
|
||||
struct _vboxDriver *driver = conn->privateData;
|
||||
int lastCell;
|
||||
|
||||
virCheckFlags(0, -1);
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell, cellCount, counts);
|
||||
virObjectLock(driver);
|
||||
lastCell = virCapabilitiesHostNUMAGetMaxNode(driver->caps->host.numa);
|
||||
virObjectUnlock(driver);
|
||||
|
||||
return virHostMemGetFreePages(npages, pages, startCell,
|
||||
cellCount, lastCell, counts);
|
||||
}
|
||||
|
||||
static int
|
||||
|
Loading…
Reference in New Issue
Block a user